akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#define N 100020
#define M 10000000000LL
using namespace std;

namespace Sieve
{
    int p[N], c;
    bool u[N];

    void InitSieve(int n)
    {
        int i, j;

        for(i = 2; i <= n; i ++)
        {
            if(!u[i])
                p[c ++] = i;
            for(j = 0; j < c && i * p[j] <= n; j ++)
            {
                u[i * p[j]] = true;
                if(!(i % p[j]))
                    break;
            }
        }

        return;
    }
}

long long a[N];
long long f[N], g[N];
map<long long, int> h;

int main(void)
{
    int n;
    int i, j, k, o;
    long long t;

    Sieve::InitSieve((int)pow((long double)M, (double)1 / 3));
    scanf("%d", &n);
    for(i = o = 0; i < n; i ++)
    {
        scanf("%lld", &a[i]);
        f[i] = g[i] = 1;
        for(j = 0; j < Sieve::c; j ++)
        {
            for(k = 0; !(a[i] % Sieve::p[j]); a[i] /= Sieve::p[j])
                k = (k + 1) % 3;
            for(t = 0; t < k; t ++)
                f[i] *= Sieve::p[j];
            for(t = 0; t < (3 - k) % 3; t ++)
                g[i] *= Sieve::p[j];
        }
        f[i] *= a[i];

        t = (long long)sqrt((long double)a[i]);
        if(t * t == a[i])
            g[i] *= t;
        else
            g[i] *= a[i] * a[i];

        if(f[i] == g[i])
            o += !h.count(f[i]);
        h[f[i]] ++;
    }

    // for(i=0;i<n;i++)printf("%lld %lld\n",f[i],g[i]);

    for(i = 0; i < n; i ++)
        if(f[i] != g[i] && h.count(f[i]))
        {
            o += max(h[f[i]], h[g[i]]);
            h.erase(f[i]);
            h.erase(g[i]);
        }
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 8832
#include<stdio.h>
int main()
{
    int n,a[1000],i,j,acm;
    while(~scanf("%d",&n))
    {
        acm=0;
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(i=1;i<n;i++)
            for(j=i+1;j<=n;j++)
            {
                acm+=a[i]*a[j];
            }
        printf("%d\n",acm);
    }
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
	long long x, y;
	int c = 0;
	cin >> x; cin >> y;
	while (x <= y) {
		x *= 2;
		c += 1;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd

n = int(input())
a_array = [int(x) for x in input().split()]

gcd_array = []
for index in range(n):
    if index == 0:
        gcd_array.append(a_array[0])
    else:
        gcd_array.append(gcd(gcd_array[index - 1], a_array[index]))
gcd_reversed_array = []
for index in range(n):
    if index == 0:
        gcd_reversed_array.append(a_array[index - 1])
    else:
        gcd_reversed_array.append(gcd(gcd_reversed_array[index - 1], a_array[-(index + 1)]))

res = 0
gcd_reversed_array.reverse()
for i in range(n):
    if i == 0:
        res = max(res, gcd_reversed_array[1])
    elif i == n - 1:
        res = max(res, gcd_array[-2])
    else:
        res = max(res, gcd(gcd_array[i - 1], gcd_reversed_array[i+1]))
print(res)


Measured memory_bytes: 16152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(); 

        if (n % 10 == 7 || n / 10 % 10 == 7 || n / 100 % 10 == 7) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35772
import java.util.Scanner;
public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b && b < c) System.out.println("Yes");
		else System.out.println("No");
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



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

int main() {
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A*B}) << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors[1:] + upper_divisors[::-1]

def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False

  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True


n = int(input())
if n == 1:
    print(0)
    exit()
if isPrime(n):
    print(1)
    exit()
div = make_divisors(n)
ans = 0
for i in range(len(div)):
    if n % div[i] == 0:
        divdiv = make_divisors(div[i])
        if div[i] == divdiv[0] ** len(set(divdiv)):
            if isPrime(divdiv[0]):
                n //= div[i]
                ans += 1
    if n == 1:
        break
print(ans)

Measured memory_bytes: 64916
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var number = input.split(' ').map(Number);
var a = number[0];
var b = number[1];
var x = Math.floor(a/b);
var y = a%b;
var z = (a/b).toFixed(10);
console.log(x+" "+y+" "+z);


Measured memory_bytes: 15412
#include <bits/stdc++.h>
//g++ -std=c++11
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define ii pair <int, int>
#define vii vector <ii> ;
#define INF 1e9+1
typedef long long ll;
#define MOD 1000000007;

int main() {

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

    int n;
    cin >> n;

    if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9)
        cout << "hon" << endl;
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8)
        cout << "pon" << endl;
    else if(n%10==3)
        cout << "bon" << endl;

    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

