akhauriyash/Code-Regression huggingface dataset:
from collections import deque


def main():
    height, width = map(int, input().split())
    grid = []
    q = deque([])
    change_time = [[float("inf") for _ in range(width)] for _ in range(height)]
    for i in range(height):
        now = list(input())
        for j in range(width):
            if now[j] == "#":
                q.append([i, j, 0])
                change_time[i][j] = 0
        grid.append(now)
    d = [[0, 1], [1, 0], [0, -1], [-1, 0]]
    answer = 0
    while q:
        y, x, time = q.popleft()
        for dy, dx in d:
            new_y = y + dy
            new_x = x + dx
            if 0 <= new_y < height and 0 <= new_x < width and grid[new_y][new_x] == ".":
                grid[new_y][new_x] = "#"
                change_time[new_y][new_x] = change_time[y][x] + 1
                q.append([new_y, new_x, change_time[new_y][new_x]])
                answer = max(answer, change_time[new_y][new_x])
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 174216
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-7
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<int, pair<int, int>> tup;

inline void solve()
{
	int n, k;
	cin >> n >> k;
	vector<double> v(n);
	fore(i, 0, n)
	{
		int a;
		cin >> a;
		v[i] = (a * (a + 1)) / 2 * (1.0 / a);
	}
	double o = 0, otv;
	fore(i, 0, k)
		o += v[i];
	otv = o;

	fore(i, k, n)
	{
		o += v[i] - v[i - k];
		otv = max(otv, o);
	}

	cout << fixed << setprecision(10) << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 13;
int n, deg[maxN], ans;
bool path[maxN];
vector<int> adj[maxN];
void dfs (int x, int p) {
    if (deg[x] == 1)
	path[x] = 1;
    
    for (auto a : adj[x]) {
	if (a != p) {
	    dfs(a, x);
	    if (path[a] && deg[x] == 2)
		path[x] = 1;
	}
    }
}

void solve (int x, int p) {
    bool fl = 0;
    if (deg[x] == 1)
	ans++;
    for (auto a : adj[x]) {
	if (a != p) {
	    if (path[a] && !fl && !path[x])
		fl = 1;
	    else
		solve(a, x);
	}
    }
}

int main () {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
	int a, b;
	cin >> a >> b;
	adj[a].push_back(b);
	adj[b].push_back(a);
	deg[a]++;
	deg[b]++;
    }
    int st = n + 13;
    for (int i = 0; i < n; i++) {
	if (deg[i] > 2) {
	    st = i;
	    dfs(i, i);
	    break;
	}
    }
    if (st == n + 13)
	return cout << 1 << endl, 0;
    solve(st, st);
    cout << ans << endl;
}


Measured memory_bytes: 9600
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		ArrayList<Integer> result = new ArrayList<Integer>();
		Scanner insert = new Scanner(System.in);
		int n = -1;
		int m = -1;
		while(true) {
			if((n==0) && (m==0)) {
				break;
			}
			String line = insert.nextLine();
			String array1[] = line.split(" ");
			n = Integer.parseInt(array1[0]);
			m = Integer.parseInt(array1[1]);
			int[] min = new int[n];
			int[] max = new int[n];
			int sum = 0;
			for(int i =0; i < m; i++) {
				String line2 = insert.nextLine();
				String array2[] = line2.split(" ");
				int s = Integer.parseInt(array2[0]);
				int ninzu = Integer.parseInt(array2[1]);
				sum+= s;
				if(ninzu == 1) {
					min[Integer.parseInt(array2[2]) - 1] +=s;
					max[Integer.parseInt(array2[2]) - 1] +=s;
				}
				else {
					for(int j = 0; j < ninzu; j++) {
						max[Integer.parseInt(array2[j+2]) - 1] +=s;
					}
				}
			}
			int minN =sum;
			int maxN = 0;
			int index = -1;
			for(int i =0;i < n; i++) {

				if(maxN < max[i]) {
					maxN = max[i];
					index = i;
				}
			}
			for(int i =0;i < n; i++) {

				if((i != index) && (minN > min[i])) {
					minN = min[i];
				}
			}
			result.add(maxN - minN +1);
		}
		for(int i = 0;i < (result.size() - 1);i++) {
			System.out.println(result.get(i));
		}

	}

}



Measured memory_bytes: 203436
#include <iostream>

using namespace std;

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

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

    int sum = 0;

    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    cout << sum;
}

