akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <tuple>
#include <algorithm>

using lli=long long int;
const double PI=4*std::atan(1);

struct p{
  p(int _x, int _y, double _t): x(_x),y(_y),t(_t) {}
  int x,y;
  double t;
};

int main(){
  int N;
  std::cin >> N;

  std::vector<p> p_arr;
  for(int i = 0; i < N; i++){
    int x,y;
    std::cin >> x >> y;
    double t = std::atan2(x,y);
    p_arr.emplace_back(x,y,t);
  }

  std::sort(p_arr.begin(), p_arr.end(), [](p& l, p& r){ return l.t < r.t; });
  std::vector<p> p2_arr(p_arr);
  p2_arr.insert(p2_arr.end(), p_arr.begin(), p_arr.end());
  std::vector<p> sum_arr;
  lli xs=0, ys=0;
  sum_arr.emplace_back(xs, ys, 0.0);
  for(auto&& it: p2_arr){
    xs += it.x;
    ys += it.y;
    sum_arr.emplace_back(xs, ys, 0.0);
  }
  lli r2_max = 0;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N; j++){
      lli xd = sum_arr[i+j].x-sum_arr[i].x;
      lli yd = sum_arr[i+j].y-sum_arr[i].y;
      r2_max = std::max(r2_max, xd*xd+yd*yd);
    }
  }

  std::cout << std::setprecision(40) << std::fixed << std::sqrt(1.0*r2_max) << std::endl;
  return 0;
}



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

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)
#define mod 1000000007

int main() {
	ll n;
	cin >> n;
	ll ans = 1;
	ll buf = 1;
	ll buf2 = 1;
	if (n < 2) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, n)ans = ans * 10 % mod;
	rep(i, n)buf = buf * 9 % mod;
	rep(i, n)buf2 = buf2 * 8 % mod;
	ans = (ans - 2 * buf + buf2)%mod;
	if (ans < 0)ans += mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
inn = input().split()
a = int(inn[0])
b = int(inn[1])
k = int(inn[2])

start = max(a, b) + 1
count = 0


rlist = list(range(0, start))
rlist.reverse()
for i in rlist:
    if a % i == 0 and b % i == 0:
        count += 1
        if count == k:
            print(i)
            break


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
    long long x,a,b,c,ans=0;//long long保险
    cin>>a>>b>>c>>x;//输入这四个数
    for(int i=0;i<=a;i++)//枚举500硬币的个数
        for(int j=0;j<=b;j++)//枚举100硬币的个数
            for(int z=0;z<=c;z++){//枚举50硬币的个数
                int k=i*500+j*100+z*50;//定义k为此时硬币总值
                if(k==x)//如果就是x
                   ans++;//计数器加一
                if(k>x)//这是一个优化，如果k值已经超过了x，后面的z到c时k的值一定大于x，肯定不等于x，所以可以直接退出当前循环
                   break;//退出当前循环
            }
    cout<<ans<<endl;//输出ans的值(AT题都要打换行)
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 1009
using namespace std;

int m,n,A,B; char a[N][N];
void gg(){ puts("NO"); exit(0); }
int main(){
	scanf("%d%d%d%d",&m,&n,&A,&B);
	int i,j;
	for (i=1; i<=m; i++)
		for (j=1; j<=n; j++) a[i][j]='.';
	if (n&1){
		for (i=1; i<m && B; i+=2){
			a[i][n]='^'; a[i+1][n]='v';
			B--;
		}
	}
	if ((B&1) && (m&1)){
		if (n>2 && m>1){
			a[m-1][n-2]='^'; a[m][n-2]='v';
			B--;
		}
	}
	for (i=1; i<m; i++)
		for (j=1; j<=n-(n&1) && B; j++) if (a[i][j]=='.' && a[i+1][j]=='.'){
			a[i][j]='^'; a[i+1][j]='v';
			B--;
		}
	if (B) gg();
	for (i=1; i<=m; i++)
		for (j=1; j<n && A; j++) if (a[i][j]=='.' && a[i][j+1]=='.'){
			a[i][j]='<'; a[i][j+1]='>';	
			A--;
		}
	if (A) gg();
	puts("YES");
	for (i=1; i<=m; i++) printf("%s\n",a[i]+1);
	return 0;
}
	

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    int l = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'A' | s[i] == 'C' | s[i] == 'G' | s[i] == 'T'){
            l += 1;
        }
        else{
            ans = fmax(ans, l);
            l = 0;
        }
    }
    ans = fmax(ans, l);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    for(register int i=0;i<a.size();++i)
        if(a[i]=='C')
            for(register int j=i+1;j<a.size();++j)
                if(a[j]=='F') return printf("Yes")%1;
    return printf("No")%1;
}


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