void solve(ll n, string s, char c) {
  if (n == s.size()) {
    cout << s << endl;
    return;
  }

  for (char i = 'a'; i <= c; ++i) {
    solve(n, s+i, (i == c) ? c+1 : c);
  }
}

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

  solve(n, "", 'a');
  
  return 0;
}

Measured memory_bytes: 1536
from sys import stdin
from sys import stdout
n = int(input())
a = [int(stdin.readline()) for _ in range(n)]
s = max(a)
cnt = a.count(s)
if cnt > 1:
    for x in a:
        stdout.write("{}\n".format(s))
    quit()
t = -1
for x in a:
    if x != s:
        t = max(t, x)
for x in a:
    stdout.write("{}\n".format(s if x != s else t))

Measured memory_bytes: 12460
#include <stdio.h>

int main() {
  double a, an[10];
  double sum;
  int k;
  while(scanf("%lf", &a) != EOF) {
    an[0] = a;
    for(k = 1; k < 10; k++) {
      if((k+1) % 2 == 0) {
	an[k] = an[k-1] * 2.0;
      } else {
	an[k] = an[k-1] / 3.0;
      }
    }
    sum = 0;
    for(k = 0; k < 10; k++) {
      sum += an[k];
    }
    printf("%2.8f\n", sum);
  }
  return 0;
}

Measured memory_bytes: 0
num=0
t=0
e=0
d=0
for i in range(109):
    A=input()
    A=A.rstrip().split(" ")
    list1=[int(A[0]),int(A[1]),int(A[2])]
    list1.sort()
    if list1[2]>=list1[0]+list1[1]:
        break
    elif (list1[2])**2==(list1[0])**2+(list1[1])**2:
        num+=1
        t+=1
    elif (list1[2])**2>(list1[0])**2+(list1[1])**2:
        num+=1
        d+=1
    elif (list1[2])**2<(list1[0])**2+(list1[1])**2:
        num+=1
        e+=1
print(num,t,e,d)


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int x, y;
    cin >> x >> y;
    int group1[7] = {1, 3, 5, 7, 8, 10, 12};
    int group2[7] = {4, 6, 9, 11, 0, 0, 0};
    int group3[7] = {2, 0, 0, 0, 0, 0, 0};

    int cnt1 = 0;
    int cnt2 = 0;
    int cnt3 = 0;

    // 処理
    rep(i, 7) {
        if (x == group1[i]) {
            cnt1 = 1;
        }
        if (x == group2[i]) {
            cnt2 = 1;
        }
        if (x == group3[i]) {
            cnt3 = 1;
        }
    }
    rep(i, 7) {
        if (cnt1 == 1 && y == group1[i]) {
            cnt1 = 2;
        }
        if (cnt2 == 1 && y == group2[i]) {
            cnt2 = 2;
        }
        if (cnt3 == 1 && y == group3[i]) {
            cnt3 = 2;
        }
    }

    // 出力
    if (cnt1 == 2 || cnt2 == 2 || cnt3 == 2) {
        cout << "Yes " << endl;
    } else {
        cout << "No " << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<set>
#include<complex>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
bool visited[100];
typedef complex<double> P;
const double EPS = 1e-10;

double cross(P a,P b){
  return ( a.real()*b.imag() - a.imag()*b.real());
}

bool is_point_online(P a,P b,P c){
  return ( abs(a-c)+abs(b-c) < abs(a-b)+EPS);
}

bool isl(P a1,P a2,P b1,P b2){
  if ( is_point_online(a1,a2,b1))return true;
  if ( is_point_online(a1,a2,b2))return true;
  if ( is_point_online(b1,b2,a1))return true;
  if ( is_point_online(b1,b2,a2))return true;
  if (  ( cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1)<-EPS ) && 
	( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<-EPS))return true;
  else return false;
}