Measured memory_bytes: 3616
from math import factorial
N = int(input())
K = int(input())
strN = str(N)
lenN = len(strN)
#dp[i][j][k] をi:今何桁目を調べているか、j:未満フラグ、k:何個0以外を出したか、としてdpしたい
dp = [[[0]*(K+1) for i in range(2)] for j in range(lenN+1)]
dp[0][0][0] = 1
for i in range(lenN):
    for j in range(2):
        for k in range(K+1):
            if j == 0:
                if k != K:
                    if strN[i] == "0":
                        dp[i+1][j][k] += dp[i][j][k]
                    else:
                        dp[i+1][j][k+1] +=  dp[i][j][k]
                        dp[i+1][1][k+1] +=  (int(strN[i])-1) * dp[i][j][k]
                        dp[i+1][1][k] += dp[i][j][k]
                else:
                    dp[i+1][j][k] += dp[i][j][k]
            if j == 1:
                if k != K:
                    dp[i+1][j][k+1] += 9*dp[i][j][k]
                    dp[i+1][j][k] += dp[i][j][k]
                else:
                    dp[i+1][j][k] += dp[i][j][k]
print(dp[lenN][0][K] + dp[lenN][1][K])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int kub[100];
int main()
{
    int n;
    cin >> n;
    string slo;
    cin >> slo;
    int zle=0;
    int mod=1000000007;
    long long wyn=0;
    for (int i=0; i<n; i++)
    {
        kub[slo[i]-'a']++;
        long long pompom=1;
        for (int j=0; j<='z'-'a'; j++)
        {
            if (j==slo[i]-'a')
                continue;
            pompom*=kub[j]+1;
            pompom%=mod;
        }
        wyn+=pompom;
        wyn%=mod;
    }
    cout << wyn;
}


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

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

    if(b == "A"){
        cout <<"T" << endl;
    } else {
        if(b == "T"){
            cout << "A" << endl;
        } else {
            if(b == "G"){
                cout << "C" << endl;
            } else {
                cout << "G" << endl;
            }
        }
    }
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int numb=b-a;
int temp=0;
for(int i=1;i<=numb-1;i++){
    temp+=i;
}
System.out.println(temp-a);
}
}

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

int n;
vector<ll> a(3010);
vector<vector<ll> > dp(3010, vector<ll>(3010, -1));

ll dodp(int l, int r){
	// cout<<"doing for "<<l<<" "<<r<<'\n';
	if(l==r)	return a[l];
	// if(l>r)		return 1e10;
	if(dp[l][r] != -1)	return dp[l][r];

	dp[l][r] = max(a[l] - dodp(l+1,r), a[r] - dodp(l,r-1));

	return dp[l][r];
}

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

	cin>>n;
	for(int i=0;i<n;++i)	cin>>a[i];

	cout<<dodp(0, n-1)<<'\n';

	// for(int l=0;l<n;++l){
	// 	for(int r=0;r<n;++r)	cout<<dp[l][r]<<" ";
	// 	cout<<"\n";
	// }

	return 0;
}

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

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    string ans;
    if (abs(a - b) <= d && abs(b - c) <= d)
    {
        ans = "Yes";
    }
    else if (abs(a - c) <= d)
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return (int(x) for x in input().split())
def LI(): return list(Is())
def TI(): return tuple(Is())
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(S())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
A = LI()
if 0 in A:
    print(0)
    exit()
    
ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

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

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

int main(){
	long double a,b,c;
    cin>>a>>b>>c;
    long double to = (c-a-b)/2;
    if(log10(a*b)<2*log10(to))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 512
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define rep(i,n) for(int i=0;i<n;i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){

  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  vector<int> B(N,0);
  REP(i,N){
    cin>>A[i];
  }
  REP(i,N){
    for(int j=-A[i];j<=A[i];j++){
      if(i+j>=0&&i+j<N){
      }
    }
  }


  for(int i=0;i<min(K,42);i++){
    for(int j=0;j<N;j++){
      int l=max(0,j-A[j]);
      int r=j+A[j];
      B[l]++;
      if(r+1<N){
        B[r+1]--;
      }
    }
    for(int j=0;j<N-1;j++){
      B[j+1]+=B[j];

    }
    for(int j=0;j<N;j++){
      A[j]=B[j];
      B[j]=0;
    }
  }
  REP(i,N){
    cout<<A[i]<<" ";
  }
}


Measured memory_bytes: 4840
//
//  main.cpp
//  hatsuharu
//
//  Created by 张轶剑 on 2017/1/14.
//  Copyright © 2017年 张轶剑. All rights reserved.
//  张爱玲

//#include <bits/stdc++.h>
#include <cstdio>
#include <queue>
#include <math.h>
#include <string>
#include <cstring>
#include <time.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <ctype.h>
#include <vector>
#include<functional>
#include <map>
using namespace std;
int main()
{
    int n,m,l,r;
    long long tt=0,a[500005],mn;
    scanf("%d%d",&n,&m);
    scanf("%d",&l);
    for (int i=1;i<=n-1;i++)
    {
        scanf("%d",&r);
        if(r>l)
        {
            tt+=r-l;
            a[l+2]+=1;
            a[r+1]-=r-l;
            a[r+2]+=r-l-1;
        }
        else
        {
            tt+=r-l+m;
            a[l+2]+=1;
            a[r+1+m]-=r-l+m;
            a[r+2+m]+=r-l+m-1;
        }
        l=r;
    }
    for (int i=1;i<=2*m;i++)
    {
        a[i]+=a[i-1];
    }
    for (int i=1;i<=2*m;i++)
    {
        a[i]+=a[i-1];
    }
    for (int i=1;i<=m;i++)
    {
        a[i]+=a[i+m];
        //printf("%d ",tt-a[i]);
        mn= a[i]>mn ? a[i]:mn ;
    }
    printf("%lld\n",tt-mn);
    
    return 0;
}

Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] inputString = br.readLine().split(" ");
            int yardA = Integer.parseInt(inputString[0]);
            int yardB = Integer.parseInt(inputString[1]);

            int squareYard = (yardA - 1) * (yardB - 1);
            System.out.println(squareYard);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 20564
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto r = RD;

	writeln(r*r);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<algorithm>