using namespace std;

int main(void) {
	string S, T;
	int sizeS, sizeT;
	int cntMAX=0, cnt=0;
	cin >> S;
	cin >> T;
	sizeS = S.size();
	sizeT = T.size();
	int i, j, k;

	int slide = sizeS - sizeT;

	for (i = 0; i <= slide; i++) {

		if (i != 0) {
			for (j = 0; j < sizeS; j++) {
				S[j] = S[j + 1];
			}
		}

		for (k = 0; k < sizeT; k++) {
			if (S[k] == T[k]) cnt++;
		}

		if (cntMAX < cnt) cntMAX = cnt;
		cnt = 0;
	}

	cout << sizeT - cntMAX << endl;
	return 0;
}

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

int main()
{
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i <= X + K - 1; ++i){
        cout << i;
        if (i != X+K-1){
            cout << ' ';
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

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

using ll = long long;

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

const int INF = 1LL<<29;

//#define __DBG__

int N;
string S,T;


void solve(void){
  
  cin >> N;
  cin >> S >> T;

  string U;
  
  REP(i,N){
    U += S[i];
    U += T[i];
  }
  
  
  cout << U << endl;
  
  
  return;
}

int main(int argc, const char * argv[]) {



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		long a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << max( { a*c,a*d,b*c,b*d } ) << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3652
import java.util.*;

class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
      	int[][] studentC = new int[n][2];
      	int[][] checkpointC = new int[m][2];
      	
      	for (int i = 0; i < n; i++) {
          	studentC[i][0] = Integer.parseInt(sc.next());
          	studentC[i][1] = Integer.parseInt(sc.next());
        }
      
      	for (int i = 0; i < m; i++) {
        	checkpointC[i][0] = Integer.parseInt(sc.next());
         	checkpointC[i][1] = Integer.parseInt(sc.next());
        }
      
      	for (int i = 0; i < n; i++) {
          int ansTmp = 1000000000;
          int ans = 0;
        	 for (int j = 0; j < m; j++) {
                int x = Math.abs(studentC[i][0] - checkpointC[j][0]);     
                int y = Math.abs(studentC[i][1] - checkpointC[j][1]);
               	if (ansTmp > x + y) {
                  ans = j + 1;
                  ansTmp = x + y;
                }
             }
          System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	private void execute() {

		String initString = getParameter();

		int count = 0;
		int index = 0;

		for (; index < initString.length(); index++) {
			if ('1' == (initString.charAt(index))) {
				count++;
			}
		}

		outputAnswer(String.valueOf(count));
	}

	private String getParameter() {

		Scanner scan = new Scanner(System.in);

		String ret = scan.next();

		scan.close();

		return ret;
	}

	private void outputAnswer(String answer) {
		System.out.println(answer);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x; cin >> n >> x;
    vector<ll> l(n), d(n + 1);
    d[0] = 0;
    ll res = 1;
    rep(i, n) cin >> l[i];
    rep(i, n + 1){
        if(i == 0) continue;
        d[i] = d[i - 1] + l[i - 1];
        if(d[i] <= x) res++;
    }
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
    //string ;
    int a[10000];
    int n,k,i,j,l=0;
    cin>>k>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        l+=a[i];
    }
    if(l==k)
        cout<<"0"<<endl;
    else if(l>k)
        cout<<"-1"<<endl;
    else
        cout<<k-l<<endl;

    return 0;
}




Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <malloc.h>

#define MAX 9999
#define FIELD 4

int Pow(int n, int m);
int Max(int N[], int n);
int Min(int N[], int n);
int Sum(int N[], int n);

void Clear(int N[], int k, int n);




int main()
{
	int X = 0, Y = 0;
	scanf("%d%d", &X, &Y);
	printf("%d", X + Y / 2);




	return 0;
}

void Move(int* x, int* y, int d, int n) {

}

void Upper(int* x, int* y, int d) {
	*y += d;
}
void Lower(int* x, int* y, int d) {
	*y -= d;
}
void Right(int* x, int* y, int d) {
	*x += d;
}
void Left(int* x, int* y, int d) {
	*x -= d;
}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = N[0];

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Min(int N[], int n) {
	int min = N[0];

	for (int i = 0; i < n; i++) {
		min = min > N[i] ? N[i] : min;
	}

	return min;
}

int Sum(int N[], int n) {
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += N[i];
	}

	return sum;
}

void Clear(int N[], int k, int n) {
	for (int i = 0; i < n; i++) {
		N[i] = k;
	}
}

Measured memory_bytes: 128
package main

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

var scanner *bufio.Scanner

func printIt() {
	for {
		h := nextInt()
		w := nextInt()
		if h == 0 && w == 0 {
			break
		}
		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				if i == 0 || i == h-1 || j == 0 || j == w-1 {
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}
			}
			fmt.Println()
		}
		fmt.Println()
	}

}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}


