akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, m; cin >> n >> m;
    vector<P> st(n), ch(m);
    rep(i, n) {
        cin >> st[i].fr >> st[i].sc;
    }
    rep(i, m) {
        cin >> ch[i].fr >> ch[i].sc;
    }
    rep(i, n) {
        int ans = 0;
        int res = abs(st[i].fr - ch[0].fr) + abs(st[i].sc - ch[0].sc);
        rep(j, m) {
            if(res > abs(st[i].fr - ch[j].fr) + abs(st[i].sc - ch[j].sc)) {
                res = abs(st[i].fr - ch[j].fr) + abs(st[i].sc - ch[j].sc);
                ans = j;
            }
        }
        cout << ans + 1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long x = long.Parse(input[1]);
    long[] answers = new long[2*n-1];

    if(x == 1 || x == 2*n-1) Console.WriteLine("No");
    else
    {
      Console.WriteLine("Yes");
      if(x == n)//中央値
      {
        for(long i = 0; i < 2*n-1; i++) answers[i] = i+1;
      }
      else if(x < n)
      {
        for(long i = 0; i < n; i++) answers[i] = n-i;//543219876のように並べる
        for(long i = 0; i < n-1; i++) answers[2*n-2-i] = n+1+i;
        answers[n-1] = x;
        answers[n-x] = 1;
      }else
      {
        for(long i = 0; i < n; i++) answers[i] = n+i;//567891234のように並べる
        for(long i = 0; i < n-1; i++) answers[2*n-2-i] = n-1-i;
        answers[n-1] = x;
        answers[n-(2*n-1-x)-1] = 2*n-1;      
      }

      var sb = new StringBuilder();
      for(long i = 0; i < answers.Length; i++)
      {
        sb.AppendLine(answers[i].ToString());
      }
      Console.Write(sb);
    }
	}
}

Measured memory_bytes: 23004
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var S = new List<string>();
            for (int i = 0; i < N; i++)
            {
                S.Add(ReadText());
            }

            return S.Distinct().Count();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 48020
#include<stdio.h>
int sum(int x, int y){
  if(x%y==0){
    return x/y;
  }
  else{
    return x/y+1;
  }
}
int main(void){
  int a, b, c, d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  if(sum(c,b)<=sum(a,d)){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

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

int main(void){
   int N,xx,yy,tt;
   cin >> N;
   for(int i=0;i<N;i++){
       cin >> tt >> xx >> yy;
       if((tt - (xx+yy)) % 2 == 1 || tt < (xx+yy)){
           cout<<"No";
           return 0;
       }
   }
   cout<<"Yes";
   return 0;
}


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

int main() {
	int n, c = 0;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i][0] == 'Y')
			c++;
	}
	cout << (c ? "Four" : "Three") << endl;
	return 0;
}

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

int main() {
    string res="No";
    vector<int> A(9);
    map<int,int> bingocard;
    for (int i=0;i<9;i++){
        int tmp;
        cin >> tmp;
        A.at(i)=0;
        bingocard[tmp]=i+1;
    }
    int N;
    cin >> N;
    for (int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        if(bingocard.count(tmp)){
            if(bingocard[tmp]<10){
                bingocard[tmp]+=10;
            }
        }
    }
    for (pair<int, int>p:bingocard){
        if (p.second/10==1){
            A[(p.second%10)-1]=1;
        }
    }
    for (int i=1;i<=3;i++){
        if (A.at(i-1)==1 && A.at(i+2)==1 && A.at(i+5)==1){
            res="Yes";
        }
    }
    for (int i=1;i<=7;i=i+3){
        if(A.at(i-1)==1 && A.at(i)==1 && A.at(i+1)==1){
            res="Yes";
        }
    }
    if (A.at(0)==1 && A.at(4)==1 && A.at(8)==1){
        res="Yes";
    }
    if (A.at(2)==1 && A.at(4)==1 && A.at(6)==1){
        res="Yes";
    }
    cout << res << endl;
}

Measured memory_bytes: 256
def kaibun(S):
    N = len(S)
    harf = int(N / 2)
    if harf != 0:
        a = S[:harf]
        b = S[-harf:][::-1]
    else:
        a = S[:1]
        b = S[-1:][::-1]
    return a,b

S = input()
flag = 0
a,b = kaibun(S)
if a == b:
    a1,a2 = kaibun(a)
    if a1 == a2:
        b1,b2 = kaibun(b)
        if b1 == b2:
            flag = 0
        else:
            flag = 1
    else:
        flag = 1