using namespace std;

int main() {
	double x;
	cin >> x;
	int year = 0;
	double sum = 100;
	while (sum < x) {
		sum = floor(sum * 1.01);
		++year;
	}
	cout << year << endl;
	return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;


#define int long long

struct Edge {
	int u, v;
	int cap, flow;

	Edge(int u_, int v_, int cap_, int flow_) : u(u_), v(v_), cap(cap_), flow(flow_){}
};

const int INF = 1e15 + 239;

namespace Flow {
	const int MAX_LOG = 40;

	int n;
	int start;
	int end;

	vector<int> d;
	vector<int> pnt;
	vector<Edge> ed;
	vector<vector<int>> g;

	void clear() {
		d.clear();
		pnt.clear();
		ed.clear();
		g.clear();
	}

	int dfs(int u, int flow) {
		if (flow == 0) {
			return 0;
		}
		if (u == end) {
			return flow;
		}
		for (; pnt[u] < (int)g[u].size(); pnt[u]++) {
			int ind = g[u][pnt[u]];
			int to = ed[ind].v;
			if (d[to] < d[u] + 1) {
				continue;
			}
			int pushed = dfs(to, min(flow, ed[ind].cap - ed[ind].flow));
			if (pushed > 0) {
				ed[ind].flow += pushed;
				ed[ind ^ 1].flow -= pushed;
				return pushed;
			}
		}
		return 0;
	}

	bool bfs(int lim) {
		for (int i = 0; i < n; i++) {
			d[i] = INF;
		}
		d[start] = 0;
		queue<int> q;
		q.push(start);
		while (!q.empty()) {
			int u = q.front();
			q.pop();
			for (auto ind : g[u]) {
				int to = ed[ind].v;
				if (d[to] > d[u] + 1 && ed[ind].flow + lim <= ed[ind].cap) {
					d[to] = d[u] + 1;
					q.push(to);
				}
			}
		}
		return d[end] < INF;
	}

	void init(int n_, int start_, int end_) {
		n = n_;
		start = start_;
		end = end_;
		d.resize(n);
		pnt.resize(n);
		g.resize(n);
	}

	void add_edge(int u, int v, int c) {
		int p = (int)ed.size();
		ed.push_back(Edge(u, v, c, 0));
		ed.push_back(Edge(v, u, 0, 0));
		g[u].push_back(p);
		g[v].push_back(p + 1);
	}

	int solve() {
		int ans = 0;
		for (int i = MAX_LOG; i >= 0; i--) {
			while (bfs(1LL << i)) {
				fill(pnt.begin(), pnt.end(), 0);
				while (true) {
					int nw = dfs(start, INF);
					if (nw > 0) {
						ans += nw;
					} else {
						break;
					}
				}
			}
		}
		return ans;
	}
}


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

	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	n++;
	int s = 0;
	for (auto t : a) {
		s += t;
	}
	int add = 0;
	Flow::init(n + 2, n, n + 1);
	for (int i = 0; i < n; i++) {
		if (a[i] >= 0) {
			Flow::add_edge(i, n + 1, a[i]);
		} else {
			add += a[i];
			Flow::add_edge(n, i, -a[i]);
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 2 * i; j < n; j += i) {
			Flow::add_edge(i, j, INF);
		}
	}
	int tadd = Flow::solve();
	add += tadd;
	cout << s - add << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
  int N;
  cin >> N;
  vector<int> time(N);
  rep(i,N) cin >> time[i];
  int M;
  cin >> M;
  rep(i,M){
    int res = 0;
    int a, b;
    cin >> a >> b;
    a--;
    rep(i,N){
      if(i == a ){
        res += b; 
        continue;
      }else{
        res += time[i];
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from math import gcd

N = int(input())
A = list(map(int, input().split()))

L = [0] * (N + 1)
R = [0] * (N + 1)
for i in range(N):
    L[i + 1] = gcd(L[i], A[i])
for i in range(N, 0, -1):
    R[i - 1] = gcd(R[i], A[i - 1])

ans = 0
for i in range(N):
    ans = max(ans, gcd(L[i], R[i + 1]))

print(ans)


Measured memory_bytes: 20828
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    double r;
    cin>>r;
    cout<< fixed<<setprecision(2)<<2*PI*r<<endl;
    return 0;
}


Measured memory_bytes: 3800
#include <stdio.h>
int main(void) 
{
	int cards[128][14] = {{0}};
	int i, N;
	scanf("%d", &N);
	for(i = 0; i < N; i++) {
    		char c; int cn;
    		scanf("%c", &c); 
    		scanf("%c %d", &c, &cn);
    		cards[c][cn] = 1;
	}

	for(i = 1; i <= 13; i++) {
    		if(cards['S'][i] == 0) {
    			printf("S %d\n", i);
    		}
	}
	
	for(i = 1; i <= 13; i++) {
    		if(cards['H'][i] == 0) {
    			printf("H %d\n", i);
    		}	
	}
	
	for(i = 1; i <= 13; i++) {
    		if(cards['C'][i] == 0) {
    			printf("C %d\n", i);
    		}
	}
	
	for(i = 1; i <= 13; i++) {
    		if(cards['D'][i] == 0) {
    			printf("D %d\n", i);
    		}
	}
	return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int count = 0;
  int N = S.size();
  rep(i,N)
  {
    if(S[i]=='x')
    {
      count ++;
    }
  }
  if(count>7)
  {
    cout << "NO" << endl;
  }
  else
  {
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  int temp[4];
  temp[0] = N / 1000;
  temp[1] = (N - temp[0] * 1000)/100;
  temp[2] = (N - temp[0] * 1000 - temp[1] * 100)/10;
  temp[3] = (N - temp[0] * 1000 - temp[1] * 100 - temp[2] * 10);
  if(temp[0] == temp[1] && temp[1] == temp[2]){
    cout << "Yes" << endl;
  }
  else if(temp[1] == temp[2] && temp[2] == temp[3]){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;  
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int a,b,c;

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

int main(void){
    ll n,x;
    while(1){
        cin>>n>>x;
        if(n==0&&x==0)break;
    ll c=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            for(int l=j+1;l<=n;l++){
                if(i+j+l==x)c++;
            }
        }
    }cout<<c<<endl;
    }
    
}



Measured memory_bytes: 3088
package main

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

func main() {
	s := getString()

	ans := ""
	for i := 0; i < len(s); i++ {
		c := string(s[i])
		if c == "B" {
			if len(ans) != 0 {
				ans = ans[0 : len(ans)-1]
			}
		} else {
			ans += c
		}
	}

	fmt.Println(ans)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

#define BUF_SIZE 10

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);
  int *arr = malloc(sizeof(int)*(num+1));

  int i;
  for(i = 1; i <= num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    sscanf(line, "%d", &arr[i]);
  }

  int light = 1;
  char checked[100001] = {0};
  int cnt = 0;
  while(1) {
    light = arr[light];
    cnt++;
    if(checked[light]) break;
    checked[light] = 1;
    if(light == 2) {
      printf("%d\n", cnt);
      return 0;
    }
  }
  printf("-1\n");

  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef unsigned long long LL;


int main() {

   int x, y, z;
   cin >> x >> y >> z;
   cout << z <<' ' << x << ' ' << y << endl;
  
    

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


"""
N^2なので素直に計算は無理，部分和を使いたいのでとりあえず累積和
[i+1:j]が条件を満たすとはS[j]-S[i]とj-iが合同．
移行して，S[j]-jとS[i]-iが合同
基本は個数だけ見れば良い

これだけだと，個数がKより大きい時にダメ
直近Kこの情報だけ持つ，今見てる数字が直近K個のものと何個組にできるか
"""
def main():

    mod=10**9+7
    N,K=MI()
    A=LI()
    from collections import defaultdict
    dd = defaultdict(int)
    
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=(S[i]+A[i])%K
        
    ans=0
    for i in range(min(K,N+1)):
        temp=(S[i]-i)%K
        ans+=dd[temp]
        dd[temp]+=1
        
    for i in range(K,N+1):
        temp=(S[i]-i)%K
        temp_m=(S[(i-K)]-(i-K))%K
        dd[temp_m]-=1
        ans+=dd[temp]
        dd[temp]+=1
        
    print(ans)
        
        
    

        

main()


Measured memory_bytes: 126668
# coding:utf-8

N = int(input())
statements = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split(' '))
        statements[i].append((x, y))

ans = 0
for i in range(2**N):
    assumption = [int(num) for num in bin(i)[2:].rjust(N, '0')]
    appropriate = True
    for j, p in enumerate(assumption):
        if p == 1:
            for s in statements[j]:
                if assumption[s[0] - 1] != s[1]:
                    appropriate = False
                    break
        else:
            continue

    if appropriate and ans < assumption.count(1):
        ans = assumption.count(1)

print(ans)

Measured memory_bytes: 3064
H, W = gets.chomp.split().map(&:to_i)
DP = Array.new(H){Array.new(W){Array.new(2){0}}}

w_col_idx = []
H.times do |h|
  gets.chomp.split('').each_with_index do |s, w|
    DP[h][w][1] = DP[h-1][w][1] if h > 0
    DP[h][w][0] = DP[h][w-1][0] if w > 0
    if s == '.'
      DP[h][w][1] += 1
      DP[h][w][0] += 1
    end
    if H == h + 1 && DP[h][w][1] == H
      w_col_idx << w
    end
  end
end

H.times do |h|
  next if DP[h][-1][0] == W
  s = ''
  W.times do |w|
    next if w_col_idx.include?(w)
    if w == 0 && DP[h][w][0] == 1
      s += '.'
    elsif DP[h][w-1][0] < DP[h][w][0]
      s += '.'
    else
      s += '#'
    end
  end
  puts s
end


Measured memory_bytes: 15168
program r20718h
 
implicit none
character(len=1) :: x, y
 
read *, x, y
 
if(ichar(x) == ichar(y)) then
 print *, '='
else if(ichar(x) > ichar(y)) then
 print *, '>'
else
 print *, '<'
end if
 
end program r20718h

Measured memory_bytes: 2764
#include <stdlib.h>
#include <stdio.h>

int D, G, p[10], c[10];

void solve();

int main() {
	int i;
	scanf("%d%d", &D, &G);
	for (i = 0; i < D; i++) scanf("%d%d", &p[i], &c[i]);
	solve();
	return 0;
}

void solve() {
	int i, j, k, max_score[12][1010], temp[110], cnt, t;
	for (i = 0; i < 12; i++)for (j = 0; j < 1010; j++)max_score[i][j] = 0;

	cnt = 0;
	for (j = 0; j < D; j++) {
		for (i = 0; i <= p[j]; i++) temp[i] = i * (j + 1) * 100;
		temp[p[j]] += c[j];

		for (i = 0; i <= cnt; i++) {
			for (k = 0; k <= p[j]; k++) {
				t = max_score[j][i] + temp[k];
				if (max_score[j + 1][i + k] < t) max_score[j + 1][i + k] = t;
			}
		}
		cnt += p[j];
	}

	for (i = 1; i <= cnt; i++) if (max_score[D][i] >= G) {
		printf("%d\n", i);
		break;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
enum TriangleType {
  ACUTE  = 0,
  RIGHT  = 1,
  OBTUSE = 2,
};
int main() {
   int tri[ 3 ];
   int tri_num[ 4 ] = { 0 };
   bool has_error = false;
   while( cin >> tri[ 0 ] ) {
     cin >> tri[ 1 ] >> tri[ 2 ];
     if( !has_error ) {
       sort( tri, tri + 3 );
       int absq = tri[ 0 ] * tri[ 0 ] + tri[ 1 ] * tri[ 1 ];
       int csq = tri[ 2 ] * tri[ 2 ];
       if( tri[ 0 ] + tri[ 1 ] <= tri[ 2 ] ) {
         has_error = true;
       } else if( absq > csq ) {
         tri_num[ ACUTE ]++;
       } else if( absq == csq ) {
         tri_num[ RIGHT ]++;
       } else {
         tri_num[ OBTUSE ]++;
       }
     }
   }
  
   cout
     << tri_num[ ACUTE ] + tri_num[ RIGHT ] + tri_num[ OBTUSE ] << ' '
     << tri_num[ RIGHT  ] << ' '
     << tri_num[ ACUTE  ] << ' '
     << tri_num[ OBTUSE ] << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int n;
const int maxn = 2e5 + 5;
int p[maxn];
int deg[maxn];
vector<int> G[maxn];
int sg[maxn];
bool vis[maxn];
bool cycle[maxn];

bool check(){
    memset(vis, 0, sizeof(vis));
    for(int i = 1;i <= n;i++){
        for(auto v : G[i]){
            if(sg[v] == sg[i])
                return false;
            vis[sg[v]] = true;
        }
        for(int j = 0;j < sg[i];j++){
            if(!vis[j])
                return false;
        }
        for(auto v : G[i]){
            vis[sg[v]] = false;
        }
    }
    return true;
}

bool solve(){
    int start = 0;
    for(int i = 1;i <= n;i++){
        if(cycle[i] == 0){
            start = i;
        }
    }
    memset(vis, 0, sizeof(vis));
    vector<int> candidate;
    for(auto v : G[start]){
        if(cycle[v]){
            vis[sg[v]] = true;
        }
    }
    for(int i = 0;i < maxn;i++){
        if(!vis[i]){
            candidate.push_back(i);
        } 
        if(candidate.size() == 2){
            break;
        }
    } 
    for(auto x : candidate){
        memset(vis, 0, sizeof(vis));
        sg[start] = x;
        int now = p[start];
        while(now != start){
            for(auto v : G[now]){
                vis[sg[v]] = true;
            }
            for(int i = 0;i < maxn;i++){
                if(!vis[i]){
                    sg[now] = i;
                    break;
                }
            }
            for(auto v : G[now]){
                vis[sg[v]] = false;
            }
            now = p[now];
        }
        if(check())
            return true;
    }
    return false;
} 

int main(){
    while(cin >> n){
        for(int i = 1;i <= n;i++){
            G[i].clear();
        }
        for(int i = 1;i <= n;i++){
            scanf("%d", &p[i]);
            deg[p[i]]++;
            G[p[i]].push_back(i);
        }
        queue<int> q;
        for(int i = 1;i <= n;i++){
            if(deg[i] == 0){
                q.push(i);
            }
        }
        memset(vis, 0, sizeof(vis));
        memset(cycle, 0, sizeof(cycle));
        while(!q.empty()){
            int Q = q.front();q.pop();
            deg[p[Q]]--;
            cycle[Q] = true;
            if(deg[p[Q]] == 0){
                q.push(p[Q]);
            }
            for(auto v : G[Q]){
                vis[sg[v]] = true;
            }
            for(int i = 0;i < maxn;i++){
                if(vis[i] == false){
                    sg[Q] = i;
                    break;
                }
            }
            for(auto v : G[Q]){
                vis[sg[v]] = false;
            }
        }
        if(solve()){
            cout << "POSSIBLE" << endl;
        }else{
            cout << "IMPOSSIBLE" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 13056
#include<stdio.h>

char* f(char* s){
	char* a=s;
	for(;*s;s++){
		char c = *s-'A';
		c = (c + 26 - 3) % 26;
		*s = c + 'A';
	}
	return a;
}

int main(){
	char s[1001];
	scanf("%s",s);
	printf("%s\n",f(s));
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;

int main()
{
    string a,b; cin>>a>>b; int x,y; cin>>x>>y; string c; cin>>c;
    if(c == a) x -= 1; else y -= 1;
    cout<<x<<' '<<y;
}

Measured memory_bytes: 256
import itertools
 
N, A, B, C = list(map(int, input().split()))
bars = [A,B,C]
l = [int(input()) for _ in range(N)]

INF = 10 ** 9    


def dfs(n, a, b, c):
    if n == N:
        return abs(a-A) + abs(b-B) + abs(c-C) -30 if min(a, b, c) > 0 else INF
    
    ret1 = dfs(n+1, a+l[n], b, c) + 10
    ret2 = dfs(n+1, a, b+l[n], c) + 10
    ret3 = dfs(n+1, a, b, c+l[n]) + 10
    ret4 = dfs(n+1, a, b, c)

    return min(ret1, ret2, ret3, ret4)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3192
#include<iostream>
using namespace std;
int a[105];
int main () {
    int n, m, mn = 10006;
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> a[i], mn = min(mn, a[i]), m -= a[i];
    cout << m / mn + n << endl;
    return 0;
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

n = int(input())

ans = 0
for i in range(1,n+1):
    if (i%3==0 and i%5==0):
        pass
    elif (i%3 == 0):
        pass
    elif (i%5 == 0):
        pass
    else:
        ans += i

print(ans)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int D;
vector<int> c(26); 
vector<vector<int>> s(365, vector<int>(26));

int cal_score(vector<int> t){
    int satis = 0;
    vector<int> last(26, 0);
    rep(d, D){
        satis += s[d][t[d] - 1];
        last[t[d] - 1] = d + 1;
        rep(i, 26){
            satis -= c[i] * (d - last[i] + 1);
        }
    }
    return satis;
}

int ch_sch(vector<int> t, int d, int q, int score){
    // change t[d - 1] -> q
    // calculate the score
    int old = t[d - 1];
    score -= s[d - 1][old - 1];
    score += s[d - 1][q - 1];

    int last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old ) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score += c[old - 1] * (i - last_old + 1);
        score += c[q - 1] * (i - last_new + 1);
    }

    t[d - 1] = q;

    last_old = 0, last_new = 0;
    rep(i, D){
        if(t[i] == old) last_old = i + 1;
        else if(t[i] == q) last_new = i + 1;
        score -= c[old - 1] * (i - last_old + 1);
        score -= c[q - 1] * (i - last_new + 1);
    }
    return score;
}

int main(){
    srand((unsigned)time(NULL));

    // input 
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D){
        rep(j, 26){
            cin >> s[i][j];
        }
    }

    // greedy
    vector<int> last(26, 0);
    vector<int> res(D);

    rep(d, D){
        int max_plus = -10000;
        int use = -1;
        rep(i, 26){
            int tmp = s[d][i] + c[i] * (d - last[i] + 1);
            if(max_plus < tmp){
                max_plus = tmp;
                use = i;
            }
        }
        last[use] = d + 1;
        res[d] = use + 1;
    }

    int cur_score = cal_score(res);
    //int ch_d = 1;
    //int cnt = 0;

    while((clock() / (double)CLOCKS_PER_SEC) <= 1.98){
        // cnt++;
        int ch_d = rand() % D + 1;
        int ch_c = rand() % 26 + 1;
        // int ifch = rand() % 100;
        int new_score = ch_sch(res, ch_d, ch_c, cur_score);
        if(cur_score + 200 < new_score){
            cur_score = new_score;
            res[ch_d - 1] = ch_c;
            // ch_d--;
            // if(ch_d == 0) ch_d = D;
        }
    }

    rep(i, D){
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, A, B, tot;
vector<int> E[maxn];
int dfs(int x, int fa)
{
	int ret = 0;
	for(auto v : E[x])
		if(v != fa)
			ret += dfs(v, x);
	if(fa) ret += (E[x].size() - 1) / 2;
	else ret += (E[x].size() + 1) / 2;
	return ret;
}
int color(int x, int fa)
{
	vector<int> a;
	for(auto v : E[x])
		if(v != fa)
		{
			int res = color(v, x);
			if(res == -1) return -1;
			else if(res == B) ++tot, res = 0;
			a.push_back(res + 1);
		}
	sort(a.begin(), a.end());
	if(!fa)
	{
		if(a.size() % 2 == 0)
		{
			for(int i = 0, j = a.size() - 1; i < j; ++i, --j)
				if(a[i] + a[j] > B)
					return -1;
			tot += a.size() / 2;
			return 0;
		}
		else
		{
			for(int i = 0, j = a.size() - 2; i < j; ++i, --j)
				if(a[i] + a[j] > B)
					return -1;
			tot += a.size() / 2 + 1;
			return a.back();
		}
	}
	else
	{
		if(a.size() % 2 == 0)
		{
			bool flag = 1;
			for(int i = 0, j = a.size() - 1; i < j; ++i, --j)
				if(a[i] + a[j] > B)
				{
					flag = 0;
					break;
				}
			if(flag) 
			{
				tot += a.size() / 2;
				return 0;
			}
			a.pop_back();
			++tot;
		}
		int ret = a[0];
		for(int i = 1, j = a.size() - 1; i < j; ++i, --j)
			if(a[i] + a[j] > B)
			{
				if(ret + a[j] <= B) ret = a[i];
				else
				{
					ret = a[j];                                                                                                  
					a.erase(a.begin() + j);
					for(int ii = 0, jj = a.size() - 1; ii < jj; ++ii, --jj)
						if(a[ii] + a[jj] > B)
							return -1;
					tot += a.size() / 2;
					return ret;
				}
			}
		tot += a.size() / 2;
		return ret;
	}
}
bool check()
{
	tot = 0;
	if(color(1, 0) == -1) return 0;
	return tot <= A;
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i < n; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	A = dfs(1, 0);
	int l = 1, r = n - 1;
	while(l <= r)
	{
		B = l + r >> 1;
		if(check()) r = B - 1;
		else l = B + 1;
	}
	cout << A << ' ' << l << endl;
	return 0;
}

Measured memory_bytes: 18272
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	int w, a, b;

	cin >> w >> a >> b;

	if (w + a < b) {
		if (a < b) {
			cout << b - (w + a) << endl;
		}
		else {
			cout << a - (b + w) << endl;
		}
	}
	else {
		if (a <= b) {
			cout << 0 << endl;
		}
		else {
			if (w + b < a) {
				cout << a - (w + b) << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}


	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n1,n2;
  char c;
 
  while(1){

    scanf("%d %c %d",&n1,&c,&n2);
    
    if(c == '+'){
      printf("%d\n", n1 + n2);
    }
    
    if(c == '-'){
      printf("%d\n", n1 - n2);
    }
    
    if(c == '*'){
      printf("%d\n", n1 * n2);
    }
    
    if(c == '/'){
      printf("%d\n", n1 / n2);
    }
    
    if(c == '?'){
      break;
    }
  }

  return 0;
}
  

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

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, n) for (int i = a; i < n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;

const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    ll n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int sp = n / 2;
    if (d[sp] == d[sp - 1])
    {
        cout << 0 << endl;
        return 0;
    }
    cout << d[sp] - d[sp - 1] << endl;
}


Measured memory_bytes: 768
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll n, m;
    cin >> n >> m;
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> X(m);
    for (auto & x : X) cin >> x;
    sort(X.begin(), X.end());
    auto sum = X[m-1] - X[0];
    vector<ll> D(m-1);
    for (ll i = 0; i < m - 1; ++i) {
        D[i] = X[i+1] - X[i];
    }
    sort(D.begin(), D.end(), greater<ll>());
    //for (auto & d : D) cerr << d << ",";
    //cerr << endl;
    for (ll i = 0; i < n - 1; ++i) {
        sum -= D[i];
    }
    cout << sum << endl;

}


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

using namespace std;

#define ll long long


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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());

    ll ans = 0;

    for (int i = 0; i < n - k; i++) {
        ans += a[i];
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
N = int(input())
l=len(str(N))
if l ==1:
    print(N)
elif l==2:
    print(9)
elif l ==3:
    print(9+N-99)
elif l ==4:
    print(9+900)
elif l ==5:
    print(9+999-99+N-9999)
elif N==100000:
    print(90909)
    

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
using ll = long long int;
using namespace std;
double pi = 3.141592653589793238;

#define FOR(i,N) for(int i=0;i<N;i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)



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

	int k[10] = { 0 };
	int s[10][10] = { 0 };
	int p[10] = { 0 };

	FOR(i, m) {
		cin >> k[i];
		FOR(j, k[i]) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	FOR(i, m) {
		cin >> p[i];
	}

	int cnt = 0;
	FOR(i, 1 << n) {
		bool flag = true;
		FOR(j, m) {
			int numofon = 0;
			FOR(l, k[j]) {
				if (i & 1 << s[j][l])numofon++;
			}
			if (numofon % 2 != p[j])flag = false;
		}
		if (flag)cnt++;
	}

	cout << cnt;

	return 0;

}

Measured memory_bytes: 256
S=str(input())
A=S[0]
B=S[1]
C=S[2]
D=S[-1]
if int(A)+int(B)+int(C)+int(D)==7:
 print(S[0]+'+'+S[1]+'+'+S[2]+'+'+S[-1]+'=7')
elif int(A)-int(B)+int(C)+int(D)==7:
  print(S[0]+'-'+S[1]+'+'+S[2]+'+'+S[-1]+'=7')
elif int(A)+int(B)-int(C)+int(D)==7:
 print(S[0]+'+'+S[1]+'-'+S[2]+'+'+S[-1]+'=7')
elif int(A)+int(B)+int(C)-int(D)==7:
 print(S[0]+'+'+S[1]+'+'+S[2]+'-'+S[-1]+'=7')
elif int(A)-int(B)-int(C)+int(D)==7:
 print(S[0]+'-'+S[1]+'-'+S[2]+'+'+S[-1]+'=7')
elif int(A)+int(B)-int(C)-int(D)==7:
 print(S[0]+'+'+S[1]+'-'+S[2]+'-'+S[-1]+'=7')
elif int(A)-int(B)+int(C)-int(D)==7:
 print(S[0]+'-'+S[1]+'+'+S[2]+'-'+S[-1]+'=7')
else:
 print(S[0]+'-'+S[1]+'-'+S[2]+'-'+S[-1]+'=7')




Measured memory_bytes: 3064
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        if(N == 1) Console.WriteLine("Hello World");
        else
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            Console.WriteLine(A + B);
        }
        
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	map<int,int>ma;
	rep(i,n){
		int a;cin>>a;
		ma[a]^=1;
	}
	int out=0;
	for(auto a:ma){
		if(a.second)out++;
	}
	cout<<out<<endl;
}








Measured memory_bytes: 4992