func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



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

void solve() {
	int n; cin >> n;
	vector<int> cnt(1111111, 0);
	int cur;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cur = a;
		cnt[a]++;
	}
	for (int i = 0; i < cnt.size(); i++)if (cnt[i] > 0)cur = __gcd(cur, i);
	if (cur > 1) {cout << "not coprime"; return ;}
	for (int i = 2; i <= 1e6; i++) {
		int thai = 0;
		for (int j = i; j <= 1e6; j += i) {
			if (cnt[j] > 0)thai++;
		}
		if (thai > 1) {cout << "setwise coprime"; return ;}
	}
	cout << "pairwise coprime"; return;


}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
#include <math.h>
double log10(double x);
int main() {
  int n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1LL;
 /* for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }*/
  for (int i = 0; i < n; i++) {
    //if (log10(a[i]) + log10(ans) > 18) {
    if (a[i] > 1000000000000000000LL / ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  
  if (ans > 1000000000000000000LL /*|| ans < 0LL*/) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  } 
  
} 
  



Measured memory_bytes: 4412
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define f first
#define s second
#define rep(i,x) for(int i=0;i<x;i++)
int in[5005]={};
vector<int>edge[5005];
int ran[5005];
bool ano=false;
int main()
{
	srand((unsigned int)time(NULL));
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		in[y]++;
		edge[x].pb(y);
	}
	queue<int>que;
	for(int i=1;i<=n;i++)
	{
		if(!in[i]) que.push(i);
	}
	if(que.size()>1)  ano=true;
	int s=1;
	while(!que.empty())
	{
		int x=que.front(),cnt=0; que.pop();
		ran[s++]=x;
		for(int i=0;i<edge[x].size();i++)
		{
			in[edge[x][i]]--;
			if(!in[edge[x][i]])
			{
				que.push(edge[x][i]); cnt++;
			}
		}
		if(cnt>1)  ano=true;
	}
	for(int i=1;i<=n;i++) printf("%d\n",ran[i]);
	cout << ano << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split();
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);
        Console.WriteLine(Math.Max(0, n - 2 * m));
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair< ll, vector<ll> > state;