else:
    flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, d int
	fmt.Fscan(read, &n, &d)

	x := make([][]float64, n)
	for i := 0; i < n; i++ {
		x[i] = make([]float64, d)
		for j := 0; j < d; j++ {
			fmt.Fscan(read, &x[i][j])
		}
	}

	cnt := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			var dist float64
			dist = 0.0
			for k := 0; k < d; k++ {
				dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k])
			}
			dist = math.Sqrt(dist)
			if math.Ceil(dist) == math.Floor(dist) {
				cnt++
			}
		}
	}
	fmt.Fprintln(write, cnt)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REPS(i,a,b) for(int i = a; i<b; ++i)
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long N,M,A, sum=0;
    cin >> N >> M;
    REPS(i,0,M) {
        cin >> A;
        sum+=A;
    }
    if (sum>N) cout << -1;
    else cout << N-sum;
}

Measured memory_bytes: 3656
from heapq import heappop, heappush
N,M = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB,key= lambda x: x[0])
hq = []
ans = 0
j = 0
for i in range(1,M+1):
  while j<N and AB[j][0]<=i:
    heappush(hq,-AB[j][1])
    j +=1
  if len(hq):
  	ans += -heappop(hq)
print(ans)

Measured memory_bytes: 82264
#include<bits/stdc++.h>
using namespace std;
typedef  long long   ll;
ll inf=1000000000000000000,mod=1000000007;
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       
        ll x;cin>>x;ll curr=100;
        for(ll i=0;;i++){

            if(curr>=x){
                cout<<i;return 0;
				// break;
            }
            curr=curr+curr/100;
        }

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF = 1e9+7;
    ll MOD = 998244353;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    #define F first
    #define S second
    #define pb(a) push_back(a)
    ///I hope I will get uprating and don't make mistakes
    ///I will never stop programming
    ///sqrt(-1) Love C++
    /// @TheofanisOrfanou Theo830
    ///AtCoder Beginner Contest 151
    int main(void){
        fastio;
        char a;
        c(a);
        a++;
        pl(a);
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
using ld = long double;

template <class T>
vector<T> solve(const vector<vector<T>> &A, const vector<T> &y) {
    int N = y.size();
    vector<T> x(N, 0);
    vector<vector<T>> tmp(N, vector<T>(N * 2, 0));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            tmp[i][j] = A[i][j];
    for (int i = 0; i < N; i++)
        tmp[i][N + i] = 1;
    
    for (int i = 0; i < N; i++) {
        if (tmp[i][i] == 0) tmp[i][i] += 1e-10;
        T sc = tmp[i][i];
        for (int k = 0; k < N * 2; k++)
            tmp[i][k] /= sc;
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            sc = tmp[j][i];
            for (int k = 0; k < N * 2; k++) {
                tmp[j][k] -= tmp[i][k] * sc;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            x[i] += tmp[i][N + j] * y[j];
        }
    }
    return x;
}

signed main() {
    while (1) {
        int d;
        cin >> d;
        if (d == 0) break;
        vector<ld> v(d + 3);
        for (int i = 0; i < d + 3; i++) {
            cin >> v[i];
        }
        
        for (int i = 0; i < d + 3; i++) {
            for (int l = i + 1; l < d + 3; l++) {
                vector<ld> y;
                y.reserve(d + 2);
                auto p = y;
                for (int j = 0; j < d + 3; j++) {
                    if (i == j || l == j) continue;
                    y.push_back(v[j]);
                    p.push_back(j);
                }
                vector<vector<ld>> A(d + 1, vector<ld>(d + 1, 0));
                for (int j = 0; j < d + 1; j++) {
                    ld x = p[j];
                    for (ld k = 0; k < d + 1; k++) {
                        A[j][k] = pow(x, k);
                    }
                }
                
                auto value = [&](const vector<ld> &c, ld p) {
                    ld ret = 0;
                    for (int k = 0; k < c.size(); k++) {
                        ret += c[k] * pow(p, k);
                    }
                    return ret;
                };

                auto c = solve(A, y);

                int cnt = 0;
                int idx = 0;
                for (int j = 0; j < d + 3; j++) {
                    if (abs(value(c, j) - v[j]) > 1e-4) {
                        cnt++;
                        idx = j;
                    }
                }
                if (cnt == 1) {
                    cout << idx << endl;
                    goto next_case;
                }
            }
        }
        next_case:;
    }
}


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

    ans+=n*(n-1)/2+m*(m-1)/2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin >> n;
    int h[100001];
    for(int i=0;i<n;i++) cin >> h[i];
    h[n] = 1000000001;
    int ma = 0;
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(h[i-1]>=h[i]){
            cnt++;
        }else{
            ma = max(ma,cnt);
            cnt = 0;
        }
    }
    cout << ma << endl;
}