bool is_in(P *in,P a){
  int cnt = 0;
  rep(i,4){
    P cur = in[i]-a,next=in[(i+1)%4]-a;
    if ( cur.imag()>next.imag())swap(cur,next);
    if (cur.imag()<0 && 0 <=next.imag() &&
	cross(next,cur)>=0)cnt++;
    if ( is_point_online(in[i],in[(i+1)%4],a))return true;
  }
  if ( cnt % 2 == 1)return true;
  else return false;
}

class block{
public:
  P in[4];
  bool sect(block  a){
    rep(i,4)
      rep(j,4)
      if ( isl(in[i],in[(i+1)%4],a.in[j],a.in[(j+1)%4]))return true;
    rep(i,4)if ( is_in(in,a.in[i])||is_in(a.in,in[i]))return true;
    return false;
  }
};

class sq{public:vector<block> in;};

void dfs(int n,sq & me,int now){
  visited[now]=true;
  rep(i,n){
    if ( i != now && visited[i]==false && me.in[now].sect(me.in[i])==true)
      dfs(n,me,i);
  }
}

int solve(int n,sq me){
  rep(i,100)visited[i]=false;
  int cnt = 0;
  rep(i,n)if ( visited[i] == false)cnt++,dfs(n,me,i);
  return cnt;
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,n){
      int m;
      cin>>m;
      sq now;
      rep(j,m){
	block ins;
	rep(k,4)cin>>ins.in[k].real()>>ins.in[k].imag();
	now.in.push_back(ins);
      }
      cout << solve(m,now) << endl;
    }
  }
  return false;
}

