akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def modpow (a, N):
    res = 1
    while (N>0):
        if N & 1:
            res = res * a % MOD
        a = a * a % MOD
        N >>= 1
    return res

def solve(N: int, K: int):
    ans = 0

    x = [1] * (K+1)

    for i in range(K, 0, -1):
        if i * 2 <= K:
            x[i] = modpow(K//i, N)
            j = 2
            while i * j <= K:
                x[i] -= x[i*j]
                j += 1
            ans += x[i] * i % MOD
        else:
            ans += i
    print(ans%MOD)


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11160
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let w: i64 = input();
    let h: i64 = input();
    let x: i64 = input();
    let y: i64 = input();

    let a = w as f64 * h as f64 * 0.5;
    let ok = x == w / 2 && w % 2 == 0 && y == h / 2 && h % 2 == 0;
    println!("{} {}", a, ok as i32);
}


Measured memory_bytes: 4352
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next();
                        for (int i = 0; i < S.length() - 1; i++) {
                                if (S.charAt(i) == S.charAt(i + 1)) {
                                        System.out.println((i + 1) + " " + (i + 2));
                                        return;
                                }
                        }
                        for (int i = 0; i < S.length() - 2; i++) {
                                if (S.charAt(i) == S.charAt(i + 2)) {
                                        System.out.println((i + 1) + " " + (i + 3));
                                        return;
                                }
                        }
                        System.out.println("-1 -1");
                }
        }
}

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

