akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

score_list = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
counter = [0] * 9
for i in range(len(a)):
    if a[i] >= 3200:
        counter[8] += 1
    for j in range(8):
        if a[i] < score_list[j]:
            counter[j] += 1
            break
ans_min = 0
for i in range(len(counter) - 1):
    if counter[i] != 0:
        ans_min += 1
if counter[8] >= 1:
    ans_max = ans_min + counter[8]
    if ans_min == 0:
        ans_min += 1
else:
    ans_max = ans_min
print(ans_min, ans_max)

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


Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
D = {"r":P,"s":R,"p":S}
T = input().strip()
hist = [0 for _ in range(N)]
ans = 0
for i in range(N):
    a = T[i]
    if hist[i]==0:
        hist[i] = 1
        cnt = 1
        j = i
        while j+K<N and T[j+K]==a:
            hist[j+K]=1
            cnt += 1
            j += K
        ans += D[a]*(cnt-cnt//2)
print(ans)

Measured memory_bytes: 45648
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['Yes', 'No']
############# CODE STARTS HERE #############

test_case=1
while test_case:
    test_case-=1

    a=li()
    print(a.index(0)+1)

Measured memory_bytes: 61888
//orz myh
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=205;
int n,k,mod;
int fac[N],inv[N],f[N][N];
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=1ll*res*b%mod;
		b=1ll*b*b%mod; n>>=1;
	}
	return res;
} 
int calc(int k,int l,int in){
	for(int i=1;i<=k;++i){
		int sum=0;
		for(int j=l;j>=0;--j){
			sum=(sum+f[i-1][j])%mod;
			if(i==1) sum=1;
			if(i-1+j<=in && k-i+l-j<=in) f[i][j]=sum;
			else f[i][j]=0;
		}
		f[1][0]=0;
	}
	return f[k][0];
}
int solve(int n,int m){
	if(n==1) return 1;
	int ans=0;
	for(int i=2;i<n;++i)
		ans=(ans+calc(i,n-i,m))%mod;
	return 1ll*ans*fac[n-1]%mod;
}
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	for(int i=n-1;i>=1;--i)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
signed main(){
	cin>>n>>k>>mod;
	init(n);int ans=0;
	for(int i=0;i<=k;++i) //枚举多少个点度数为0
	{
		ans=ans+solve(n-i,k-i)*fac[n]%mod*inv[n-i]%mod;
		ans%=mod;	
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3952
# coding: utf-8
# Your code here!
l = []

for i in range(4):
    l.append(int(input()))

x = l[3]
ans = 0
for i in range(l[0]+1):
    for j in range(l[1]+1):
        for k in range(l[2]+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
                
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define INF 0x7fffffff
using namespace std;
typedef long long ll;
inline ll min(ll x,ll y) {return x<y?x:y;}
inline ll max(ll x,ll y) {return x>y?x:y;}
const int Maxn=1e5+5;
int a[2],k;
int main()
{
	cin>>a[0]>>a[1]>>k;
	for(int i=0;i<k;i++)
	{
		a[!(i&1)]+=a[i&1]/2;
		a[i&1]/=2;
	}
	cout<<a[0]<<" "<<a[1]<<endl;
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <tuple>
#include <set>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(v) (v).begin(),(v).end()
#define Sort(x) sort((x).begin(),(x).end())
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

void solve(int n){
    if(n<1912) cout<<"M"<<n-1868+1<<endl;
    else if(n<1926)cout<<"T"<<n-1912+1<<endl;
    else if(n<1989)cout<<"S"<<n-1926+1<<endl;
    else cout<<"H"<<n-1989+1<<endl;
}

void solve1(int a, int b){
    if(a==1)cout<<1868+b-1<<endl;
    else if(a==2)cout<<1912+b-1<<endl;
    else if(a==3)cout<<1926+b-1<<endl;
    else cout<<1989+b-1<<endl;
}

int main(){
    int e,y;
    cin>>e>>y;
    if(e==0){
        solve(y);
    }else solve1(e,y);
    
    
    
    return 0;
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, x;
    cin >> n;
    string s="",t="", m="";
    for(int i=0; i<n; i++){
        cin >> x;
        s+=(char)(x+'0');
    }
    for(int i=0; i<n; i++){
        cin >> x;
        t+=(char)(x+'0');
    }
    for(int i=1; i<=n; i++){
        m+=(char)(i+'0');
    }
    int cnt = 0, ans1 ,ans2;
    while(1){
        cnt++;
        if(m==s) ans1 = cnt;
        if(m==t) ans2 = cnt;
        if(!next_permutation(m.begin(), m.end())) break;
    }
    cout << abs(ans1- ans2);
return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++){
        if(s[i]=='C'){
            for(register int j=i+1;j<l;j++){
                if(s[j]=='F'){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
};

class BiDGraph : public Graph {//??????
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
};
class DGraph : public Graph {//??????
public:
	DGraph(int n) : Graph(n) {}
	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		sumcost++;
	}
};

void SCC(DGraph& g, vector<int>& scc) {
	vector<int> lowlink(g.vn, -1), orb(g.vn, -1);
	scc.resize(g.vn, -1);
	int cc = 0;
	int k = 0;
	vector<bool> used(g.vn);
	stack<int> st;
	function<int(int)> dfs = [&](int cur) {
		lowlink[cur] = orb[cur] = ++k;
		st.push(cur);
		used[cur] = 1;
		for (auto itr : g.g[cur]) {
			if (orb[itr.first] == -1)
				lowlink[cur] = min(lowlink[cur],dfs(itr.first));
			else if(used[itr.first])
				lowlink[cur] = min(lowlink[cur], orb[itr.first]);
		}
		if (lowlink[cur] == orb[cur]) {
			while (1) {
				int cp = st.top(); st.pop();
				used[cp] = 0;
				scc[cp] = cc;
				if (cp == cur)
					break;
			}
			cc++;
		}
		return lowlink[cur];
	};
	REP(i, g.vn) 
		if (orb[i] < 0) 
			dfs(i);
}

signed main() {
	int v, e;
	scnaf("%d %d", &v, &e);
	DGraph g(v);
	REP(i, e) {
		int a, b;
		scanf("%d %d", &a, &b);
		g.con(a, b);
	}
	vector<int> scc;
	SCC(g, scc);

	int q;
	scanf("%d", &q);

	REP(i, q) {
		int a, b;
		scanf("%d %d", &a, &b);

		printf("%d\n", scc[a] == scc[b]);
	}

	return 0;
}

Measured memory_bytes: 4736
$%=<>;@c=(0,2,5,5,4,5,6,3,7,6)[@a=sort{$b-$a}glob<>];
map{//;($p[$_])=sort{$b-$a}map$'<$_?-1:$p[$'-$_]+1,@c}1..$%;
$%-=$c[$i=(grep$p[$#_=$%-$c[$_]]+1==$p[$%],0..@a)[0]],print$a[$i]while$%

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define i64 long long
#define vi32 vector<int>
#define vi64 vector< long long>
#define  ii pair<int,int>
const  long long mod = 1e9 + 7, inf = 1e9, linf = 1 << 30; //linf = 9223372036854775807;
const long long hashmod[4] = { (int)1e9 + 2277, (int)1e9 + 5277, (int)1e9 + 8277, (int)1e9 + 9277 };
const long double EPS = 0.000000001L, pi = acos(-1);
using namespace std;
#define pb push_back
#define mp make_pair
#define N 200005
//int base = 311;
using namespace std;
int main()
{
    string s;
    int a;
    cin>>a>>s;
    if(a<3200)s="red";
    cout<<s;
    
}




/* Written by a random fan of Mr.Siro 

Association of people who died from abandonment

Gb_H

*/


Measured memory_bytes: 256
#define M 1000000
p[M+1];main(i,j,n){p[1]=1;for(;i<=M;i++)if(!p[i])for(j=i*2;j<=M;j+=i)p[j]=1;for(;scanf("%d",&n),n;printf("%d\n",j))for(i=2,j=0;i<=n/2;i++)if(!p[i]&&!p[n-i])j++;return 0;}

Measured memory_bytes: 0
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nm = inputs.head.split(" ").map(_.toInt)
  val n = nm(0)
  val m = nm(1)
  val students = inputs.tail.splitAt(n)._1
  val points = inputs.tail.splitAt(n)._2

  solve(students, points)

  private def solve(students: Seq[String], points: Seq[String]): Unit = {
    val pointsSeq = points.map(_.split(" ").map(_.toInt))

    students.foreach { s =>
      val sp = s.split(" ").map(_.toInt)

      var min = Int.MaxValue
      var nearPoint = 0
      pointsSeq.zipWithIndex.foreach { case (point, i) =>
        val diff = Math.abs(sp(0) - point(0)) + Math.abs(sp(1) - point(1))
        if(diff < min) {
          min = diff
          nearPoint = i + 1
        }
      }
      println(nearPoint)
    }
  }
}

Measured memory_bytes: 54988
H, W = gets.split.map(&:to_i)
as = []
H.times do |i|
    as[i] = gets.split.map(&:to_i)
end

ans = []

H.times do |i|
    if i%2==0
        W.times do |j|
            if as[i][j] % 2 == 1
                if j<W-1
                    ans.push([i, j, i, j+1])
                    as[i][j] -= 1
                    as[i][j+1] += 1
                else
                    next if i==H-1
                    ans.push([i, j, i+1, j])
                    as[i][j] -= 1
                    as[i+1][j] += 1
                end
            end
        end
    else
        (W-1).downto(0) do |j|
            if as[i][j] % 2 == 1
                if j>0
                    ans.push([i, j, i, j-1])
                    as[i][j] -= 1
                    as[i][j-1] += 1
                else
                    next if i==H-1
                    ans.push([i, j, i+1, j])
                    as[i][j] -= 1
                    as[i+1][j] += 1
                end
            end
        end
    end
end

puts ans.length
ans.each do |arr|
    puts arr.map{|n| n+1}.join(' ')
end

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

int main(){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a % 2 != 0) {
            cout << "first\n";
            return 0;
        }
    }
    cout << "second\n";
    return 0;
}

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

int SumOfDigits(int a){
  int sum=0;
  while(a>0){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main() {
  int N;
  cin >> N;
  int result=90;
  for(int i=1;i<N;i++){
    int a=SumOfDigits(i)+SumOfDigits(N-i);
    if(a<result) result=a;
  }
  cout << result << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s[3];
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[0][i] == s[1][i] && s[1][i] == s[2][i]) {
      continue;
    } else if (s[0][i] == s[1][i] && s[1][i] != s[2][i]) {
      ans++;
    } else if (s[1][i] == s[2][i] && s[1][i] != s[0][i]) {
      ans++;
    } else if (s[0][i] == s[2][i] && s[0][i] != s[1][i]) {
      ans++;
    } else {
      ans += 2;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    boolean[] use;
    int[] hand;
    int uc;

    void run(){
	while(sc.hasNext()){
	    use = new boolean[4];
	    hand = new int[5];
	    hand[0] = sc.nextInt();
	    use[hand[0]] = true;
	    uc = 1;

	    if(hand[0]==0) break;
	    for(int i=1; i<hand.length; i++){
		hand[i] = sc.nextInt();
		if(!use[hand[i]]){
		    use[hand[i]] = true;
		    uc++;
		}
	    }

	    if(uc==1 || uc==3){
		for(int i=0; i<5; i++)
		    System.out.println("3");
	    }
	    else{
		if(use[1] && use[2])
		    show(1, 2);
		else if(use[2] && use[3])
		    show(2, 3);
		else if(use[3] && use[1])
		    show(3, 1);
	    }
	}
    }

    void show(int win, int lose){
	for(int i=0; i<hand.length; i++)
	    System.out.println(hand[i]==win ? "1":"2");
    }
}

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

int judgeIntersection(double distance, double ra, double rb){
    if(distance > (ra + rb))
        return 0;
    else if((distance + ra) < rb)
        return -2;
    else if((distance + rb) < ra)
        return 2;
    else
        return 1;
}

int main(void){
    double xa, ya, ra, xb, yb, rb; 
    int N;
    std::cin >> N;
    while(std::cin >> xa >> ya >> ra >> xb >> yb >> rb){
        double distance = std::sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
        std::cout << judgeIntersection(distance, ra, rb) << std::endl;
    }
}

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

int ctoi(char c){
    if('0' <= c && c <= '9') return (c-'0');
    else return -1;
}

int main(void){
    string n;
    cin >> n;
    int f=0;
    for (size_t i = 0; i < n.size(); i++)
    {
        f+=ctoi(n[i]);
    }
    cout << ((stoi(n)%f==0)?"Yes":"No")<<endl;
    return 0;
}

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

string solve() {
    ll N;
    string S, t;
    cin >> N >> S;
    for ( char c : S ) {
        char d = 'A' + ((int)(c - 'A') + N ) % 26;
        t.push_back(d);
    }
    return t;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
  string a;
  cin >> a;
  
  for(int i=0;i<3;i++){
    if(a.at(i)=='1'){
      a.at(i) = '9';
    }
    else{
      a.at(i) = '1';
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define eb emplace_back
#define em emplace
#define print(x) cout<<x<<endl;
#define in(k) int k;cin>>k
typedef long long int ll;
const ll mod=1e9+7;
int c=0;
int n,m;
vector<vector<int>> g;
vector<int> e,f;
void dfs(int n)
{
    for(auto to:g[n])
    {
        if(f[to]==0)
        {
            f[to]=1;
            dfs(to);
        }
        e[n]=max(e[n],e[to]+1);
        c=max(c,e[n]);
    }
}
int main()
{
    fastio;
    cin>>n>>m;
    g=vector<vector<int>>(n+1);
    e.assign(n+1,0);
    f.assign(n+1,0);
    fore(i,0,m)
    {
        in(x);in(y);
        g[x].eb(y);
    }
    fore(i,1,n+1)
    {
        if(f[i]!=1)
        {
            f[i]=1;
            dfs(i);
        }
    }
    cout<<c;
    return 0;
}
    

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
const int mod= 1000000007;

void add_self(int &a, int b){
      a+=b;
      while(a>mod)
            a-=mod;
}

int main(){
      string s;
      int d;
      cin>>s>>d;
      int len=s.length();
      vector<vector<int>>dp(d, vector<int>(2, 0));

      dp[0][0] = 1;

      for(int where = 0; where < len; where++){
            
            vector<vector<int>>new_dp(d, vector<int>(2, 0));
            
            for(int sum = 0; sum < d; sum++){
                  
                  for(bool sm_already: {false, true}){
                        
                        for(int digit = 0; digit < 10; digit++){
                              
                              if((digit > s[where] - '0') && !sm_already){
                                    break;
                              }
                              add_self(new_dp[(sum + digit)%d][sm_already || (digit < (s[where] - '0'))], dp[sum][sm_already]);
                        }
                  }
            }
            dp = new_dp;
      }
      int ans=dp[0][1]+dp[0][0];
      ans--;
      ans%=mod;
      if(ans<0)ans=mod-1;
      cout<<ans<<'\n';
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b,c;
    cin >> a>>b >>c;
    // スペース区切りの整数の入力
    // 文字列の入力
    cout << (a*b)/2  << endl;
    return 0;
  }


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

N,M = map(int,readline().split())
A = list(map(int,readline().split()))

B = [A[i]//2 for i in range(N)]
ans = 1

dev_c = 0
while A[0]%2 != 1:
    A[0] = A[0]//2
    dev_c += 1
#print(dev_c)

for i in range(1,N):
    dev_c2 = 0
    while A[i]%2 != 1:
        A[i] = A[i]//2
        dev_c2 += 1
    if dev_c != dev_c2:
        ans = 0
        break

l = B[0]
if ans == 1:
    for i in range(N):
        l = lcm(l,B[i])

#print(l)

if ans != 0:
    ans = (M//l+1)//2

print(ans)

Measured memory_bytes: 12972
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	int x[100], y[100], h[100];
	for(int i = 0; i < n; i++) scanf("%d %d %d", &x[i] ,&y[i], &h[i]);
	for(int cx = 0; cx <= 100; cx++) for(int cy = 0; cy <= 100; cy++){
		int H;
		for(int i = 0; i < n; i++) if(h[i] > 0){
			H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
			break;
		}
		int i;
		for(i = 0; i < n; i++){
			int t = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0);
			if(t != h[i]) break;
		}
		if(i == n){ printf("%d %d %d\n", cx, cy, H); return 0; }
	}
	return 0;
}

Measured memory_bytes: 128
import fractions
def gcd(x,y): return fractions.gcd(x,y)
def lcm(a,b): return a*b//fractions.gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
x=a[0]
for i in range(1,n):
    x=lcm(x,a[i])
ans=chk=0
for i in a:
    ans+=x//i
print(x/ans)

Measured memory_bytes: 66028
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt(),c=stdIn.nextInt(),k=stdIn.nextInt(),i,t=a,s;
		for(i=0;i<k;i++) t*=2;
		s=t+b+c;
		t=b;
		for(i=0;i<k;i++) t*=2;
		if(s<t+a+c) s=t+a+c;
		t=c;
		for(i=0;i<k;i++) t*=2;
		if(s<t+a+b) s=t+a+b;
		System.out.print(s);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1
static const int N = 100;

int main(){
  int M[N][N];
  int n,u,k,v;
  cin >> n;

  for(int i = 0;i<n;i++){
      for(int j = 0;j<n;j++){
          M[i][j]= 0;
      }
  }
for(int i = 0;i<n;i++){
    cin >> u >> k;
    u--;//0オリジンに変換
    for(int j = 0;j<k;j++){
        cin >> v;
        v--;
      M[u][v] = 1;

    }
}
for(int i = 0;i<n;i++){
      for(int j = 0;j<n;j++){
         if(j) cout << " ";
         cout << M[i][j];  
         if(j == n-1) cout << endl;
      }
}
}


Measured memory_bytes: 3108
#include<stdio.h>
int main (){
	int nyawaa;
	int damagee;
	int serangann;
	
	1<=nyawaa<=10000;
	1<=damagee<=10000;
	
	scanf("%d %d", &nyawaa, &damagee);
	
	serangann = nyawaa/damagee;
		
	nyawaa%damagee==0 ? printf("%d", serangann) : printf("%d", serangann+1);
	
	
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define LD long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define loop(i,a,b) for(int i=a;i<=b;++i)
#define pool(i,a,b) for(int i=a;i>=b;--i)
#define int long long
using namespace std; const int N = 300000 + 5, N2 = 50000 + 5, LOG = 9 + 1, INF = 1e9;

signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,l; cin>>n>>l;
	int tot=0; loop(i,1,n) tot+=l+i-1;
	int cur=-10000;
	loop(i,1,n) if(abs(tot-(l+i-1) - tot) < abs(cur - tot)) cur=tot-(l+i-1);
	cout<<cur<<'\n';
}


Measured memory_bytes: 256
// Payment 
// https://atcoder.jp/contests/abc173/tasks/abc173_a
// date: 2020-08-09T18:11:33.316424

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

#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 ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

template<typename T, typename ...Args>
void IN(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args));
}

template<char Sep, typename T, typename ...Args>
void print_sep(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args));
}

template<typename... Words>
void OUT(Words... words) {
    print_sep<' '>(words...);
    cout << endl;
    return;
}

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

int main(void){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll N;
    IN(N);
    OUT((1000 - N % 1000) % 1000);
}


Measured memory_bytes: 3636
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long a = parseLong(sc.next());
		char[] op = sc.next().toCharArray();
		long b = parseLong(sc.next());
		sc.close();
		out.println(op[0]=='+'?a+b:a-b);
	}
}


Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<cstring>
#define int long long
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
vector<int> a(100050);
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;
	string s;
	cin >> a >> s;
	cout << ((a >= 3200) ? s : "red") << '\n';
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int ans = 1;
            for (int i = 0; i < N - 1; i++)
            {
                if (S[i] != S[i + 1])
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;
int main(){
  int n;
  cin >> n;
  n %= 10;
  if(n==3) cout << "bon" << endl;
  else if(n==0 || n==1 || n==6 || n==8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	    	Stack<Integer> stack = new Stack<Integer>();
			
		    String str = kb.readLine();
			int a, b;
		    for( String wd: str.split( " " ) ) {
			    if( "+".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a + b );			    
			    } else if( "-".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a - b );			    
			    } else if( "*".equals( wd ) ) {
			    	b = stack.pop();
			    	a = stack.pop();
			    	stack.push( a * b );			    
			    } else {
			    	stack.push( Integer.parseInt( wd ) );
			    }
		    }

            System.out.println( stack.pop() );
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
}

Measured memory_bytes: 17068
package main

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

func main() {
	n := oneInt()
	as := scanNums(n)

	ans := calc(as)

	fmt.Println(ans)
}

func calc(as []int) int64 {
	var minusCount int
	for _, ai := range as {
		if ai < 0 {
			minusCount++
		}
	}
	var answer int64
	if minusCount%2 == 0 {
		for _, ai := range as {
			answer += int64(abs(ai))
		}
	} else {
		s := []int{}
		for _, ai := range as {
			s = append(s, abs(ai))
		}
		sort.Ints(s)
		answer = int64(s[0] * -1)
		for _, si := range s[1:] {
			answer += int64(si)
		}
	}
	return answer
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

func nextWord(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanNums(n int) (nums []int) {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		s := nextWord(sc)
		num, _ := strconv.Atoi(s)
		nums = append(nums, num)
	}
	return nums
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 7424
#include<stdio.h>

int main(){
  int h,w;
  while(1){
    scanf("%d %d",&h,&w);
    if ( w == 0 && h == 0 )break;
    else{
      for(int i=0;i<h;i++){
        for (int j=0;j<w;j++)
        {
          if( i%2 == 0 ){
            if( j%2 == 0)printf("#");
            else printf(".");
            
          }else{
            if( j%2 == 0)printf(".");
            else printf("#");
          }
        }
        printf("\n");
      }
    }
    printf("\n");
  }
  

  return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N + 2);
    A[0] = 0;
    A[N + 1] = 0;
    // N個の観光スポットを番号順に訪れ、最後に座標 0
    // の点に戻ってくることになっています。
    REP(i, N) { cin >> A[i + 1]; }
    int cnt = 0;
    REP(i, N + 1) {
        cnt += abs(A[i + 1] - A[i]);
        // cout << cnt << endl;
    }
    for(int i = 1; i <= N; i++) {
        if(A[i - 1] <= A[i] and A[i] <= A[i + 1]) {
            cout << cnt << endl;
        } else {
            cout << cnt - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) +
                        abs(A[i + 1] - A[i - 1])
                 << endl;
        }
    }
}

Measured memory_bytes: 1664
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
    string s;
	cin >> s;
	for(int i = 0; i < s.length()-1; i ++){
		if(s.substr(i,2) == "AC"){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n
    character(len=200000)::s,t
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*)s
    read(*,*)t
    n=len_trim(s)
    m=0
    do i=1,n
        if(s(i:i) .ne. t(i:i))then
            m=m+1
        end if
    end do
    write(*,*) m
  
    stop
end program sample
  



Measured memory_bytes: 3448
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,C = MI()
A = [[0]*(10**5+2) for i in range(C+1)]
for i in range(N):
    s,t,c = MI()
    A[c][s] += 1
    A[c][t+1] -= 1

from itertools import accumulate

for i in range(1,C+1):
    A[i] = list(accumulate(A[i]))

# A[i][j] が正 ⇔ チャンネル i が時刻 j に録画機が必要

ans = 0
for j in range(10**5+2):
    ans = max(ans,sum(A[i][j] > 0 for i in range(1,C+1)))

print(ans)


Measured memory_bytes: 175676
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] tot = new int[3];
		int[][] cs = new int[3][];
		for(int i=0;i<3;i++){
			cs[i] = new int[NC];
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				cs[(i+j) % 3][C[i][j]]++;
				tot[(i+j) % 3]++;
			}
		}
		
		long min = (long) 1e18;
		for(int i=0;i<NC;i++){
			for(int j=0;j<NC;j++){
				for(int k=0;k<NC;k++){
					if(i == j || i == k || j == k) continue;
					long diff = 0;
					for(int l=0;l<NC;l++) diff += D[l][i] * cs[0][l];
					for(int l=0;l<NC;l++) diff += D[l][j] * cs[1][l];
					for(int l=0;l<NC;l++) diff += D[l][k] * cs[2][l];
					
					min = Math.Min(min, diff);
					
				}
			}
		}
		
		Console.WriteLine(min);
		
		
		
		
	}
	
	int N, NC;
	long[][] D;
	int[][] C;
	public Sol(){
		var d = ria();
		N = d[0]; NC = d[1];
		D = new long[NC][];
		for(int i=0;i<NC;i++){
			D[i] = rla();
		}
		C = new int[N][];
		for(int i=0;i<N;i++){
			C[i] = ria();
			for(int j=0;j<N;j++) C[i][j]--;
		}
		
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18504
def main():
    s=input()
    m=int(input())
    tank=[]
    n=len(s)
    alpha=[chr(i) for i in range(97, 97+26)]
    for i in range(26):
        for j in range(n):
            if alpha[i]==s[j]:
                for k in range(min(n-j,m)):
                    if s[j:j+k+1] not in tank:
                        tank.append(s[j:j+k+1])
        if len(tank)>=m:
            break
    tank.sort()
    print(tank[m-1])
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long H, long long W, long long D, std::vector<std::vector<long long>> A, long long Q, std::vector<long long> L, std::vector<long long> R)
{
}

int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    long long D;
    scanf("%lld", &D);
    vector<pair<int, int>> A(H * W + 1);
    vector<ll> ruiseki(H * W + 1);
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int a;
            cin >> a;
            A[a] = make_pair(i + 1, j + 1);
        }
    }
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> L(Q);
    std::vector<long long> R(Q);
    for (int i = 1; i <= H * W; i++)
    {
        if (i - D <= 0)
        {
            ruiseki[i] = 0;
        }
        else
        {
            ruiseki[i] = ruiseki[i - D] + abs(A[i].first - A[i - D].first) + abs(A[i].second - A[i - D].second) ;
        }
    }

    for (int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << ruiseki[r] - ruiseki[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 4096
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans;
int fen(int k){
	int s=0;
	while (k){
		s+=k%10;
		k/=10;
	}
	return s;
}
int main(){
	scanf("%d",&n);
	ans=0x3f3f3f3f;
	for(int i=1;i<n;i++)ans=min(ans,fen(i)+fen(n-i));
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> dp(K + 1, 0);
	vector<int> ndp(K + 1, 0);
	dp[0] = 1;
	ndp[0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= K; j++) {
			//ndp[j] = sum(dp[j], dp[j - A[i]]);
			//ndp[j - 1] = sum(dp[j - 1], dp[j - 1 - A[i]]);
			if (j > 0)ndp[j] += ndp[j - 1];
			if (j - 1 - A[i] >= 0)ndp[j] -= dp[j - 1 - A[i]] - MOD;
			//ndp[j] += 10 * MOD;
			ndp[j] %= MOD;
		}
		dp = ndp;
	}
	cout << dp[K] << endl;
}

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

int main(){
  int n;
  string s;
  cin >> n;
  cin.ignore();
  while(n--){
    getline(cin, s);
    string ans = s;
    for(int i = 0 ; i < 26 ; i++){
      for(int j = 0 ; j < 26 ; j++){
	for(int k = 0 ; k < s.size() ; k++){
	  if(isalpha(s[k])) ans[k] = ((i*s[k]+j)%26)+'a';
	}
	if(ans.find("that")+1 || ans.find("this")+1) goto finish;
      }
    }
  finish:;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int main(){
  int l; cin >> l;
  double ans = pow(l,3)/27;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
list($s) = strs();
$a = '';
for ($i = 0; $i < strlen($s); ++$i) {
    if ($s[$i] === 'B') $a = substr($a, 0, -1);
    else $a .= $s[$i];
}
echo $a;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


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

ll dp[100005];

int main(){
int n, m;
cin >>n >>m;
vector<bool> ok(n+1, true);
for(int i = 0; i<m; i++){
 int a; cin >> a;
 ok[a] = false;
}

dp[0]= 1;
for(int now = 0; now<n; now++){
  for(int next = now+1; next<=min(n, now+2);next++){
     if(ok[next]){
           dp[next] += dp[now];
            dp[next] %= 1000000007;
          }
      }
  }
cout << dp[n] << endl;
return 0;
}


Measured memory_bytes: 4424
from collections import defaultdict
n=int(input())
d=defaultdict(int)
for _ in range(n):
    s=input()
    d[s] += 1
print("AC x %d" % d["AC"])
print("WA x %d" % d["WA"])
print("TLE x %d" % d["TLE"])
print("RE x %d" % d["RE"])

Measured memory_bytes: 69852
D,N = map(int, input().split())

if D == 0:
    if N != 100:
        print(N)
    else:
        print(101)

elif D == 1:
    if N != 100:
        print(100*N)
    else:
        print(100*101)

elif D == 2:
    if N != 100:
        print(100*100*N)
    else:
        print(100*100*101)


Measured memory_bytes: 3060
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
a1 = a.pop(0)

if a[0] <= a1 / 2:
    res = a[0]
elif a[-1] >= a1 / 2:
    res = a[-1]
else:
    left = 0
    right = n-2
    while True:
        j = (left + right) // 2
        if left == right:
            res = a[left]
            break
        elif a1/2 >= a[j+1] and a1/2 <= a[j]:
            if abs(a[j+1]-a1/2) >= abs(a[j]-a1/2):
                res = a[j]
            else:
                res = a[j+1]
            break
        elif a1/2 > a[j]:
            right = j
        else:
            left = j

print(a1, res)

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

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

// global variables

int main() {
  int n;cin>>n;
  int cnt[n]={};
  rep(i,n){
    int t;cin>>t;
    cnt[t] += 1;
  }

  int now = n-1;
  while (true){
    if (now <= 0){
      int res = 1;
      rep(i, n/2){
        res *= 2;
        res %= MOD;
      }
      std::cout << res << std::endl;
      return 0;
    }
    if (cnt[now] != 2){
      std::cout << 0 << std::endl;
      return 0;
    }
    now -= 2;
  }

  return 0;
}


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

int main() {
 	int s;
	cin >> s;
	int s1 = s / 100;
	int s2 = (s - s1 * 100) / 10;
	int s3 = (s - s1 * 100 - s2 * 10) / 1;
	cout << s1 + s2 + s3 << endl;
	
	
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cstdio>
using namespace std;
#define rep(i, b) for( int i = 0; i < b; i++ )
#define repi(i, a, b) for( int i = a; i < b; i++ )
typedef vector<int> vec;
#define eps 1e-10

struct C{
    double l, a, b;
};

int N, M;
double ans = 0;
vector<C> c;

double dist( C c1, C c2 ){
    return pow(c1.l - c2.l, 2) + pow(c1.a - c2.a, 2) + pow(c1.b - c2.b, 2);
}

void dfs( int d, vec v ){
    if( d == M ){
        double sum = 0;
        rep(i, v.size()) repi(j, i+1, v.size()){
            sum += dist(c[v[i]], c[v[j]]);
        }
        //cout << 'ans:' << ans << endl;
        ans = max( ans, sum );
    }else{
        repi(i, v[d-1]+1, N){
            v.push_back(i);
            dfs(d+1, v);
            v.pop_back();
        }
    }
}

int main(){
    cin >> N >> M;
    rep(i, N){
        C t;
        cin >> t.l >> t.a >> t.b;
        c.push_back(t);
    }
    vec v;

    rep(i, N){
        v.push_back(i);
        dfs(1, v);
        v.pop_back();
    }
    printf("%.20f\n", ans);
}

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

int main(){
    int n,m;
    scanf(" %d %d",&n,&m);
    vector<vector<int>> g(n);
    for(int i = 0; i < m;++i){
        int a,b;
        scanf(" %d %d",&a,&b);
        --a,--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int dist[n];
    memset(dist,-1,sizeof(dist));
    queue<int> q;
    q.push(0);
    dist[0] = 0;
    while(q.size()){
        int dad = q.front();
        q.pop();
        for(auto va:g[dad]){
            if(dist[va] == -1){
                dist[va] = dist[dad]+1;
                q.push(va);
            }
        }
    }
    if(dist[n-1] != -1 && dist[n-1] < 3)
        puts("POSSIBLE");
    else
        puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 16152
#include<iostream>
using namespace std;
#define INF (1 << 30)

int main() {
	int n;
	cin >> n;
	int h[n], dp[n];
	for (int i=0; i<n; i++) {
		cin >> h[i];
		dp[i] = INF;
	}

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 0; i < n; i++) {
			dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]- h[i]));
			dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]- h[i]));
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))

A.sort()

B = [0 for _ in range(N)]
b = 0
for i in range(N):
    b += A[i]
    B[i] = b

ans = 1
for i in range(N-1):
    if 2*B[i]>=A[i+1]:
        ans += 1
    else:
        ans = 1
        
print(ans)

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

int main() {
  	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	bool res = (abs(a - c) <= d) || ((abs(a - b) <= d) && (abs(b - c) <= d));
  	cout << (res ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
    priority_queue<ll, vector<ll>> que;
    rep(i,x) que.push(p[i]);
    rep(i,y) que.push(q[i]);
    ll total = 0;
    int j = 0, count = 0;
    rep(i,x+y) {
        if (j == c) break;
        if (que.top() > r[j]) {
            total += que.top();
            que.pop();
            count++;
        } else {
            total += r[j];
            j++;
        }
    }
    rep(i,x+y-j-count) {
        total += que.top();
        que.pop();
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int N;
    cin >> N;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    LL ans=0;
    for(int i=0;i<N-1;i++){
        a[i+1]+=a[i];
    }
    sort(a,a+N);
    LL u=0;
    for(int i=0;i<N;i++){
        if(a[i]==0){
            ans++;
        }
        if(a[i]==a[i+1]){
            u++;
            continue;
        }
        else{
            if(!u) continue;
            ans+=u*(u+1)/2;
            u=0;
        }
    }
    ans+=u*(u+1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792