Measured memory_bytes: 992
n=int(input())
a=list(map(int, input().split()))
ans='YES'
suma=sum(a)
i=suma/(n*(n+1)//2)
a2=[a[j]-a[j-1]-i for j in range(n)]
for i in a2:
    if i%n!=0 or i>0:ans='NO'
print(ans)

Measured memory_bytes: 14260
#pragma GCC optimize("O3") 

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

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

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << ": " << x << endl;
#define deb2(x,y)	        cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    ll d, t,s;
    cin >> d >> t >> s;
    if(s * t < d)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

#define rep(x, a, b) for (int x = a; x < b; x++)

int table[] = {254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129, 128, 127};

int main()
{
  int t;

  cin >> t;

  rep (i, 0, t) {
    int n, d;

    cin >> n >> d;

    if (n == 1) {
      cout << d << endl;;
    } else {
      cout << 127 * (n - 2) + table[(n % 2) ? (127 ^ d) : d] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;


class Page{
 
    String name;
    int n,btnn;
    int[][] b;
    String[] linkpage;
    public Page(int n,String name,int btnn,int[][] b,String[] linkpage){
	this.n=n;this.name=name;this.btnn=btnn;this.b=b;this.linkpage=linkpage;
    }
}



class Main{
   boolean debug=false;
    int n,w,h;
    HashMap<String,Integer> map;

    void run(){
	Scanner sc=new Scanner(System.in);
	while(true){
	    n=sc.nextInt();if(n==0)break;
	    w=sc.nextInt();h=sc.nextInt();
	    Page[] a=new Page[n];
	    map=new HashMap<String,Integer>();
	    for(int k=0;k<n;k++){
		String name=sc.next();
		int btnn=sc.nextInt();
		int[][] b=new int[btnn][4];
		String[] linkpage=new String[btnn];
		for(int i=0;i<btnn;i++){
		    b[i][0]=sc.nextInt();b[i][1]=sc.nextInt();
		    b[i][2]=sc.nextInt();b[i][3]=sc.nextInt();
		    linkpage[i]=sc.next();
		}
		a[k]=new Page(k,name,btnn,b,linkpage);
	    }
	    for(int i=0;i<n;i++){
		String name=a[i].name;
		map.put(name,i);//名前ーページ番号
	    }

	    int m=sc.nextInt();
	    LinkedList<Integer> rireki=new LinkedList<Integer>();
	    Page cnt=a[0];int pt=0;rireki.add(0);
	    for(int i=0;i<m;i++){
		char command=sc.next().charAt(0);
		switch(command){
			case 'c':{
		    int x=sc.nextInt();int y=sc.nextInt();
		    if(debug)System.out.printf("cnt.btnn=%d x=%d y=%d cnt.b[0][0]=%d \n",cnt.btnn,x,y,cnt.b[0][0]);
		    for(int k=0;k<cnt.btnn;k++){
			if(inrange(cnt.b[k],x,y)){
			    while(rireki.size()>pt+1)rireki.removeLast();
			    cnt=a[map.get(cnt.linkpage[k])];
			    rireki.add(cnt.n);if(debug)System.out.printf("pppp \n");
			    pt++;
			    break;
			}}
		    break;
		}
		case 'b':{if(pt>0)pt--;cnt=a[rireki.get(pt)];break;}
		case 'f':{if(pt<rireki.size()-1)pt++;cnt=a[rireki.get(pt)];break;}
		case 's':{System.out.println(cnt.name);
			if(debug)System.out.printf("size=%d cnt.n=%d cnt.name=%s pt=%d \n",rireki.size(),cnt.n,cnt.name,pt);break;}
		}
	    }
	}
    }

    boolean inrange(int[] b,int x,int y){
	return x>=b[0] && x<=b[2] && y<=b[3] && y>=b[1];
    }

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

Measured memory_bytes: 13000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

L = int(input())
orig_L = L

v = 1
edges = []  # (from, to, cost)

# L = 37の場合を例にとりコメントを付与
# まず長さ0 ~ 31までのパスを作成する。
#   頂点1 -> 頂点2を0の辺と1の辺で結ぶ
#   頂点2 -> 頂点3を0の辺と2の辺で結ぶ
#   頂点3 -> 頂点4を0の辺と4の辺で結ぶ
#   頂点4 -> 頂点5を0の辺と8の辺で結ぶ
#   頂点5 -> 頂点6を0の辺と16の辺で結ぶ
n = 2
cost = 1
while n <= L:
    edges.append((v, v+1, 0))
    edges.append((v, v+1, cost))
    cost *= 2
    v += 1
    n *= 2

# 頂点6をv_sink(最終到達点)とする
v_sink = v

# ここから先、長さ32, 33, 34, 35, 36のパスを生成することになる。
# 頂点3と頂点6を、32の辺で直でつなぐと、長さ32, 33, 34, 35のパスが作れる。
# 頂点1と頂点6を、32の辺で直でつなぐと、長さ36のパスが作れる。
n //= 2
N = n
L -= N

# print("N:", N)
# print("L:", L)
# print("v:", v)

while L > 0:
    if L >= n:
        edges.append((v, v_sink, N))
        L -= n
        N += n
    n //= 2
    v -= 1

print(v_sink, len(edges))
for e in edges:
    print(*e)


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

signed main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i=0; i < n; i++) cin >> v[i];
    vector<int> suff(n+1), pref(n+1);
    suff[n] = 0;
    pref[0] = 0;
    vector<int> kek;
    vector<int> indixes;
    int t = 0;
    for (int i=n-1; i >= 0; i--){
        int ind = ((int) kek.size()) - 1;
        while (kek.size() && indixes.size() && v[i] > kek.back()){
            for (int j=indixes.back(); j < kek.size(); j++){
                kek[j] *= 4;
                t+=2;
            }
            if (kek[indixes.back()] * 4 > kek[indixes.back() - 1]) indixes.pop_back();
        }
        int r = 1, s = 0;
        while (kek.size() && r*kek.back() < v[i]){
            r *= 4, s++;
        }
        t += 2*((n-1)-i)*s;
        if (kek.size() && 4*v[i] <= kek.back()) indixes.push_back((n-1)-i);
        kek.push_back(v[i]);
        suff[i] = t;
    }
    kek.clear(), indixes.clear(), t=0;
    reverse(v.begin(), v.end());
    for (int i=n-1; i >= 0; i--){
        t++;
        int ind = ((int) kek.size()) - 1;
        while (kek.size() && indixes.size() && v[i] > kek.back()){
            for (int j=indixes.back(); j < kek.size(); j++){
                kek[j] *= 4;
                t+=2;
            }
            if (kek[indixes.back()] * 4 > kek[indixes.back() - 1]) indixes.pop_back();
        }
        int r = 1, s = 0;
        while (kek.size() && r*kek.back() < v[i]){
            r *= 4, s++;
        }
        t += 2*((n-1)-i)*s;
        if (kek.size() && 4*v[i] <= kek.back()) indixes.push_back((n-1)-i);
        kek.push_back(v[i]);
        pref[n-i] = t;
    }
    int ans = 1e18;
    for (int i=0;i<=n;i++) ans = min(ans, pref[i] + suff[i]);
    cout << ans;
    return 0;
}


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

using namespace std;

void solve()
{
	int A, B, C;
	cin >> A >> B >> C;
	int ans = min(A, B);
	for (;;)
	{
		if (A % ans == 0 && B % ans == 0)
		{
			C--;
			if (!C) break;
		}
		ans--;
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main(){

	int N;
	cin >> N;
  	
  	string str = "";
  	while(N!=0){
    	/*Nを2で割った余りを求める*/
      	int r = N%2;
      	if(r < 0)r+=2;//Nがマイナスだとｒがマイナスになったりするので2を足す。
      	
      	/*Nから余りを取り除いて-2で割る*/
    	N=(N-r)/(-2);
      	
      	/*答えに追加*/
    	str += (char)('0'+r);
    }
  	/*向きが逆なので反転*/
  	reverse(str.begin(),str.end());
  	if(str=="")str="0";//N=0の時は～文字列になってしまうので例外処理
  	cout << str << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	int n;
	double students[1000] = {0},sum,m,div;

	while(true){
		scanf("%d",&n);
		if(n == 0) break;
		div = sum = 0;
		for(int i = 0; i < n; i++){
			scanf("%lf",&students[i]);
			sum += students[i];
		}
		m = sum/n;
		for(int i = 0; i < n;i++){
			div += (students[i] - m)*(students[i] - m);
			students[i] = 0;
		}
		printf("%.8lf\n",sqrt(div/n));
	}
}



Measured memory_bytes: 2720
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b)*c/2;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    char a, b;
    cin >> a >> b;
    if(a == b) {
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int k,n;
    cin>>k>>n;
    int mx=0;
    int arr[n];
    loop(n,i,0)
        cin>>arr[i];
    loop(n,i,0){
        if(i==n-1)
            max_self(mx,k-arr[i]+arr[0]);
        else
            max_self(mx,arr[i+1]-arr[i]);
    }
    cout<<k-mx<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 4440
package main

import (
	"fmt"
	"sort"
	//"math"
	// "sort"
	//"regexp"
)

var n, k, a, ans int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)
	l := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		l[i] = a
	}
	sort.Slice(l, func(i, j int) bool { return l[i] > l[j] })
	for i := 0; i < k; i++ {
		ans += l[i]
	}
	fmt.Printf("%d\n", ans)
}


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

int main() {
	int N;
	cin >> N;
	int p[N];
	for (int i = 0; i < N; i++) cin >> p[i];
	long long dp[N - 1][21] = { 0 };
	dp[0][p[0]] = 1;
	for (int i = 1; i < N - 1; i++) {
		for (int j = 0; j < 21; j++) {
			if (j - p[i] >= 0) {
				dp[i][j] += dp[i - 1][j - p[i]];
			}
			if (j + p[i] <= 20) {
				dp[i][j] += dp[i - 1][j + p[i]];
			}
		}
	}
	cout << dp[N - 2][p[N - 1]] << endl;
}


Measured memory_bytes: 3108
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 2**(n//2)%mod
if n % 2 == 0:
    l = n ** 2
else:
    l = (n - 1) * (n + 1)
if sum(a) == l // 2:
    print(ans)
else:
    print(0)


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

int main() {
	int a, b, c, t;
	cin >> a >> b >> c;
	
    if (a > b){
        t = a;
        a = b;
        b =t;
    }

    if (b > c){
        t = b;
        b = c;
        c = t;
    }

    if (a > b){
        t = a;
        a = b;
        b =t;
    }
    cout << a << " " << b << " " << c << endl;

	return 0;
}


Measured memory_bytes: 3068
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int len[9],n;
inline int Ocost(int x,int gol)
{
    int ret=0;
    int one=__builtin_popcount(x);
    ret=(one-1)*10;
    int sum=0;
    f(i,0,n-1)
    {
        if(x & (1<<i))
        {
           sum+=len[i];
        }
    }
    int gap=abs(gol-sum);
    ret+=gap;
    return ret;

}
bitset<5>chk;
inline pi yo(int x,int g1,int g2)
{
    int nx=0,ny=0;
    pi ret;
    ll mn=inf;
    for(int i=x;i;i=(i-1)&x)
    {
        nx=0,ny=0;
        for(int k=0;k<n;k++)
        {
             if(!(x & (1<<k)))continue;
            if(i & (1<<k))nx+=(1<<k);
            else ny+=(1<<k);
        }
        if(__builtin_popcount(nx)<1 || __builtin_popcount(ny)<1)continue;
        pi tmp;
        tmp.fi=Ocost(nx,g1);
        tmp.si=Ocost(ny,g2);
        int val=tmp.fi+tmp.si;
        if(val<=mn)
        {
            mn=val;
            ret=tmp;
        }
    }
    return ret;
}
 main()

{

    int a,b,c;
    cin>>n>>a>>b>>c;
    f(i,0,n-1)cin>>len[i];
    int mx=(1<<n)-1;
    ll ses=inf;
    f(i,0,mx)
    {
       int one=__builtin_popcount(i);
       if(one<3)continue;
       for(int j=i;j;j=(j-1)&i)
       {
            int p=0,q=0;
            for(int k=0;k<n;k++)
            {
                if((i & (1<<k))==0)continue;
                if((j & (1<<k)))
                {
                     p+=(1<<k);
                }
                else q+=(1<<k);
            }
            if(__builtin_popcount(p)<1 || __builtin_popcount(q)<2)continue;
           ll x=Ocost(p,a);
           pi tmp=yo(q,b,c);
           ll y=tmp.fi;
           ll z=tmp.si;
           ses=min(ses,x+y+z);

       }
    }
    cout<<ses<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;
typedef array<int, 20001> A;

constexpr int MAX = 1e9;
int N;
A p, a, b, ab, r;

// p 2 3 1
// r 1 2 3
//
// p 1 2 3
// r 3 1 2

int main(void) {
    cin >> N;
    ab[0] = 1;

    for (int i = 1; i <= N; i++) {
        cin >> p[i];
        r[p[i]] = i;
    }
    for (int i = 1; i <= N; i++) {
        cout << 30000 * r[p[i]];
        cout << ' ';
    }
    cout << endl;
    for (int i = 1; i <= N; i++) {
        cout << 30000 * (N - i + 1) + r[i];
        cout << ' ';
    }
    cout << endl;
    //for (int i = 1; i <= N; i++) {
    //    cout << 30000 * (N + 1) + r[i];
    //    cout << ' ';
    //}
    //cout << endl;

    return 0;
}


Measured memory_bytes: 768
n = int(input())
ans = int(input())
 
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
 
def lcm(x,y):
    return (x*y//gcd(x,y))
 
for i in range(n-1):
    t = int(input())
    ans = lcm(ans,t)
print(ans)

Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    k = I()
    a,b = LI()
    for i in range(a,b+1):
        if i%k == 0:
            print("OK")
            return
    print("NG")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 67224
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

class UnionFind {
  std::vector<int> p;
public:
  UnionFind(int n) : p(n, -1) {}
  int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) std::swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    return true;
  }
};
int main(void)
{
  LL n;
  cin >> n;
  vector<pair<LL,LL>> x(n),y(n);
  UnionFind uf(n);
  REP(i,n) cin >> x[i].first >> y[i].first;
  REP(i,n) x[i].second=y[i].second=i;
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  vector<tuple<LL,LL,LL>> cost;
  REP(i,n-1) {
    cost.emplace_back(x[i+1].first-x[i].first,x[i].second,x[i+1].second);
    cost.emplace_back(y[i+1].first-y[i].first,y[i].second,y[i+1].second);
  }
  sort(cost.begin(),cost.end());
  LL answer=0ll;
  for(auto t:cost) {
    LL c,l,r;
    tie(c,l,r)=t;
    if(uf.unite(l,r)) answer+=c;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 12016
import math
a,b,h,m = list(map(int,input().split()))
a1 = 30 * (h + (m / 60))
a2 = 6 * m
a3 = min(abs(360 - abs(a1 - a2)), abs(a1 - a2))
c = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * (math.cos(math.radians(a3)))))
print(c)

Measured memory_bytes: 9384
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	int a,b;cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,i,a,b,x,y,lt,rt,d,t;
bool f = 1;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,n){
        cin>>t>>a>>b;
        d = abs(a - x) + abs(b - y);
        rt = t - lt;
        if(rt < d)
            f = 0;
        else{
            if(rt%2 != d%2)
                f = 0;
        }
        x = a;
        y = b;
        lt = t;
    }
    cout<<(f ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i;
    char st,al[53] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
    do{
        scanf("%c", &st);
        
        for(i=0;i<52;i++)
            if(al[i] == st){
                st = al[ (i+26)%52 ];
                break;
            }
        
        printf("%c", st);
        
    }while(st != '\n');
    
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,k,dp[3005][3005][4],a[3005][3005];
int32_t main(){
CODE_START;
cin>>n>>m>>k;
for(ll i=1;i<=k;i++)
{
    ll x,y,z;
    cin>>x>>y>>z;
    a[x][y]=z;
}
for(ll i=1;i<=n;i++)
{
    for(ll j=1;j<=m;j++)
    {
        dp[i][j][0]=max({dp[i][j][0],dp[i][j-1][0],dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]});
        dp[i][j][1]=max(dp[i][j][1],dp[i][j-1][1]);
        dp[i][j][2]=max(dp[i][j][2],dp[i][j-1][2]);
        dp[i][j][3]=max(dp[i][j][3],dp[i][j-1][3]);
        if(a[i][j]!=0){
                dp[i][j][3]=max(dp[i][j][3],dp[i][j][2]+a[i][j]);
        dp[i][j][2]=max(dp[i][j][2],dp[i][j][1]+a[i][j]);
            dp[i][j][1]=max(dp[i][j][1],dp[i][j][0]+a[i][j]);
            //dp[i]
        }
    }
}
cout<<max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3])))<<endl;
}