namespace ConsoleApp15
{
    class Class178
    {
        static void Main()
        {
            string S = Console.ReadLine();
            for(int i = 97; i <= 122; i++)
            {
                if (S.Contains((char)i)) continue;
                S += ((char)i).ToString();
                Console.WriteLine(S);
                return;
            }
            for(int i = 0; i < S.Length; i++)
            {
                string s = S.Substring(0, S.Length - i-1);
                for(int j = S[S.Length - 1 - i]+1; j <= 122; j++)
                {
                    if (s.Contains((char)j))continue;
                    Console.WriteLine(s+((char)j).ToString());
                    return;
                }
            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin>>n;
	int cnt=0, mx=0;
	rep(i, n){
		int c, d;
		cin>>c>>d;
		if(c==d) cnt++;
		else cnt=0;

		mx=max(mx, cnt);
	}

	if(mx>=3) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll h,a;
    cin>>h>>a;
    ll ans=(h/a) + ((h%a)!=0);
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        int standard = 1;
        while (true) {
          int target = standard * 2;
          if (target <= n) {
            standard = target;
          } else {
            break;
          }
        }
        
		// 出力
		System.out.println(standard);
	}
}

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

using namespace std;

long long num_comb(long long n, long long m);

int main()
{
	long long n, m;
	cin >> n >> m;
	cout << num_comb(n, m) << endl;
	return 0;
}

long long num_comb(long long n, long long m) {
	long long num;
	if(m <= 2*n)
		num = m / 2;
	else
		num = (m - 2 * n) / 4 + n;
	return num;
}



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

int X;

int main() {
    cin >> X;
    for (long long int i = 0; i * i <= X; i++) {
        for(long long int j = 0; j <= i; j++) {
            long long int i5 = i * i * i * i * i;
            long long int j5 = j * j * j * j * j;
            if (i5 - j5 == X) {
                cout << i << " " << j << endl;
                return 0;
            }
            else if (i5 + j5 == X) {
                cout << i << " " << -j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
import org.w3c.dom.ls.LSOutput;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] values = new long[N];
        for(int i = 0; i < N; i++) {
            values[i] = scanner.nextLong();
        }
        Arrays.sort(values);
        for(int i = 0; i < values.length - 1; i++) {
            if(values[i] == values[i + 1]) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


Measured memory_bytes: 65344
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  int ans=0;
  loop(i,1,n+1){
    int tmp=i;
    int t=0;
    while(tmp%2==0)tmp/=2,t++;
    ans=max(ans,t);
  }
  cout<<(1<<ans)<<endl;
}


Measured memory_bytes: 256
L,R=map(int,input().split())
_min=2018
if L==0:
  _min=0
else:  
  for l in range(L,L+2019):
    if l>R:
      break
    for r in range(l+1,l+2020):
      if r>R:
        break
      m=(l*r)%2019
      if _min>m:
        _min=m
print(_min)    



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
bool dis[10];
bool chk(int x){
	while(x){
		int d=x%10;
		x/=10;
		if(dis[d])
		   return false;
	}
	return true;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		int mm;
		cin>>mm;
		dis[mm]=true;
	}
	for(int i=n;i<=99999;i++){
		if(chk(i)){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
class Qsort
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int h = int.Parse(str[0]);
        int w = int.Parse(str[1]);
        int a = int.Parse(str[2]);
        int b = int.Parse(str[3]);
        int[,] s = new int[h, w];

        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);


        for (int i = 0; i < b; i++)
        {
            for (int j = 0; j < a; j++)
            {
                Console.Write(1);
            }
            for (int j = a; j < w; j++)
            {
                Console.Write(0);
            }
            Console.WriteLine();
        }







        for (int i = b; i < h; i++)
        {
            for (int j = 0; j < a; j++)
            {
                Console.Write(0);
            }
            for (int j = a; j < w; j++)
            {
                Console.Write(1);
            }
            Console.WriteLine();
        }
        Console.Out.Flush();





    }
}

Measured memory_bytes: 18008
#include<iostream>
using namespace std;
int n,m;
int p[1<<17],r[1<<17];
int l[1<<17];
int find(int a){return p[a]-a?p[a]=find(p[a]):a;}
void unite(int a,int b)
{
	int pa=find(a),pb=find(b);
	if(pa==pb)return;
	if(r[pa]<r[pb])
	{
		p[pa]=pb;
	}
	else
	{
		p[pb]=pa;
		if(r[pa]==r[pb])r[pa]++;
	}
}
main()
{
	cin>>n>>m;
	for(int i=0;i<=n||i<=m;i++)l[i]=-1,p[i]=i;
	for(int i=0;i<n;i++)
	{
		int k,a;
		cin>>k;
		for(int j=0;j<k;j++)
		{
			cin>>a;
			if(l[a]<0)l[a]=i;
			else unite(i,l[a]);
		}
	}
	bool f=true;
	for(int i=0;++i<n;)f&=find(0)==find(i);
	cout<<(f?"YES":"NO")<<endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n, a[200001];
    cin>>n;
    for(long i=1;i<=n;i++) cin>>a[i];
     sort(a+1,a+n+1);
     for(long i=1;i<n;i++){
        if(a[i]==a[i+1]){
            cout<<"NO";
            return 0;
        }
     }
     cout<<"YES";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a,b;
  cin >> a >> b;
  cout<< (b-1+a-2)/(a-1)  <<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n,a,b=mii()
arr=limii()
cnt=0
for i in range(n-1):
    if (arr[i+1]-arr[i])*a>b:
        cnt+=b
    else:
        cnt+=(arr[i+1]-arr[i])*a
print(cnt)

Measured memory_bytes: 87788
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    
    int K, X; cin >> K >> X;
    X -= (K-1);
    FOR(i, X, X+2*K-1) {
		cout << i << " ";
	} cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x[10], y[10];

double distance(int i, int j){
  //cout<<x[i]<<","<<y[i]<<endl;
  return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) );
}

int N1(int i){
  if(i==1){
    return 1;
  }else{
    return i * N1(i-1);
  }
}

int main(){
  int n;cin>>n;
  vector<int> a;
  for(int i=0; i<n; i++){
    cin>>x[i]>>y[i];
    a.push_back(i);
  }

  double ans = 0;
  do{
    for(int i=0; i<n-1; i++){
      //cout<<"d("<<i<<","<<i+1<<")";
      //cout << distance(a[i], a[i+1])<<endl;
      ans += distance(a[i], a[i+1]);
    }
  }while(next_permutation(a.begin(), a.end()));

  int all = N1(n);
  cout<<fixed<<setprecision(10);
  cout<<ans/all<<endl;
}

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

typedef long long int ll;
const int maxn = 10000 + 5;
int n;
ll a[maxn], b[maxn];
ll total_a = 0, total_b = 0;
ll total = 0;
ll D;

bool solve()
{
	ll cnt1 = 0, cnt2 = 0;
	for(int i = 0; i < n; i++) 
	{
		if(a[i] > b[i]) cnt1 += a[i] - b[i];
		else if(a[i] < b[i]) cnt2 += (b[i]-a[i])/2;
	}
	if(cnt1 - cnt2 > 0) return false;
	else return true;
}

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++) { scanf("%lld", &a[i]); total_a += a[i]; }
	for(int i = 0; i < n; i++) { scanf("%lld", &b[i]); total_b += b[i]; }
	D = total_b - total_a;
	if(D < 0) printf("No\n"); 
	else
	{
		if(solve()) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		if(13<=a) {
			System.out.println(b);
		}else if(6<=a) {
			System.out.println(b/2);
		}else {
			System.out.println(0);
		}
	}
}

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

int main(){
    int N, M;
    int L, R;
    cin >> N >> M;
    int max = 1;
    int min = N;
    for(int i = 0; i < M; i++){
        cin >> L >> R;
        if(min > R){
            min = R;
        }
        if(max < L){
            max = L;
        }
    }

    int gate;
    if(min < max){
        gate = 0;
    } else {
        gate = min - max + 1;
    }
    cout << gate << endl;
    return 0;
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
ll a[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, (1 << n))
        cin >> a[i];

    return true;
}

void umx(pair<ll, ll>& mx, ll x) {
    if (x >= mx.f) {
        mx.s = mx.f;
        mx.f = x;
    } else if (x > mx.s) {
        mx.s = x;
    }
}

void solve() {
    auto ans = a[0] + a[1];
    cout << ans << endl;

    for (int i = 2; i < (1 << n); ++i) {
        pair<ll, ll> mx = {-1, -1};

        for (int j = i; j >= 0; j = ((j - 1) & i)) {
            umx(mx, a[j]);

            if (j == 0)
                break;
        }

        cout << (ans = max(ans, mx.f + mx.s)) << endl;
    }
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



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

int H,W;
int t[1000][1000];
int v[1000][1000];

queue<int> qy,qx;
int d[1000][1000];

int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};

int main(){
  
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
      scanf("%d",&t[i][j]);

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<4;k++){
        int y=i+dy[k];
        int x=j+dx[k];
        if(y<0||H<=y)continue;
        if(x<0||W<=x)continue;
        if(t[i][j]<t[y][x]){
          v[y][x]++;
        }
      }
    }
  }

  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(v[i][j]==0){
        qy.push(i);
        qx.push(j);
        d[i][j]=qy.size();
      }
    }
  }
  
  int ans=0;
  while(!qy.empty()){
    int y=qy.front();qy.pop();
    int x=qx.front();qx.pop();
    if(d[y][x]==-1)ans++;
    
    for(int i=0;i<4;i++){
      int ny=y+dy[i];
      int nx=x+dx[i];
      if(ny<0||H<=ny)continue;
      if(nx<0||W<=nx)continue;
      v[ny][nx]--;
      if(v[ny][nx]==0){
        qy.push(ny);
        qx.push(nx);
      }
      if(d[ny][nx]==-1){
        //continue;
      }else if(d[ny][nx]==0){
        d[ny][nx]=d[y][x];
      }else{
        d[ny][nx]=(d[ny][nx]==d[y][x]?d[y][x]:-1);
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 15036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

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

  int cnt = 1;
  for(int i=1;i<S.size();i++){
    if(S[i-1] != S[i]){
      ++cnt;
    }
  }
  
  cout << cnt - 1 << endl;
  return 0;
}


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

#define all(x) x.begin(),x.end()
#define LB(V,x) lower_bound(all(V),x)-V.begin()

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vll = vector<int64>;
using ll = int64;

void Main(){
    int32 N, ans, a;
    cin >> N >> ans;
    while(--N){
        cin >> a;
        ans = __gcd(ans,a);
    }
    cout << ans << endl;
}

int main(){cin.tie(0);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
n=int(input()) 
lst=list(map(int,input().split()))
lst.sort()
#print(lst) 
a=[] 

for i in range(n): 
	if i==0: 
		#print(lst[i]) 
		a.append(lst[i]) 
	else: 
		#print(lst[i]) 
		a.append((a[-1]+lst[i])/2)   
print(a[-1])


Measured memory_bytes: 2940
#include <climits>
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

int main() {
  int n, max_n = 0, second_n = 0, max_count = 0;
  cin >> n;
  vector<int> a(n, 0);

  for (int i=0; i<n; i++) {
    cin >> a[i];
    max_n = max(max_n, a[i]);
  }

  for (int b: a) {
    if (b == max_n) {
      max_count++;
      continue;
    }
    second_n = max(second_n, b);
  }

  /*
  cout << max_n << endl;
  cout << second_n << endl;
  cout << max_count << endl;
  */

  for (int i=0; i<n; i++) {
    if (a[i] == max_n && max_count == 1) {
      cout << second_n << endl;
    } else {
      cout << max_n << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll k, q;
    cin >> k >> q;
    vector<ll> d0(k);
    REP(i, k) cin >> d0[i];

    REP(i, q) {
        ll n, x, mo;
        cin >> n >> x >> mo;
        x %= mo;

        ll sum = 0;
        vector<ll> d(d0);
        REP(j, k) {
            d[j] %= mo;
            sum += d[j];
        }

        ll ret = 0;
        REP(j, k) if(d[j] == 0) ret += (n-1)/k + (j < (n-1)%k);
        dump(ret);
        
        ll last = (n-1)/k*sum + x;
        dump(last, (n-1)/k, sum);
        REP(j, (n-1)%k) last += d[j];
        ret += last/mo - x/mo;
        dump(last, x, last/mo, x/mo, ret);
        
        cout << n-1 - ret << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let k = read_as_vec::<i32>()[0];
    let x = read_as_vec::<i32>();

    println!("{}",
             x.into_iter().map(|p| 2*cmp::min((k-p).abs() , (p).abs())).sum::<i32>()
    );
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;


const int maxn = 405;
int a[maxn],dp[maxn][maxn];
int n;
int solve(int l,int r)
{
	if( l>r )return 1e15;
	if( l==r ) return dp[l][r]=0;
	if( dp[l][r]!=-1 )return dp[l][r];
	dp[l][r]=1e15;
	for(int i=l;i<r;i++)
	{
		dp[l][r]=min(dp[l][r],solve(l,i) + solve(i+1,r) + a[i]-a[l-1] + a[r]-a[i] );
	}
	return dp[l][r];
}
int32_t main()
{
	IOS
	memset(dp,-1,sizeof(dp));
	cin >> n;
	a[0]=0;
	for(int i=1;i<=n;i++)
	cin>>a[i],a[i]+=a[i-1];
	
	cout << solve(1,n) << endl;
	
}


Measured memory_bytes: 1536
#include <stdio.h>

int main(void) {
  int a[10][10], i, j;
  long int t;
  while (scanf("%ld", &t) != EOF) {
    for (i = 9; i >= 0; i--) {
      a[0][i] = t % 10;
      t /= 10;
    }

    for (i = 1; i < 10; i++)
      for (j = 0; j < 10 - i; j++)
	a[i][j] = (a[i-1][j] + a[i-1][j+1]) % 10;

    printf("%d\n", a[9][0]);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	vector<ll> c_(n + 1, 0);
	rep(i, n) {
		int d = lower_bound(c.begin(), c.end(), b[i] + 1) - c.begin();
		c_[i + 1] = n - d;
	}
	rrep(i, n + 1) c_[i] += c_[i - 1];
	ll ans = 0;
	rep(i, n) {
		int d = lower_bound(b.begin(), b.end(), a[i] + 1) - b.begin();
		ans += c_[n] - c_[d];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5288
#include <stdio.h>

using namespace std;


int main(){
	char buf[21];
	int length=0;

	scanf("%s",buf);
	for(int i=0;buf[i]!='\0';i++)length++;
	for(int i=length-1;i>=0;i--)printf("%c",buf[i]);
	printf("\n");

    return 0;
}



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

bool has3(int x){
  while(x){
    if (x % 10 == 3)return true;
    x/=10;
  }
  return false;
}

void call(int n){
  for(int x=1; x<=n; x++){
    if(x%3==0 || has3(x)){
      cout << ' ' << x;
    }
  }
  cout << endl;
}

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

  call(n);

  return 0;
}


Measured memory_bytes: 3096
import numpy as np

N = int(input())
same_dict = {}
keys = []

inputs = []
for i in range(N):
    S, P = input().split(" ")
    P = int(P)
    inputs.append([S, P, i])

pairs = sorted(inputs, key=lambda x: x[0])
#print("pairs", pairs)

before_key = pairs[0][0]
tmp_indexes = [pairs[0][2]]
tmp_vals = [pairs[0][1]]

out = []
for pair in pairs[1:]:
    tmp_key, val, index = pair
    #print(before_key, tmp_key)
    if before_key == tmp_key:
        tmp_indexes.append(index)
        tmp_vals.append(val)
    else:
        both_l = []
        ss = [[elm1, elm2] for elm1, elm2 in zip(tmp_indexes, tmp_vals)]
        ss = sorted(ss, key=lambda x: -x[1])
        #print("ss", before_key, ss)
        for a, b in ss:
            out.append(a)

        tmp_vals = [val]
        tmp_indexes = [index]

    before_key = tmp_key

 
#print("index", tmp_indexes)
#print("vals", tmp_vals)
ss = [[elm1, elm2] for elm1, elm2 in zip(tmp_indexes, tmp_vals)]
ss = sorted(ss, key=lambda x: -x[1])
#print("ss", tmp_key, ss)
for a, b in ss:
    out.append(a)

for elm in out:
    print(elm+1)



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

/*
  セグメント木
  コンストラクタには要素数を渡す
  * 根 : 1
  * 左からx番目の葉 : x+N
  * iの親のindex : i/2
  * iの子のindex : i*2+0, i*2+1
  * iの兄弟(sibling) : i^1
  * iの深さ(depth) : log_2 iの整数部分
  * iの区間幅(width) : N/highest(i)
  * iの区間の左端 : (i-highest(i))*width(i)
  */

// Range Minimum Query
typedef ll dat_t;
dat_t const inf = (1LL<<31)-1;
dat_t const init = (1LL<<31)-1;
struct segment_tree {
    vector<pair<dat_t,int>> dat;
    int n;
    segment_tree(int n_){
        n = 1;
        while(n < n_) n<<=1;
        dat.resize(n*2);
        for(int i=n; i<n+n; i++){
            dat[i] = make_pair(init,i); // -infをdat[i]にするとvectorからのコンストラクタになる
        }
        for(int i=n-1; i>=1; i--){
            dat[i] = min(dat[i<<1], dat[i<<1|1]);
        }
    }

    // bottom-up
    void set(int k, dat_t x){
        int i = n+k; // leaf
        dat[i] = make_pair(x,k);
        while(i != 1){ // 1 is root
            dat[i>>1] = min(dat[i], dat[i^1]);
            i>>=1;
        }
    }
    // top-down
    pair<dat_t,int> get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return make_pair(inf,0);
        if(a <= l && r <= b) return dat[k];
        pair<dat_t,int> v1 = get(a,b,k<<1,l,(l+r)/2);
        pair<dat_t,int> v2 = get(a,b,k<<1|1,(l+r)/2,r);
        return min(v1,v2);
    }
    pair<dat_t,int> get(int a, int b){
        return get(a,b,1,0,n);
    }
};

int main(){
#ifdef LOCAL
    freopen("in","r",stdin);
#endif
    int n,q;
    while(cin >> n >> q){
        segment_tree tree(n);
        for(int i=0;i<q;i++){
            int c,x,y;
            cin >> c >> x >> y;
            if(c==0){
                tree.set(x,y);
            } else {
                cout << tree.get(x,y+1).first << endl;
            }
        }
    }
}

Measured memory_bytes: 5152
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);

		   int [][] ali = new int[4][13];
	        String Card[]= {"S","H","C","D"};

	        int yy = scan.nextInt();
	        String kk ;
	        int zz;
	        int i;
	        int q;
	        for(i = 0; i < yy ; i++){
	        	kk= scan.next();
	        	zz= scan.nextInt();
	        	if(kk.equals(Card[0])){
	        		q=0;
	        		ali[q][zz-1]=213;
	        	}else if(kk.equals(Card[1])){
	        		q=1;
	        		ali[q][zz-1]=213;
	        	}
	        	else if(kk.equals(Card[2])){
	        		q=2;
	        		ali[q][zz-1]=213;
	        	}
	        	else if(kk.equals(Card[3])){
	        		q=3;
	        		ali[q][zz-1]=213;
	        	}

	        }



	        for ( i= 0; i<4; i++){
	        	for (int j=0; j<13;j++){
	        		if  (ali[i][j]!= 213){
	        			System.out.println(Card[i]+ " " + (j +1));
	        		}
	        		}
	        	}
	        }

	}

Measured memory_bytes: 26412
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int N=in.nextInt();
    int K=in.nextInt();
    int l=(int)Math.ceil((Math.log(N)/Math.log(K)));
if(l==0)
System.out.println("1");
else
System.out.println(l);
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	vi vs;
	vi vss = {1, 4, 7, 9};
	REP(i, 4) {
		int n; cin >>n;
		vs.pb(n);
	}
	sort(ALL(vs));
	if (vs == vss) p("YES");
	else p("NO");
}



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

from collections import deque

n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]

x_list = {}
y_list = {}
for i in range(1,10**5+1):
    x_list[i] = set()
    y_list[i] = set()

for i in range(n):
    x,y = xy[i]
    x_list[x].add(i)
    y_list[y].add(i)

remain = set(range(n))
ans = 0
while(len(remain) > 0):
    d = deque()
    d.append(remain.pop())
    num = 0
    xs = set()
    ys = set()
    while(len(d) > 0):
        tmp = d.pop()
        x,y = xy[tmp]
        num += 1
        xs.add(x)
        ys.add(y)
        while(len(x_list[x]) > 0):
            j = x_list[x].pop()
            if( j in remain):
                d.append(j)
                remain.remove(j)
        while(len(y_list[y]) > 0):
            j = y_list[y].pop()
            if(j in remain):
                d.append(j)
                remain.remove(j)

    ans += len(xs) * len(ys) - num

print(ans)

Measured memory_bytes: 112980
#include <iostream>
#include <map>
#include <string>

using namespace std;

int c[200][200];

bool check(int A, int B, int size){
	bool flag = false;
	for(int i=0;i<size;i++){
		if(i==A||i==B) continue;
		if(c[i][A]==1&&c[i][B]==1) flag = true;
		if(c[i][A]==1&&c[B][i]==1) return false;
		if(c[A][i]==1&&c[i][B]==1) return false;
		if(c[A][i]==1&&c[B][i]==1) flag = true;
	}
	return flag;
}

int main(){
	int n, m;
	while(cin >> n, n){
		for(int i=0;i<200;i++)
			for(int j=0;j<200;j++) c[i][j] = 1000000;
		map<string, int> mp;
		int size = 0;
		for(int i=0;i<n;i++){
			string name; cin >> name;
			int pos = name.find("-");
			string A = name.substr(0,pos);
			string B = name.substr(pos+1);
			if(!mp.count(A)) mp[A] = size++;
			if(!mp.count(B)) mp[B] = size++;
			c[mp[A]][mp[B]] = 1;
		}
		for(int i=0;i<size;i++){
			for(int j=i+1;j<size;j++){
				if(check(i,j,size)) c[i][j]=2, c[j][i]=2;
			}
		}
		for(int k=0;k<size;k++)
			for(int i=0;i<size;i++){
				if(k==i) continue;
				for(int j=0;j<size;j++)
					c[i][j] = min(c[i][j],c[i][k]+c[k][j]);
			}
		cout << size << endl; 
		cin >> m;
		for(int i=0;i<m;i++){
			string name; cin >> name;
			int pos = name.find("-");
			string A = name.substr(0,pos);
			string B = name.substr(pos+1);
			if(mp.count(A)&&mp.count(B)&&c[mp[A]][mp[B]]%2==1) puts("YES");
			else puts("NO");
		}
	}
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int n; cin >> n;
    mii d;
    rep(i,n) {
        int k; cin >> k;
        d[k]++;
    }
    int m; cin >> m;
    rep(i,m) {
        int t; cin >> t;
        if (d[t] == 0) {
            cout << "NO" << endl;
            return 0;
        } else {
            d[t]--;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 12980
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        int result = b;
        if (a <= 5) {
            result = 0;
        } else if (a <= 12) {
            result = b /2;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 25172
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define ll long long
#define kl k<<1
#define kr k<<1|1
using namespace std;
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
void put1(){ puts("YES") ;}void put2(){ puts("NO") ;}void put3(){ puts("-1"); }
ll qp(ll a,ll b, ll p){ll ans = 1;while(b){if(b&1){ans = (ans*a)%p;--b;}a =
(a*a)%p;b >>= 1;}return ans%p;}

const int manx=1e5+5;
const int mo=998244353;

vector<ll>R,G,B;

int main(){
    ll n=read();
    ull ans=0;
    for(int i=1;i<=n;i++){
        if(i%3 && i%5) ans+=i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3164
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int a, b;
  cin >> a >> b;
  
  cout << (a-1)*(b-1) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007
vi adj[1234567];
bool vis[1234567];
int var[1234567];
int ans[1234567];

void dfs(int u)
{
	vis[u] = 1;
	int c = 1;
	for (int x : adj[u])
	{
		if (!vis[x])
		{
			ans[x] += ans[u];
			dfs(x);
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, q;
	cin >> n >> q;
	zip(i, 0, n - 1)
	{
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	zip(i, 0, q)
	{
		int a, b;
		cin >> a >> b;
		var[a] += b;
		ans[a] += b;
	}

	dfs(1);
	rep(i, 1, n)
	{
		cout << ans[i] << " ";
	}


	return 0;
}



Measured memory_bytes: 51564
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,t;
  cin>>n>>x>>t;
  int q,r;
  q=n/x;
  r=n%x;
  if(r>0)
  q+=1;
  q*=t;
  cout<<q;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),asum(n+1,0),bsum(n+1,0);
  rep(i,n){
    cin >> a[i];
    asum[a[i]]++;
  }
  rep(i,n){
    cin >> b[i];
    bsum[b[i]]++;
  }
  rep(i,n+1){
    if(asum[i] + bsum[i] > n){
      cout << "No\n";
      return 0;
    }
  }
  rep(i,n){
    asum[i+1] += asum[i];
    bsum[i+1] += bsum[i];
  }
  int d = 0;
  rep(i,n+1){
    d = max(asum[i]-bsum[i-1],d);
  }
  cout << "Yes\n";
  rep(i,n){
    cout << b[(n+i-d)%n] << " ";
  }
  return 0;
}

Measured memory_bytes: 6440
import math as m

abx = input().split(' ')
a = float(abx[0]) #側面の底辺
b = float(abx[1]) #側面の高さ
x = float(abx[2]) #水の容積
s = x / a #側面の面積

if s > a * b / 2:
  Q = 2 * (a * b - s) / (a * a)
else:
  Q = (b * b) / (2 * s)

ans = m.degrees(m.atan(Q))
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  sort(A, A+N);
  int s = 0;
  int h = 0;
  int l = 0;
  while (h < N) {
    s += A[h];
    l = h;
    h++;
    while (h < N && A[h] <= 2LL*s) {
      s += A[h];
      h++;
    }
  }
  cout << N-l << "\n";
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

ans = 100000000

for i in range(len(a)):
    tmp = 0
    while a[i] % 2 == 0 and tmp < ans:
        a[i] = a[i] / 2
        tmp += 1
    ans = tmp
print(ans)

Measured memory_bytes: 3060
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort(reverse=True)  # 0(NlogN)
    F.sort()  # O(NlogN)

    def train(X, Y, T):  # O(N)    ans: 回数
        ans = 0
        for i in range(len(X)):
            ans += max(0, X[i] - T // Y[i])
        return ans

    if K>=10**12:
        print(0)
        exit()

    ok = 10**12+1 #時間
    ng = -1

    # O(Nlog(maxK)?)
    while ok - ng > 1:
        mid = (ok + ng) // 2 #時間
        ans = train(A,F,mid)  #kaisuu
        if ans >K:
            ng =mid
        else:
            ok =mid

    print(ok)


if __name__ == "__main__":
    main()


Measured memory_bytes: 113856
//Homework
#include <iostream>

using namespace std;

int main() {
    int L, A, B, C, D;
    cin >> L >> A >> B >> C >> D;
    int x = (A + C - 1) / C;
    int y = (B + D - 1) / D;
    cout << (L - max(x, y)) << endl;
    
    return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

map<int, int> prime_factor(int n) {
  map<int, int> ret;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

void solve() {
  int m;
  cin >> m;
  map<int, int> mp;
  for (int n = m; 1 <= n; n--) {
    map<int, int> p = prime_factor(n);
    dump(n, p);
    for (auto m : p) {
      mp[m.first] += m.second;
    }
    dump(n, mp.size(), mp);
  }
  vector<int> prime;
  for (auto m : mp) prime.push_back(m.second);
  dump(prime);
  function<int(int, int)> calc = [&](int idx, int val) {
    if (val > 75 || prime.size() <= idx) return 0;
    if (val == 75) return 1;
    int cnt = 0;
    for (int i = 1; i <= prime[idx] + 1; i++) {
      cnt += calc(idx + 1, val * i);
    }
    return cnt;
  };
  int ans = calc(0, 1);
  dump(ans);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
k, n = map(int, input().split())

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

# 最初と最後の家の距離（左側）を計算
distance_max = k - (A[-1]- A[0])

# 上記のdistanceより長い距離があるか調べる
for i in range(n-1):
    dis = A[i+1] - A[i]
    distance_max = max(distance_max, dis)

# 一番長い距離を切り、円環を切る
ans = k - distance_max
print(ans)

Measured memory_bytes: 26060
#include <stdio.h>

int main()
{
    int h, w;
    int y, x;
    while(1) {
        scanf("%d%d", &h, &w);
        if(h==0 && w==0) break;
        for(y=0; y<h; y++) {
            for(x=0; x<w; x++) {
                if((x^y)&1) putchar('.');
                else putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

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;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll iterate_sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

struct union_find {
    int size;
    vector<int> par;
    union_find(int N) : size(N), par(N) { REP(i, N) par[i] = i; }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        else {
            par[rx] = ry;
            return;
        }
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n = in(), m = in(), c = in();
    int b[m], a[n][m];
    REP(i, m) { cin >> b[i]; }
    REP(i, n) {
        REP(j, m) { cin >> a[i][j]; }
    }
    ll res = 0;
    REP(i, n) {
        ll ans = 0;
        REP(j, m) { ans += a[i][j] * b[j]; }
        if (ans + c > 0) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#pragma GCC otimize(3)
#pragma once
#include<bits/stdc++.h>
#define q register
#define hxj 10001
using namespace std;
typedef long long ll;
ll a[hxj],n,i;
int main()
{
	ios::sync_with_stdio(false);
	memset(a,0,sizeof(a));
	cin>>n;
	a[1]=2;
	if(!n){
	   cout<<"2"<<endl;  return 0;
	}
	if(n==1){
	   cout<<"6"<<endl;  return 0;
	}
	for(q int i=2;i<=hxj-10;i++){
	   a[i]=(a[i-1]+1)*2;
	}
    cout<<a[n+1]<<endl;
    return 0;
}

Measured memory_bytes: 384