Measured memory_bytes: 768
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N;

int main(){
  FAST_IO
  cin >> N;
  int answer = 0;
  for(int rep = 0, ele; rep < N; ++rep){
    cin >> ele;
    answer += ele - 1;
  }

  cout << answer << '\n';
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  rep(i,10000) {
    int za = i * 0.08;
    int zb = i * 0.1;
    if(za == a && zb == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>

using namespace std;

int main(void){
    int n;
    cin >> n ;
    cin.ignore();
    int h;
    int max = 0;
    int result = 0;
    for(int i = 0; i<n; i++){
        cin >> h;
        if( max <= h ){
            result += 1;
            max = h;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod = (int)1000000007;
#pragma endregion
lint n;
vector<pair<lint,lint> > prime_factorize(lint N) {
	vector<pair<lint, lint>> res;
	for (lint a = 2; a * a <= N; a++) {
		if (N % a != 0) continue;
		lint ex = 0; 
		while (N % a == 0) {
			ex++;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}
void input() {
	cin >> n;
	return;
}
int ans = 0;
void solve() {
	vector<pair<lint, lint>> d;
	d = prime_factorize(n);
	int cnt = 0;
	for (int i = 0; i < d.size(); i++) {
		auto s = d[i];
		for (int j = 1; j < INF; j++) {
			cnt += j;
			if (cnt > s.second) {
				ans += j - 1;
				cnt = 0;
				break;
			}
		}
	}
}

int main(void) {
	input();
	solve();
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 3696
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);

		int max = a+b;
		if(max < a-b)max=a-b;
		if(max < a*b)max=a*b;
		//出力
		Console.WriteLine(max);
	}
}

Measured memory_bytes: 13140
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;


int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	ll n,a,b;
	cin>>n>>a>>b;
	ll k=n/(a+b);
	k*=a;
	n%=(a+b);
	k+=min(n,a);
	cout<<k<<endl;




	return 0;
}



Measured memory_bytes: 256
import java.io.*;
class Main 
{
    public static void main(String args[])throws IOException
    {
    int c,i,c1;
    String S;
    BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    S=br.readLine();
    i=0;c=0;c1=0;
    while(i<3)
    {
       if(S.charAt(i)=='R')
       {c++;c1++;}
       else
       {
         if(c==1)
         c=0;
        }
      i++;
    }
     if(c==0&&c1==1)
       c=c1;
    System.out.println(c);
    }
}

Measured memory_bytes: 32356
import sys
sys.setrecursionlimit(10 ** 7)

from bisect import bisect_left

n = int(input())
a = list(map(int, input().split()))
uv = [list(map(int, input().split())) for _ in range(n - 1)]

INF = 10 ** 10

adj = [[] for _ in range(n)]
for u, v in uv:
    u -= 1
    v -= 1
    adj[u].append(v)
    adj[v].append(u)

arrived = [False] * n

ans = [None] * n
ans[0] = 1

dp = [INF] * n


def dfs(u):
    arrived[u] = True
    for v in adj[u]:
        if not arrived[v]:
            idx = bisect_left(dp, a[v])
            tmp = dp[idx]
            dp[idx] = a[v]
            ans[v] = bisect_left(dp, INF - 1)
            dfs(v)
            dp[idx] = tmp


dp[0] = a[0]
dfs(0)
print(*ans, sep="\n")



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s = "CODEFESTIVAL2016",ss;
	cin >> ss;
	int cnt = 0;
	rep(i, 16) {
		if (s[i] != ss[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}



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

using namespace std;

int main(void) {
  int N, tmp;
  cin >> N;
  vector<int> p;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    p.push_back(tmp);
  }

  int max = 0, sum = 0;
  for (int v : p) {
    if (max < v)
      max = v;
    sum += v;
  }

  cout << sum - (max / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
string s;
int ac, bc;

int main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(0);

	cin >> s;
	for(auto u : s){
		if(u == 'A') ac++;
		else bc++;
	}

	if(!bc || !ac){
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;


	cout.flush();
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    int dp[n][3];
    memset(dp,0,sizeof(dp));
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=max(dp[i-1][j+1]+a[i][j],dp[i-1][j+2]+a[i][j]);
            }
            else if(j==1)
            {
                dp[i][j]=max(dp[i-1][j-1]+a[i][j],dp[i-1][j+1]+a[i][j]);
            }
            else
            {
                dp[i][j]=max(dp[i-1][j-1]+a[i][j],dp[i-1][j-2]+a[i][j]);
            }
        }
    }
    ll ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans;
    /*for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return 0;
}









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

int main(){  
  int N;
  cin>>N;
  vector<vector<int>> G(N);
  vector<pair<int,int>> vp;

  for(int i=1;i<N;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a,b);
  }
  int C[10010];
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>C[i];
  }
  
  //最大スコア計算
  sort(C,C+N);
  for(int i=0;i<N-1;i++){
    sum+=C[i];
  }
  cout<<sum<<endl;
  
  //構築
  queue<int>que;
  que.push(0);  
  vector<int>ans(N,0);
  int k=N-1;
  //cout<<"#k"<<k<<" "<<C[k]<<endl;
  int l;
  int qq;
  
  //cout<<"G[0].size()"<<G[0].size()<<endl;
  //cout<<"que.size()"<<que.size()<<endl;
  
  while(que.size()!=0){
    
    qq=que.front();
    //cout<<"#"<<qq<<endl;
    que.pop();
    ans[qq]=C[k];
    
    k--;
    
    l=G[qq].size();
    //cout<<"$2$"<<l<<endl;
    for(int i=0;i<l;i++){
      if(ans[G[qq][i]]==0){
        que.push(G[qq][i]);
      }
    }
  }
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }

  return 0;
}




Measured memory_bytes: 4120
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
  int n,ans=0;
  for(int i=0;i<10;i++){
      cin>>n;
      ans+=n;
  }
  cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5404
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  double L; cin >> L;
  printf("%.9f\n", (L/3)*(L/3)*(L/3));
}


Measured memory_bytes: 256
import sys

n = int(input())
a = list(map(int,input().split()))
for i in range(n) :
    b = 0
    if a[i]%2 == 0 and a[i]%3 !=0 :
        b += 1
    if a[i]%2 == 0 and a[i]%5 != 0 :
        b += 1
    if b == 2 :
        print("DENIED")
        sys.exit()
print("APPROVED")

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

string yomikata(int n)
{
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        return "hon";
        break;
    case 3:
        return "bon";
        break;
    default:
        return "pon";
        break;
    }
}

int main()
{
    int n;
    cin >> n;
    n = n % 10;
    cout << yomikata(n) << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, M;
int s[5];
int c[5];
int ans[3];

void input() {
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> s[i] >> c[i];
    }
}

void solve() {
    bool ok = true;
    for(int i = 0; i < N; i++) {
        ans[i] = -1;
    }
    for(int i = 0; i < M; i++) {
        if(N != 1 and s[i] == 1 and c[i] == 0) ok = false;
        if(ans[s[i]-1] == -1) {
            ans[s[i]-1] = c[i];
        } else {
            if(ans[s[i]-1] != c[i]) ok = false;
        }
    }
    if(!ok) cout << -1 << endl;
    else {
        for(int i = 0; i < N; i++) {
            if(ans[i] != -1) {
                cout << ans[i];
            } else if(N != 1 and i == 0) {
                cout << 1;
            } else {
                cout << 0;
            }
        }
        cout << endl;
    }
    return;
}

int main() {
    input();
    solve();
    return 0;
}

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

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r)
{
    if (l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

void solve()
{
    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}


int main(int argc, char const *argv[])
{
    int k;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> k;
        pre.push_back(k);
    }
    for (int i = 0; i < n; i++) {
        cin >> k;
        in.push_back(k);
    }

    solve();

    return 0;
}




Measured memory_bytes: 3144
import Control.Monad
import Data.Maybe
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as BS

main = do
  [n, k] <- getIntList
  h <- getIntList
  print $ sum $ drop (fromIntegral k) (sortOn Down h)

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine


Measured memory_bytes: 47484
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int cnt[25];
int n,a[200010];
int main(){
    cin>>n;
    lol(i,n)cin>>a[i];
    ll ans=0;
    lol(j,25)cnt[j]=0;
    int last=0;
    lol(i,n){
	int t=a[i];
	lol(j,25){
	    cnt[j]+=t%2;
	    t/=2;
	}
	while(last<=i){
	    bool ok=true;
	    lol(j,25){
		if(cnt[j]>1)ok=false;
	    }
	    if(ok){
		ans+=i-last+1;
		//cout<<"%"<<i<<" "<<last<<endl;
		break;
	    }
	    int t=a[last];
	    lol(j,25){
		cnt[j]-=t%2;
		t/=2;
	    }
	    last++;
	}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int main(){
/*
int n;

for(n =1;;n++){
	if(x==0 && y==0) break;
	
}
*/
int a,b;
scanf("%d",&a);
scanf("%d",&b);

printf("%d %d %lf\n", a/b,a%b,(double)a/b);
return 0;
	}




Measured memory_bytes: 2112
N,M=map(int, raw_input().split() )
S=raw_input()
T=raw_input()

if M>N:
	N,M=M,N
	S,T=T,S

if S[0]!=T[0]:
	print -1
	quit()

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)


LCM=lcm(N,M)

if gcd(N,M)==1:
	print N*M
else:
	n=N/gcd(N,M)
	m=M/gcd(N,M)
	S_tmp=""
	T_tmp=""

	for i in range(N/n): S_tmp+=S[ i*n ]
	for i in range(M/m): T_tmp+=T[ i*m ]

	if S_tmp==T_tmp:
		print LCM
	else:
		print -1




Measured memory_bytes: 33948
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		// 入力を読み込む
		Scanner sc = new Scanner(System.in);

		// 取得
		int maxX = sc.nextInt();
		int maxY = sc.nextInt();
		int squearNum = sc.nextInt();
		
		// 長方形作成
		boolean[][] squear = new boolean[maxX][maxY];
		// 長方形の色を塗っていく
		int x;
		int y;
		int positionPaint;
		for (int i = 0; i < squearNum; i++) {
			x = sc.nextInt();
			y = sc.nextInt();
			positionPaint = sc.nextInt();
			
			// 条件によって色を塗る
			switch (positionPaint) {
			case 1 :
				paintX(squear, x, 0, maxY);
				break;
			case 2 :
				paintX(squear, maxX, x, maxY);
				break;
			case 3 :
				paintY(squear, y, 0, maxX);
				break;
			case 4 :
				paintY(squear, maxY, y, maxX);
				break;
			default :
			}
			
		}
		int count = 0;
		// 塗られていない箇所を求める
		for (int i = 0; i < maxX; i++) {
			for (int j = 0; j < maxY; j++) {
				if (!squear[i][j]) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
	
	public static void paintX(boolean[][] square, int maxX, int x, int maxY) {
		for (int i = x; i < maxX; i++) {
			for (int j = 0; j < maxY; j++) {
				// 塗りつぶす
				square[i][j] = true;
			}
		}
	}
	
	public static void paintY(boolean[][] square, int maxY, int y, int maxX) {
		for (int i = 0; i < maxX; i++) {
			for (int j = y; j < maxY; j++) {
				// 塗りつぶす
				square[i][j] = true;
			}
		}
	}

}


Measured memory_bytes: 24148
#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}
macro_rules ! readl { ( $ t : ty ) => { { let s = getline ( ) ; s . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,+ ) => { { let s = getline ( ) ; let mut iter = s . trim ( ) . split ( ' ' ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; }
macro_rules ! readlvec { ( $ t : ty ) => { { let s = getline ( ) ; let iter = s . trim ( ) . split ( ' ' ) ; iter . map ( | x | x . parse ( ) . unwrap ( ) ) . collect ::< Vec <$ t >> ( ) } } }
macro_rules ! mvec { ( $ v : expr , $ s : expr ) => { vec ! [ $ v ; $ s ] } ; ( $ v : expr , $ s : expr , $ ( $ t : expr ) ,* ) => { vec ! [ mvec ! ( $ v , $ ( $ t ) ,* ) ; $ s ] } ; }
macro_rules ! debug { ( $ x : expr ) => { println ! ( "{}: {:?}" , stringify ! ( $ x ) , $ x ) } }
fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator,
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display,
{
    for (i, e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}
struct ContestPrinter {
    s: String,
}
impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter { s: String::new() }
    }
    fn print<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}", x).as_str());
    }
    fn println<T>(&mut self, x: T)
    where
        T: std::fmt::Display,
    {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}
impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}
static MOD: i64 = 1e9 as i64 + 7;
fn is_max_i64(num: i64) -> bool {
    if num == i64::max_value() {
        true
    } else {
        false
    }
}
fn main() {
    let mut pr = ContestPrinter::new();
    let N = readl!(usize);
    let mut v = Vec::new();
    for i in 0..N {
        let a = readl!(usize);
        v.push(a);
    }

    let mut ans = 0;
    for i in 0..N-1 {
        let num = v[i] / 2;
        v[i] -= num * 2; ans += num;
        if (v[i] == 1) & (v[i + 1] > 0) {
            v[i+1] -= 1;
            ans += 1;
        }
    }
    if v[N-1] > 0 {
        ans += v[N-1] / 2;
    }

    pr.println(ans);
}

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

int main()
{
	int n, q, S[10000], T, res = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T;
		for (int j = 0; j < n; j++) {
			if (T == S[j]) {
				res++;
				break;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>
int main (){
	/*変数宣言*/
	int i,j,n,m,sum = 0;
	int a[101][101],b[101],c[101];

	/*変数入力*/
	scanf("%d %d",&n,&m);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)scanf("%d",&a[i][j]);
	}
	for (i = 0; i < m; i++)scanf("%d",&b[i]);

	for (i = 0; i < n; i++){
		c[i] = 0; 
		for (j = 0; j < m; j++)c[i] += a[i][j] * b[j];
	}
	
	/*出力*/
	for (i = 0; i < n; i++)printf("%d\n",c[i]);
	return 0;

}

/*
scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (j = 0; j < m; j++) scanf("%d", &b[j]);

	for (i = 0; i < n; i++) {
		c[i] = 0;
		for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
	}


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

	for (i = 0; i < n; i++){
		c[i] = 0; 
		for (j = 0; j < m; j++)c[i] += a[i][j] * b[j];
	}
*/


Measured memory_bytes: 2088
package main

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

var N, W int
var ws, vs []int

func main() {
	N, W = ReadInt(), ReadInt()
	ws = make([]int, N+1)
	vs = make([]int, N+1)
	for i := 0; i < N; i++ {
		ws[i], vs[i] = ReadInt(), ReadInt()
	}
	fmt.Println(solve(N, W))
}

var memo = make(map[int]map[int]int)

func solve(n int, w int) int {
	if n == 0 {
		return 0
	}
	if w == 0 {
		return 0
	}
	if _, ok := memo[n]; !ok {
		memo[n] = make(map[int]int)
	}
	if v, ok := memo[n][w]; ok {
		return v
	}
	v := solve(n-1, w)
	if w-ws[n-1] >= 0 {
		v = Max(v, solve(n-1, w-ws[n-1])+vs[n-1])
	}
	memo[n][w] = v
	return v
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 6560
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
score = 0
last = -1
for i in A:
    score += B[i-1]
    if(last+1 == i):
        score += C[last-1]
    last = i
print(score)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n=3;
	vector<int> a(n);
	for(int i=0;n>i;i++){
		cin>>a.at(i);
	}
	sort(a.begin(),a.end());
	cout<<a.at(n-1)-a.at(0)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int D, yyy[50], eee[50], *yks = yyy + 25, *eks = eee + 25;
ll ans;

ll Dfs (ll res, ll l, ll r) {
	if (res % l) return 0;
	if (l >= r) {
		if (res) return 0;
		else return l == r ? 10 : 1;
	} else {
		ll ret = 0, cur = r - l;
		l *= 10; r /= 10;
		for (int i = -9; i <= 9; ++i) ret += Dfs(res + cur * i, l, r) * eks[i];
		return ret;
	}
}

int main () {
	scanf("%d", &D);
	for (int i = 0; i <= 9; ++i) {
		for (int j = -9; j <= 0; ++j) {
			if (i) ++yks[i + j];
			++eks[i + j];
		}
	}
	for (ll i = 1e18; i > 1; i /= 10) {
		for (int j = -9; j <= 9; ++j) {
			ans += Dfs((i - 1) * j + D, 10, i / 10) * yks[j];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    string s,msa,msb;
    cin >> s;
    int p = 0;
    vector<int> v;
    msa = msb = "";
    REP(i,s.size()){
        v.push_back(0);
        if (s[i]!='x') {
            msa += s[i];
            msb = s[i] + msb;
            p++;
            v.push_back(0);
        } else {
            v[p]++;
        }
    }
    if (msa!=msb) {
        puts("-1");
        return 0;
    }
    int t = 0;
    REP(i,p+1){
        t += abs(v[i]-v[p-i]);
    }
    t /= 2;
    cout << t;
    return 0;
}


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

int main() {
    int K,A,B;
    cin >> K >> A >> B;

    int cnt = 0;

    for (A; A <= B; A++) {
        if (A % K == 0) {
            cnt++;
        }
    }

    if (cnt > 0) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;

using T = long long;
T binomial(T N, T K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}

int main() {
    int n;
    cin>>n;
    vector<int> a;
    unordered_map<int, int> count;
    for (int i=0;i<n;++i){
        int x;
        cin>>x;
        a.push_back(x);
        count.emplace(x,0);
        ++count[x];
    }
    long long sum = 0;
    for (const auto& p : count) {
        sum += binomial(p.second, 2);
    }
    for (int i=0;i<n;++i){
        auto ans = sum - binomial(count[a[i]],2) + binomial(count[a[i]]-1,2);
        cout << ans << "\n";
    }
}

Measured memory_bytes: 8380
import java.util.*;

public class Main{

     public static void main(String []args){
      Scanner in = new Scanner(System.in);       
        String s=in.next();
        int[] arr = new int[128];
       
         for (int i = 0; i < s.length(); i++) {
             arr[s.charAt(i)]++;
         }
               for (int i = 0; i < arr.length; i++) {
             if (arr[i]%2!=0){
                       System.out.println("No");
             return;
             }
         }
               System.out.println("Yes");
    }
}

Measured memory_bytes: 27028
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N,M;
vector<pair<int,int> > pic;
vector<int> gaku;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> N >> M;
	for(int i=0; i<N; i++){
		int s,v;
		cin >> s >> v;
		pic.push_back(MP(v,s));
	}
	sort(pic.begin(),pic.end());
	reverse(pic.begin(),pic.end());
	for(int i=0; i<M; i++){
		int c;
		cin >> c;
		gaku.push_back(c);
	}
	sort(gaku.begin(),gaku.end());

	int ans = 0;
	for(int i=0; i<N; i++){
		if(gaku.size() == 0) break;
		if(pic[i].second <= gaku.back()){
			ans++;
			gaku.erase(gaku.end()-1);
		}
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
	
	int n;
	cin>>n;
	if(n%2){
		float a = 0.0;
		a = n/2;
		a = (a + 1)/n;
		cout<<a<<endl;
	}
	else
		cout<<0.5<<endl;
	return 0;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))
wk = 0
if a[0] + a[1] > a[0] - a[1]:
    wk = a[0] + a[1]
    if wk > a[0] * a[1]:
        print(wk)
    else:
        print(a[0] * a[1])
else:
    wk = a[0] - a[1]
    if wk > a[0] * a[1]:
        print(wk)
    else:
        print(a[0] * a[1])


Measured memory_bytes: 3060
a = int(input())
b = map(int, input().split())
ans_list =[]
list_b =list(b)
if a == 0:
    ans_list.append(0)
else:
    for i in range(max(list_b)+1):
        ene_list =map(lambda x: (x-i)**2, list_b)
        sum_ene= sum(list(ene_list))
        ans_list.append(sum_ene)


print(min(ans_list))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  for(int i = 0; i <2; i++)
  {
    if(s[i]!=s[i+1])
    {
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
#define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(ll i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

void vlprn(vl &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }///

using DBL = double;
#define MAX 50

vvl nCr_table(MAX+1, vl(MAX+1, 1));

void nCr_table_create(ll N){
	rp(n,1,N+1) rp(r,1,N+1-n)
		nCr_table[n][r] = nCr_table[n-1][r] + nCr_table[n][r-1];

	// rp(n,0,N+1){rp(r,0,N+1)printf("%3lld ",nCr_table[n][r]);puts("");}puts("---");///
}

ll nCr(int n, int r){
	if(n < r) return 0;
	// if(n < r) return 1;
	int i = n - r;
	int j = r;
	// printf("n %d r %d i %d j %d\n",n,r,i,j);///
	return nCr_table[i][j];
}

int main(){
	ll N,A,B; cin>>N>>A>>B;
	vl V(N); rpz(i, N) cin>>V[i];
	sort(allr(V));
	nCr_table_create(N);

	DBL maxave = 0.0;
	rpz(i, A) maxave += V[i];
	maxave /= A;

	int n = 0, r = 0;
	ll v = V[A-1];
	rpz(i, N){
		if(v == V[i]){
			n++;
			if(i < A) r++;
		}
	}
	// printf("n %d r %d\n",n,r);//

	ll maxcnt = 0;
	if(r == A) rp(r, A, B+1) maxcnt += nCr(n, r);
	else maxcnt = nCr(n, r);

	printf("%.6f\n", maxave);
	cout<< maxcnt <<endl;
}


Measured memory_bytes: 256
n,P = map(int,input().split())
#i = 2
from collections import defaultdict
dic = defaultdict(int)
# 約数分解
if n == 1:
    print(P)
    exit()
i = 2
N = P
while i*i <= N:
    #print(i,N)
    if N%i != 0:
        i += 1
        continue
    num = 0
    while N%i == 0:
        num += 1
        N//=i
    dic[i] = num
    i += 1
if N != 1:
    dic[N] = 1
ans = 1
for k,v in dic.items():
    if v//n >= 1:
        ans *= k ** (v//n)
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "Yes";

struct Room {
  int id;
  int from;
  int depth;
};

queue<Room> q;

constexpr int NA = 1000000;

int main() {
  int N, M;
  cin >> N >> M;

  vector<vector<int>> graph(N+1,vector<int>());
  vector<Room> rooms(N+1, {0,0,NA});
  for (auto i = 1; i <= N; ++i) {
    rooms[i].id = i;
  }
  
  int a,b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  Room start = {1,0,0};
  q.emplace(start);

  while(!q.empty()) {
    Room now = q.front(); q.pop();
    auto from = now.id;
    auto dep = now.depth;

    for (int to: graph[from]) {
      Room next = {to, from, dep+1};
      if (next.depth < rooms[to].depth) {
        rooms[to].from = next.from;
        rooms[to].depth = next.depth;
        q.push(next);
      }
    }
  }


  for (auto i = 2; i <= N; ++i) {
    if (rooms[i].depth == NA) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  for (auto i = 2; i <= N; ++i) {
    cout << rooms[i].from << endl;
  }
  
  return 0;
}


Measured memory_bytes: 11808
#include<bits/stdc++.h>
using namespace std;
int f(int n)
{
	int s=0;
	for(int i=1;i<=n;i++)
	{
		if((i>=1&&i<10)||(i>=100&&i<1000)||(i>=10000&&i<100000))
		  s++;
	}
	return s;
}
int main()
{
	int n;
	cin>>n;
	cout<<f(n);
	return 0;
}

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

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;
        

            x = int.Parse(Console.ReadLine());
            if (x == 7 || x == 3 || x == 5)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadKey();
        
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll h,w,d;
    cin >> h >> w >> d;
    map<int,P> ma;
    rp(i,h){
        rp(j,w){
            int a;
            cin >> a;
            ma[a]=mp(i,j);
        }
    }
    matrix tab(d,Vi(1,0));
    repi(i,d+1,h*w+1){
        P p1=ma[i],p2=ma[i-d];
        ll ind=(i-1)/d-1;
        tab[i%d].pb(tab[i%d][ind]+abs(p1.first-p2.first)+abs(p1.second-p2.second));
    }
    ll q;
    cin >> q;
    Vi ans;
    while(q--){
        ll l,r;
        cin >> l >> r;
        ll res=l%d;
        ans.pb(tab[res][(r-1)/d]-tab[res][(l-1)/d]);
    }
    for(auto an:ans){
        print(an);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 14736
import math
import sys
MAX_INT = int(10e9)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B = IL()
ans = (A+B)/2
if int(ans) == math.ceil(ans):
    print(int(ans))
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define LL long long
string s;

// set<string> st;

// void rev(int i, int j){
// 	for(int l = i, r = j; l < r; l++, r-- ){
// 		swap(s[l],s[r]);
// 	}
// }

int num[30];

int main(){
	cin>>s;
	// st.insert(s);
	int n = s.length();
	// for(int i = 0; i < n; i++ ){
	// 	for(int j = i; j < n; j++ ){
	// 		rev(i,j);
	// 		if(st.count(s)){
	// 			printf("dup %d %d\n",i,j);
	// 		}
	// 		st.insert(s);
	// 		rev(i,j);
	// 	}
	// }
	// printf("%ld\n",st.size());

	for(char x : s){
		num[x-'a']++;
	}

	LL ans = (LL)n*(n-1)/2+1;

	for(int i = 0; i < 26; i++ ){
		ans -= (LL)num[i]*(num[i]-1)/2;
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 640