Measured memory_bytes: 355504
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 5010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int a[MAXN];

int main()
{
	
	for (int i = 0; i < 4; ++ i)
		scanf("%d", &a[i]);
	sort(a, a+4);
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
		puts("YES");
	else
		puts("NO");
	
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

tmp = 999999999999999


def calc_area(H, W):
    piece_1 = i * W
    piece_2 = int(W / 2) * (H - i)
    piece_3 = int(W / 2 + 0.9) * (H - i)
    holi = max(piece_1, piece_2, piece_3) - min(piece_1, piece_2, piece_3)

    piece_2 = W * int((H - i) / 2)
    piece_3 = W * int((H - i) / 2 + 0.9)
    ver = max(piece_1, piece_2, piece_3) - min(piece_1, piece_2, piece_3)
    return min(tmp, holi, ver)


for i in range(0, H + 1):
    holi = calc_area(H, W)
    ver =  calc_area(W, H)
    tmp = min(tmp, holi, ver)


for i in range(0, W + 1):
    holi = calc_area(H, W)
    ver =  calc_area(W, H)
    tmp = min(tmp, holi, ver)

print(tmp)

Measured memory_bytes: 3064
/*ex9-2 C- Unification
ryo_1129*/

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100000
//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

void pop(node **first);
void push(node **first, char elem);

int main(void){
    int counter=0;
    char cube[SIZE+1];
    scanf("%s", cube);
    //最初のノードの指す先
    node *first = NULL;
    //キューブを積み上げていく
    for(int i=0; cube[i] != '\0'; i++){
        //同じ色が連続するか、キューブがない場合
        if(first == NULL || first->elem == cube[i]){
            push(&first, cube[i]);
        //色が異なる場合
        }else{
            pop(&first);
            counter += 2;
        }
    }
    printf("%d\n",counter);

    return 0;
}

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り除く
void pop(node **first){
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    *first = tmp->next;
    //取り除いたノードのメモリを解放
    free(tmp);
}

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

#include <boost/rational.hpp>

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

const int INF = 1 << 30;

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

  int N, ma, mb;
  cin >> N >> ma >> mb;

  int mincost = INF;
  vector<tuple<int, int>> x_minus, x_plus;
  int xmax = 0;
  REP(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    int x = a * mb - ma * b;
    if (x == 0) {
      mincost = min(mincost, c);
    } else if (x < 0) {
      x_minus.emplace_back(c, -x);
    } else {
      x_plus.emplace_back(c, x);
    }
    if (xmax < abs(x)) {
      xmax = abs(x);
    }
  }

  // dp_*[i] := mincost of total weight i.
  vector<int> dp_plus(xmax + 1, INF), dp_minus(xmax + 1, INF);
  dp_plus[0] = dp_minus[0] = 0;
  for (auto& cx : x_plus) {
    int ci = get<0>(cx), xi = get<1>(cx);
    for (int w = xmax - xi; w >= 0; --w) {
      dp_plus[w + xi] = min(dp_plus[w + xi], dp_plus[w] + ci);
    }
  }
  for (auto& cx : x_minus) {
    int ci = get<0>(cx), xi = get<1>(cx);
    for (int w = xmax - xi; w >= 0; --w) {
      dp_minus[w + xi] = min(dp_minus[w + xi], dp_minus[w] + ci);
    }
  }
  for (int w = 1; w <= xmax; ++w) {
    int wp = dp_plus[w], wm = dp_minus[w];
    if (wp != INF && wm != INF && mincost > wp + wm) {
      mincost = wp + wm;
    }
  }
  cout << (mincost == INF ? -1 : mincost) << endl;
}