int main(void) {
  ll N;
  while(cin >> N, N) {
    vector<ll> schedule(N, 0);
    REP(i, 0, N) REP(j, 0, 16) {
      ll d;
      cin >> d;
      schedule[i] = schedule[i] | (d << (15 - j));
    }

    set<state> st;
    st.insert(state(5, vector<ll>({ 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff })));

    ll ans = 0;

    REP(i, 0, N) {
      set<state> nst;

      for(state s : st) {
        ll p = s.first;
        vector<ll> past = s.second;

        ll rain[16] = {
          0x3300, 0x6600, 0xcc00, 0x0000,
          0x0330, 0x0660, 0x0cc0, 0x0000,
          0x0033, 0x0066, 0x00cc, 0x0000,
          0x0000, 0x0000, 0x0000, 0x0000
        };
        ll r = rain[p];

        ll u = schedule[i] & r;
        ll t = r;
        REP(j, 0, 6) t = t | past[j];

        if(u == 0 && t == 0xffff) {
          if(i + 1 == N) ans = 1;

          vector<ll> current(6);
          current[0] = r;
          REP(j, 0, 5) current[j + 1] = past[j];

          ll y = p / 4, x = p % 4;
          REP(dy, -2, 3) REP(dx, -2, 3) if(dy == 0 || dx == 0) {
            ll ny = y + dy, nx = x + dx;
            if(0 <= ny && ny < 3 && 0 <= nx && nx < 3) {
              ll np = ny * 4 + nx;
              nst.insert(state(np, current));
            }
          }
        }
      }

      swap(st, nst);
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 6796
N,M = (int(x) for x in input().split())
a = [0]*N  
k = []
ans = 0
for i in range(M):
  k = [int(x) for x in input().split()]
  for j in range(k[0]): #kよりつながっている電球を一個ずつ見てる
    s = k[j+1]-1
#    print(i,j,s,a[s],a)
    a[s] = a[s] | (1<<i) #aは各スイッチがつながっている電球の情報を保持
#   左端はMとつながっているかどうかを表す。
    #a[0]＝10100はスイッチ０が電球4と電球2とつながっていることを表している。
p = [int(x) for x in input().split()]
P = 0
for i in range(M):
  P |= p[i] << i
#Pはpの情報を全て持っている二進数。例えば、P＝10011は電球４、１、０が
# on になっているスイッチの個数を2で割った余りが１の時点灯するを表す
#左端がMは統一されている

#1<<N は2**nと同じ
for s in range(1<<N):
  t = 0
  for i in range(N):
    if ((s>>i) & 1):#スイッチオンだったら
      t ^= a[i]		
      #これはXORを使って、スイッチがonになっているスイッチの個数を２で割ったあまりを表している
  if (t == P):	#もし、t＝＝Pなら、当てはまっているので、ans++する。
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    ll x;
    cin >> x;
    ll ans = 1;
    FOR(i,2,x){
        ll roop = 2;
        while(1){
            if(x >= pow(i,roop)){
                ans = max(ans,(ll)pow(i,roop));
            }else{break;}
            roop++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
# ABC053 D - Card Eater
from collections import defaultdict
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
a=nl()
cnt=0

d=defaultdict(int)
for aa in a:
    d[aa]+=1

for dd in d.items():
    if dd[1]%2==0:
        cnt+=1

if cnt%2==0:
    print(len(set(a)))
else:
    print(len(set(a))-1)

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,a,b,c=0;
  cin>>n;
  vector<P> p(n);
  for(int i=0;i<n;i++){
    cin>>a>>b;
    p[i]=P(b,a);
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    c+=p[i].second;
    if(c>p[i].first){
      cout<<"No";return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 3328
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

long long N;
long long M;
long long Q;
std::vector<long long> a;
std::vector<long long> b;
std::vector<long long> c;
std::vector<long long> d;
vector<ll> A;
ll ans = 0;
void dfs(int x)
{
  if (A.size() == N)
  {
    ll sum = 0;
    for (int i = 0; i < Q; ++i)
    {
      if (A[b[i]] - A[a[i]] == c[i])
        sum += d[i];
    }
    ans = max(sum, ans);
    return;
  }
  for (int i = x; i <= M; ++i)
  {
    A.push_back(i);
    dfs(i);
    A.pop_back();
  }
  return;
}

int main()
{
  scanf("%lld", &N);
  scanf("%lld", &M);
  scanf("%lld", &Q);
  a.assign(Q, 0);
  b.assign(Q, 0);
  c.assign(Q, 0);
  d.assign(Q, 0);
  for (int i = 0; i < Q; i++)
  {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
    scanf("%lld", &d[i]);
    a[i]--;
    b[i]--;
  }
  dfs(1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3244
#!/usr/bin/env python
# coding: utf-8
"""
purpose
"""


def main() -> None:
    """
    main function
    """
    (A, B, C, X, Y) = map(int, input().split())

    if 2 * C <= A + B:
        ans = C * min(X, Y) * 2 + min(max((X-Y)*A, (Y-X)*B), max(X-Y, Y-X)*C*2)
    else:
        ans = A * X + B * Y

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

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

  rep(i, n)
  {
    int a;
    cin >> a;
    map[a] = i+1;
  }

  for (int i = 1; i < n+1; i++){
    cout << map[i] << endl;
  }
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	vector<int>a(n), b(3);
	rep(i, n) {
		cin >> a[i];
		int res = 0;
		int res2 = a[i];
		while (res2 % 2 == 0) {
			res++;
			res2 /= 2;
		}
		if (res >= 2)b[2]++;
		else b[res]++;
	}
	if (b[1] == 0) {
		if (b[2] + 1 >= b[0])puts("Yes");
		else puts("No");
	}
	else {
		if (b[2] >= b[0])puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int r;
  cin>>r;
  cout<<r*r<<endl;
}

Measured memory_bytes: 3592
#include<stdio.h>

int search(int A[],int n,int key){
int i=0;
A[n]=key;
while(A[i]!=key)i++;
return i!=n;
}
int main(){
int i,n,A[10000+1],q,key,sum=0;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);
scanf("%d",&q);
for(i=0;i<q;i++){
scanf("%d",&key);
if(search(A,n,key))sum++;
}
printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include <type_traits>
using namespace std;
#define rep(i,a,n) for(i=a;i<=n;i++)
#define ll long long
#define test(a) cout << "*" << a << endl
int main(){
  ll i;
  ll N,X;
  ll x[100001];
  ll dl[100001];
  ll dlMin = 1000000000;
  ll gcd;
  
  cin >> N >> X;
  rep(i,1,N){  
    cin >> x[i];
    dl[i] = abs(x[i]-X);
    dlMin = min(dlMin,dl[i]);    
  }
  if(N==1)
    gcd = dl[1];
  else{
    gcd = __gcd(dl[1],dl[2]);  
    for(i=3;i<N;i++){
      gcd = __gcd(gcd,dl[i]);
    }
  }
  cout << gcd << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int a, b, c;

int main() {

	cin >> a >> b >> c;

	if (a + b + c >= 22)cout << "bust" << endl;
	else cout << "win" << endl;

	return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
	string a;
	cin >> a;
	int n = a.size()-1;
	int x = stoll(a);
	int ans=0,b=x;
	while(x >= 10){
		b = x/10;
		ans += x%10;
		x /= 10;
	}
	ans += b;
	b--;
	b = n*9+b;
	ans=max(b,ans);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#define ll long long

using namespace std;

const int N = 55;
const int M = 3000;
int n,m;
int dep[N];
int fa[N];
vector<int> adj[N];
ll record[N];

ll ppow(ll a,ll b){
	ll res = 1;
	while(b){
		if(b&1) res *= a;
		a = a * a;
		b >>= 1;
	}
	return res;
}

void dfs(int u,int pre){
	fa[u] = pre;
	dep[u] = dep[pre]+1;
	for(int i = 0;i < adj[u].size();i++){
		int v = adj[u][i];
		if(v == pre) continue;
		dfs(v,u);
	}
}

int main(){
	//freopen("in","r",stdin);
	scanf("%d",&n);
	for(int i = 1;i < n;i++){ int u,v;scanf("%d%d",&u,&v);adj[u].push_back(v);adj[v].push_back(u);}
	dfs(1,0);
	scanf("%d",&m);
	for(int i = 0;i < m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(dep[u]<dep[v]) swap(u,v);
		while(dep[u]>dep[v]) {record[i] |= (1ll<<u>>1),u = fa[u];}
		while(u != v) {record[i] |= (1ll<<u>>1)|(1ll<<v>>1),u = fa[u],v = fa[v];}
		//record[i] |= (1<<u);
	}	

	ll res = 0;
	for(ll i = 0;i < (1ll<<m);i++){
		ll r = 0;
		int cnt1=0,cnt2=0;
		for(int j = 0;j < m;j++){
			if((i>>j)&1){
				r |= record[j];
				cnt1++;
			}
		}
		for(int j = 0;j < n;j++) if((r>>j)&1) cnt2++;
//		int cnt1 = __builtin_popcount(i);
//		int cnt2 = __builtin_popcount(r);
		res += ((cnt1&1)? -1 : 1) * (1ll << (n-1-cnt2));
	}
	printf("%lld\n", res);
	return 0;
}


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

int N, A[300000];

bool check(int K){
    int d = 0;
    while(pow((double)K, d+1) <= 8e18) d++;

    vector<int64_t> pows = {1};
    for(int i=1; i<=d; i++) pows.push_back(pows[i-1] * K);

    int64_t num = 0, num2 = 0;
    for(int i=0; i<N-1; i++){
        if(A[i] >= A[i+1]){
            if(A[i+1] > 2*d){
                continue;
            }else if(A[i+1] > d){
                int d2 = 2*d - A[i+1];
                num2 /= pows[d2];
                num2++;
                num2 *= pows[d2];
                if(num2 >= pows[d]){
                    num++;
                    num2 = 0;
                }
            }else{
                num /= pows[d-A[i+1]];
                num++;
                num *= pows[d-A[i+1]];
            }
            if(num >= pows[d]) return false;
        }
    }
    return true;
}

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

    bool incr = true;
    for(int i=0; i<N-1; i++) if(A[i] >= A[i+1]) incr = false;
    if(incr){
        cout << 1 << endl;
        return 0;
    }

    int ng = 1, ok = N;
    while(ok-ng>1){
        int mid = (ng+ok)/2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 1408
n, a, b = gets.chomp.split(" ").map(&:to_i)

a_b = (a + b)
if a_b == 0
    puts 0
    exit
end
ans = (n / a_b).to_i * a # + (n % a_b)
q = n % a_b
ans += q < a ? q : a

puts ans


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

pair<pair<string, int>, int> p[110]; //((string,int),int)のペアが格納された配列p。最大110要素
int main()
{
  int a; //int型のaは、紹介するレストランの数
  scanf("%d", &a); //変数aにint型を入力
  for (int i = 0; i < a; i++) //レストランの数だけループ
  {
    int t; char in[120]; //最大120要素あるchar型配列in
    scanf("%s%d", in, &t); //文字列の場合&を付けない。点数をtに格納。
    p[i] = make_pair(make_pair(in, -t), i); //配列pのi番目に、((in, -t), i)ペアを格納。-tは、昇順（小さい順）に対応するため。
  }
  std::sort(p, p + a); //配列の昇順の書き方。vectorでいう、sort(v.begin(), v.end());
  for (int i = 0; i < a; i++)
    printf("%d\n", p[i].second + 1); //ペアの配列内要素のiに1を加算して出力
}

Measured memory_bytes: 256
N,K = [int(it) for it in input().split() ]
li = [ int(it) for it in input().split() ]

sm = 10000000000000000
for i in range(N-K+1):
  #li[i+K-1]-li[i]
  a,b = li[i],li[i+K-1]
  if ( b<=0 ):
    sm = min (sm,-a)
  if ( a <= 0 and 0 <= b ):
    sm = min ( sm , b - 2*a )
    sm = min ( sm , 2*b - a )
  if ( a >= 0 ):
    sm = min ( sm , b)
print ( sm )
    

Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<cstdio>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<vector<Int>> F(N, vector<Int>(10, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 10; j++) {
			cin >> F[i][j];
			//scanf_s("%d", &F[i][j]);
		}
	}

	vector<vector<Int>> P(N, vector<Int>(11, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 11; j++) {
			cin >> P[i][j];
		}
	}

	Int ans = -INF;
	Int temp;
	Int count;
	for (Int bit = 1; bit < (1LL<<10); bit++) {
		temp = 0;
		for (Int i = 0; i < N; i++) {
			count = 0;
			for (Int j = 0; j < 10; j++) {
				if ((bit >> j & 1) && F[i][j]) {
					count++;
				}
			}
			temp += P[i][count];
		}
		ans = max(ans, temp);
	}

	cout << ans << endl;
}

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

typedef long long ll;
typedef vector<int> vi;

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

int main(){
    int n;
    cin >> n;
    vi v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    double ans = v[0];
    for(int i = 1; i < n; i++){
        ans += (ans + v[i])/2 - ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
S = int(input())
li = list(map(int,input().split()))
a = 0
for i in range(S):
    if li[i] % 2 == 0 and li[i] % 3 != 0 and li[i] % 5 != 0:
        print("DENIED")
        a += 1
        break
if a == 0:
    print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int n;
int x[25], y[25], r[25], c[25];
bool board[25][25];
bool memo[1<<24];

void dfs(int S) {
    if(memo[S]) return;
    vector<int> candidate;
    rep(i,0,n) {
        if(!(S >> i & 1)) continue;
        bool ok = true;        
        rep(j,0,i) {
            if(!(S >> j & 1)) continue;
            if(board[j][i]) ok = false;
        }
        if(ok) candidate.push_back(i);
    }

    int m = candidate.size();
    rep(i,0,m) {
        rep(j,i+1,m) {
            int x = candidate[i], y = candidate[j];
            if(c[x] == c[y]) {
                int nbit = S ^ (1 << x) ^ (1 << y);
                dfs(nbit);
                memo[nbit] = true;
            }
        }
    }
}

ll dist(ll x1, ll y1, ll x2, ll y2) {
    ll d1 = (x1-x2) * (x1-x2);
    ll d2 = (y1-y2) * (y1-y2);
    return d1 + d2;
}

bool in(ll x1, ll y1, ll r1, ll x2, ll y2, ll r2) {
    double d1 = dist(x1, y1, x2, y2);
    double d2 = (r1+r2) * (r1+r2);
    return d1 < d2;
}

signed main() {
    while(cin >> n, n) {
        memset(board, false, sizeof(board));
        memset(memo, false, sizeof(memo));
        rep(i,0,n) {
            cin >> x[i] >> y[i] >> r[i] >> c[i];
        }
        rep(i,0,n) rep(j,0,i) {
            if(in(x[i], y[i], r[i], x[j], y[j], r[j])) board[j][i] = true;
        }
        dfs((1<<n)-1);
        int ans = 0;
        rep(i,0,1<<n) {
            if(memo[i]) {
                // printf("true: i = %lld\n", i);
                ans = max(ans, n - __builtin_popcount(i));
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 19460
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    double a,b;
    cin>>a>>b;
    cout<<a/b<<endl;
}

Measured memory_bytes: 256
use proconio::*;

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
        mut k: i32,
    }

    let mut ans = a.min(k);
    k -= a.min(k);
    k -= b.min(k);
    ans -= c.min(k);
    println!("{}", ans);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
#define setbit(s, i) (s|=(1LL<<(i)))
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "E"
string s;
int cnt[26];
deque <int> d[26];
int ft[200001];
int n;
void update(int u, int x){
    for(; u<=n; u+=u&-u) ft[u]+=x;
}
int get(int u){
    int res=0;
    for(; u>0; u-=u&-u) res+=ft[u];
    return res;
}
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>s;
    for(char &c: s) c-='a';
    for(char c: s) cnt[c]++;
    int oddc=0;
    FFOR(i, 0, 26) oddc+=cnt[i]%2;
    if(oddc>1){
        write(-1);
        return 0;
    }
    n=s.size();
    s='0'+s;
    ll ans=0;
    FFOR(i, 1, s.size()) d[s[i]].pb(i);
    FOR(l, 1, n/2){
        int r=n-l+1;
        int best=0, res=n*2;
        int nl, nr;
        FFOR(j, 0, 26){
            if(d[j].size()<=1) continue;
            nl=d[j].front()+get(d[j].front());
            nr=d[j].back()+get(d[j].back());
            if(res>abs(nl-l)+abs(nr-r)){
                res=abs(nl-l)+abs(nr-r);
                best=j;
            }
        }
        ans+=res;
        update(1, 1);
        update(d[best].front(), -1);
        update(d[best].back(), -1);
        d[best].pop_front();
        d[best].pop_back();
    }
    if(oddc){
        FFOR(i, 0, 26) if(cnt[i]%2){
            int nl=d[i].front()+get(d[i].front());
            ans+=abs((n/2+1)-nl);
            break;
        }
    }
    write(ans);
}

Measured memory_bytes: 2112
import sys
# import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def solve():
	n = int(inp())
	dic = read()
	for _ in range(n-1):
		arr = read()
		for i in range(3):
			# print(i, [dic[j] for j in range(3) if i != j])
			arr[i] += max([dic[j] for j in range(3) if i != j])
		dic = arr
		# print(dic, "*")
			# m = dic[]
			# for j in range(3):
			# 	if i != j:
			# print([dic[j]+arr[i] for j in range(3) if i!=j])
			# dic[i] = max([dic[j]+arr[i] for j in range(3) if i!=j])
			# print(dic, "****")
	print(max(dic))



if __name__ == "__main__":
	solve()

Measured memory_bytes: 33640
#include <iostream>
#include <set>
#include <cmath>

using namespace std;
using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;

  set<ll> st;
  for (ll i = 1; i <= sqrt(m); ++i) {
    if (m / i * i != m)
      continue;
    st.insert(i);
    st.insert(m/i);
  }

  ll ans = 1;
  for (auto &v : st)
    if (v * n <= m)
      ans = max(ans, v);

  cout << ans << endl;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    int x;
    cin>>x;
    cout<<1-x<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int h, w;
    cin >> h >> w;
    int k; 
    cin >> k;
    vs s(h);
    rep(i, h) {
        cin >> s[i];
    }

    int uu = 1;
    vvi ss(h, vi(w));
    int aa = 0;
    rep(i, h) {
        int cou = 0;
        rep(j, w) {
            if(s[i][j] == '#') {
                if(cou) {
                    uu++;
                } else {
                    aa++;
                    cou++;
                }
            }
            ss[i][j] = uu;
        }
        if(!aa) continue;
        if(!cou && i) {
            rep(j, w) {
                ss[i][j] = ss[i-1][j];
            }
            uu--;
        }
        if(aa == 1) {
            rep(k, i) {
                rep(j, w) {
                    ss[k][j] = ss[i][j];
                }
            }
            aa = -INF;
        }


        uu++;
    }

    rep(i, h) {
        rep(j, w) {
            cout << ss[i][j] << (j == w-1 ? '\n':' ');
        }
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL a[4];
int main(){
    for(int i = 0;i < 4; ++i){
        scanf("%lld",&a[i]);
    }
        a[1] = min(a[1],2*a[0]);
        a[2] = min(a[2],2*a[1]);
        a[3] = min(a[3],2*a[2]);
    LL y;
    scanf("%lld",&y);
    y *= 4;
    LL ans = 0;
    ans += y / 8 * a[3];
    y %= 8;
    ans += y / 4 * a[2];
    y %= 4;
    ans += y / 2 * a[1];
    y %= 2;
    ans += y * a[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define ll long long
using namespace std;
signed main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 1)cout << b-a << endl;
	else cout << a-b << endl;
	getchar(); getchar(); return 0;
}


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

struct UnionFind{
	vector<int> rnk,par,num;
	UnionFind(int N) : rnk(N),par(N),num(N){
		init();
	}
	void init(){
		for(int i = 0;i < rnk.size();i++){
			rnk[i] = 0;
			par[i] = i;
			num[i] = 1;
		}
	}
	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x,int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rnk[x] < rnk[y]){
			par[x] = y;
			num[y] += num[x];
		}
		else{
			par[y] = x;
			num[x] += num[y];
			if(rnk[x] == rnk[y]) rnk[x]++;
		}
	}
	bool same(int x,int y){
		return (find(x) == find(y));
	}
	int size(int x){
		return num[find(x)];
	}
};

signed main(){
  int n, m; scanf("%d%d", &n, &m);
  vector<vector<int> > data(m);
  for(int i = 0; i < n; i++){
    int k; scanf("%d", &k);
    for(int j = 0; j < k; j++){
      int l; scanf("%d", &l);
      data[l - 1].push_back(i);
    }
  }
  UnionFind tree(n);
  for(int i = 0; i < m; i++){
    for(int j = 1; j < data[i].size(); j++){
      tree.unite(data[i][j - 1], data[i][j]);
    }
  }
  if(tree.size(0) == n) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 4608
S=list(input())
T=list(input())
if S[0]==T[0] and S[1]==T[1] and S[2]==T[2]:
  print(3)
elif S[0]==T[0] and S[1]!=T[1] and S[2]!=T[2]:
  print(1)
elif S[0]!=T[0] and S[1]==T[1] and S[2]!=T[2]:
  print(1)
elif S[0]!=T[0] and S[1]!=T[1] and S[2]==T[2]:
  print(1)
elif S[0]!=T[0] and S[1]!=T[1] and S[2]!=T[2]:
  print(0)
else:
  print(2)


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int r, d, x;
	cin >> r >> d >> x;
	int a = x;
	rep(i, 10) {
		cout << r * a - d << endl;
		a = r * a - d;
	}

	return 0;
}


Measured memory_bytes: 256
open Batteries
open BatPervasives
open Printf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> BatString.split_on_char ' '
  |> List.map cnv

let rec zip xs = function
  | [] -> []
  | y::ys ->
    match xs with
    | [] -> []
    | z::zs -> (z, y)::zip zs ys

let (n, k) = scan "%d %d" BatTuple.Tuple2.make
let ps = scan_list float_of_string

let exp n = n *. (n +. 1.0) /. 2.0 /. n

let hold_max (m, p) (x, y) =
  let n = p -. x +. y in
  ((if m > n then m else n), n)

let () =
  let sums = List.map exp ps in
  let init = BatList.fsum @@ BatList.take k sums in
  BatList.fold_left hold_max (init, init) (zip sums @@ BatList.drop k sums)
  |> BatTuple.Tuple2.first
  |> printf "%f\n"


Measured memory_bytes: 36096
#include <iostream>
using namespace std;
int main(void){

    int n,q;
    cin>>n;
    int a[300020];
    for(int i=0;i<n-1;++i)cin>>a[i];
    int b[300020];
    for(int i=0;i<n-1;++i){
        q=a[i]-1;
        b[q]++;
    }

    for(int i=0;i<n;++i)cout<<b[i] <<endl ;
}


Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='o') ans+=100;
    }
    ans+=700;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n;

int main() {
	cin >> n;
	double ans = 0;
	inc(i, n) {
		double x;
		string s;
		cin >> x >> s;
		if(s[0] == 'J') { ans += x; } else { ans += x * 380000; }
	}
	
	printf("%.9f\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
module Main where

import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.String
import Data.List
import Data.Maybe
import Control.Monad

main :: IO ()
main = do
  [n, d] <- map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  xn <- replicateM n (map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine)
  print . length . filter (==True) $ map (solve d) xn

solve :: Int -> [Int] -> Bool
solve d [p, q] =
  dist <= d
  where
    dist = ceiling . sqrt . fromIntegral $ (p ^ 2) + (q ^ 2)


Measured memory_bytes: 56240