Measured memory_bytes: 256
n, q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for _ in range(q)]

ac = [0] * n
for itr, (i, j) in enumerate(zip(S, S[1:])):
  if i + j == "AC":
    ac[itr+1] = ac[itr] + 1
  else:
    ac[itr+1] = ac[itr]

for l, r in lr:
  print(ac[r-1] - ac[l-1])

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

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    mat a(2,vec(N));
    rep(i,2) rep(j,N) cin>>a[i][j];
    ll ans = 0;
    rep(j,N) ans += a[1][j];
    ans += a[0][0];
    ll temp = ans;
    reps(i,1,N){
        temp += a[0][i] - a[1][i-1];
        ans = max(ans, temp);
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,m,x;cin>>n>>m>>x;
  int a[m+10];
  rep(i,0,m)cin>>a[i];

  int l=lower_bound(a,a+m,x)-a;


  out(min(l,m-l));

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    string s;
    cin>>s;
    if(s.length() < 6){cout<<"No\n";return ;}
    if(s[2] == s[3] && s[4] == s[5])cout<<"Yes\n";
    else cout<<"No\n";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n+1), as(n+1);
    rep(i, n){
        cin >> a[i];
        as[i] += a[i];
        as[i+1] += as[i];
    }
    bool NextIsPlus = true;
    ll PlusStartCnt = 0, PlusAdd = 0;
    ll MinusStartCnt = 0, MinusAdd = 0;

    rep(i, n){
        if(NextIsPlus){
            if(as[i]+PlusAdd <= 0){
                ll tmp = 1-(as[i]+PlusAdd);
                PlusStartCnt += abs(tmp);
                PlusAdd += tmp;
            }
            if(as[i]+MinusAdd >= 0){
                ll tmp = -1-(as[i]+MinusAdd);
                MinusStartCnt += abs(tmp);
                MinusAdd += tmp;
            }
        }
        else{
            if(as[i]+PlusAdd >= 0){
                ll tmp = -1-(as[i]+PlusAdd);
                PlusStartCnt += abs(tmp);
                PlusAdd += tmp;
            }
            if(as[i]+MinusAdd <= 0){
                ll tmp = 1-(as[i]+MinusAdd);
                MinusStartCnt += abs(tmp);
                MinusAdd += tmp;
            }
        }
        NextIsPlus ^= 1;
    }
    cout << min(PlusStartCnt, MinusStartCnt) << endl;
}

Measured memory_bytes: 4784
import sys

# import re
import math
import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
MOD2 = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    a, b, h, m = ns()

    short_deg = (h * 30 + 30 * m / 60)
    long_deg = 6 * m

    short_x = a * math.sin(math.radians(short_deg))
    short_y = a * math.cos(math.radians(short_deg))
    long_x = b * math.sin(math.radians(long_deg))
    long_y = b * math.cos(math.radians(long_deg))

    ans = ((short_x - long_x) ** 2 + (short_y - long_y) ** 2) ** (1 / 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10648