akhauriyash/Code-Regression huggingface dataset:
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var n = long.Parse(ReadLine());
    var load = Enumerable.Range(0, 5).Select(_ => long.Parse(ReadLine())).ToArray();

    var group = (n + (load.Min() - 1)) / load.Min();
    var ans = 5 + (group - 1);
    WriteLine(ans);
  }
}

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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}


Measured memory_bytes: 3164
# -*- coding: utf-8 -*
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        for j in range(w):
            if i == 0 or i == h - 1 or j == 0 or j == w - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

Measured memory_bytes: 8892
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    int n;
    int m;
    cin>>n>>m;
    int a[114514];
    prique q;
    for(int i=0;i<n;i++){
        cin>>a[i];
        q.push(a[i]);
    }
    for(int i=0;i<m;i++){
        int k=q.top();
        q.pop();
        q.push(k/2);
    }
    int ans=0;
    while(!q.empty()){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1912
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,tot=0;
int head[1000001],a[1000001];
bool vis[1000001],f[1000001];
struct data {
	int next,num;
}edge[1000001];
void add(int u,int v) {
	edge[++tot].next=head[u];
	edge[tot].num=v;
	head[u]=tot;
}
void dfs(int x) {
	vis[x]=1;
	f[x]=0;
	for (int i=head[x];i!=-1;i=edge[i].next) {
		int kx=edge[i].num;
		dfs(kx);
		if (!f[kx]) {
			f[x]=1;
			return;
		}
	}
}
int main() {
	memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		if (a[u]>a[v]) add(u,v);
		if (a[u]<a[v]) add(v,u);
	}
	for (int i=1;i<=n;i++) if (!vis[i]) dfs(i);
	for (int i=1;i<=n;i++) if (f[i]) printf("%d ",i);
	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000003 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int a,b;
	cin >> a >> b;
	cout << a + b/2 << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a, b, k;
  int count, temp;
  
  scanf("%d%d%d", &a, &b, &k);
  
  for(temp=a,count=0; count<k; temp--){
    if((a%temp==0) && (b%temp==0)){
      count++;
    }
  }
  
  printf("%d\n", temp+1);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

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

  vector<int> dp(10101, 0);
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 10000; j >= 0; j--){
      if(j + a[i] > 10000) continue;
      dp[j + a[i]] |= dp[j];
    }
  }

  int ans = 0;
  for(int i = 0; i < 10000; i++){
    if(dp[i] && i % 10 != 0){
      ans = max(ans, i);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
    int r,c;
    int a[101][101]={};
    
    cin>>r>>c;
    int i,j;
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cin>>a[i][j];
            cout<<a[i][j]<<" ";
            a[r][j]+=a[i][j];
            a[i][c]+=a[i][j];
        }
        cout<<a[i][c]<<endl;
        a[r][c]+=a[i][c];
    }
    for(j=0;j<c;j++){
        cout<<a[r][j]<<" ";
    }
    cout<<a[r][c]<<endl;
    
    return 0;
}



Measured memory_bytes: 3156
#include <cstdio>
#include <cmath>

int main()
{
  int x;
  scanf("%d", &x);
  
  int ans = 1;
  for (int i = 2; i < 32; ++i)
  {
    for (int j = 2; std::pow(i, j) <= x; ++j)
    {
      if (std::pow(i, j) > ans) ans = std::pow(i, j);
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A - 2 * B > 0) {
		cout << A - 2 * B << endl;
	}
	else {
		cout << 0 << endl;
	}

}






Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

const int N=1e5+5;

int num[N];

int main() {
	int n=read();
	ll sum=0;
	for (int i=1;i<=n;i++) {
		int a=read();
		num[a]++;
		sum+=a;
	}
	int q=read();
	for (int i=1;i<=q;i++) {
		int b=read(),c=read();
		sum+=num[b]*(c-b);
		num[c]+=num[b];
		num[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3964
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int X[101010], Y[101010];
class UnionFind {
public:
	vector<int> r, p;

	UnionFind() {}
	UnionFind(int size) {
		r.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size;i++)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		r[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (r[x] > r[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (x == y) {
				r[y]++;
			}
		}
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}
};

int main() {
	int N;
	cin >> N;
	UnionFind un(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
	}

	vector<int>xorder, yorder;
	for (int i = 0; i < N; i++) { xorder.pb(i); yorder.pb(i); }
	sort(all(xorder), [&](int i, int j) {return X[i] < X[j]; });
	sort(all(yorder), [&](int i, int j) {return Y[i] < Y[j]; });

	vector<vector<ll>>edges;
	int xsz = (int)xorder.size();
	int ysz = (int)yorder.size();
	for (int i = 0; i < xsz - 1; i++) {
		edges.pb({X[xorder[i+1]]-X[xorder[i]],xorder[i],xorder[i+1]});
	}
	for (int i = 0; i < ysz - 1; i++) {
		edges.pb({Y[yorder[i + 1]]-Y[yorder[i]],yorder[i],yorder[i + 1] });
	}
	sort(all(edges));

	ll ans = 0;
	fore(e, edges) {
		if (!un.same(e[1], e[2])) {
			un.unite(e[1], e[2]);
			ans += e[0];
		}
	}
	puts(ans);


	return 0;
}

Measured memory_bytes: 14820
X,Y,A,B,C = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

hoge=p[:X]+q[:Y]+r
hoge.sort(reverse=True)
print(sum(hoge[:X+Y]))




Measured memory_bytes: 23328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int A,B;
	cin >> A >> B;
	if((A + B) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << ( A + B )/ 2 << endl; 
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int N = NextInt();
        if (N == 3) { Console.WriteLine(61); return; }
        int[,,,] dp = new int[110, 4, 4, 4];
        dp[0, 3, 3, 3] = 1;
        for (int i = 0; i < N; i++)
            for (int j = 0; j < 4; j++)
                for (int k = 0; k < 4; k++)
                    for (int l = 0; l < 4; l++)
                        for (int n = 0; n < 4; n++)
                        {
                            if (n == 2 && j == 1 && k == 0) continue;
                            if (n == 2 && j == 0 && k == 1) continue;
                            if (n == 1 && j == 2 && k == 0) continue;
                            if (n == 2 && j == 1 && l == 0) continue;
                            if (n == 2 && k == 1 && l == 0) continue;
                            dp[i + 1, n, j, k] += dp[i, j, k, l];
                            dp[i + 1, n, j, k] %= INF;
                        }
        long ans = 0;
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++)
                for (int k = 0; k < 4; k++)
                {
                    ans += dp[N, i, j, k];
                    ans %= INF;
                }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13360
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	long long int h,w,i,j,ans,y,a,aa,b,c,max,min;
	cin >> h >> w;
	if(h%3==0 ||w%3==0){
		cout << "0" << endl;
	}
	else{
		ans=h*w;
		for(i=0;i<=h;i++){
			a=i*w;
			b=(h-i)*(w/2);
			c=h*w-a-b;
			max=a;
			if(max<b)max=b;
			if(max<c)max=c;
			min=a;
			if(min>b)min=b;
			if(min>c)min=c;
			if(ans>max-min)ans=max-min;
			
			aa=(h-i)/2;
			b=aa*w;
			c=h*w-a-b;
			max=a;
			if(max<b)max=b;
			if(max<c)max=c;
			min=a;
			if(min>b)min=b;
			if(min>c)min=c;
			if(ans>max-min)ans=max-min;
		}
		
		for(i=0;i<=w;i++){
			a=i*h;
			b=(w-i)*(h/2);
			c=h*w-a-b;
			max=a;
			if(max<b)max=b;
			if(max<c)max=c;
			min=a;
			if(min>b)min=b;
			if(min>c)min=c;
			if(ans>max-min)ans=max-min;
			
			aa=(w-i)/2;
			b=aa*h;
			c=h*w-a-b;
			max=a;
			if(max<b)max=b;
			if(max<c)max=c;
			min=a;
			if(min>b)min=b;
			if(min>c)min=c;
			if(ans>max-min)ans=max-min;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

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

  string A, B, C;
  while(cin>>A, A != "0"){
	cin >> B >> C;
	int D = SZ(A);
	vector<LL> c(2, 0), c_(2, 0);
	c_[0] = 1;
	for(int d=D-1;d>=0;--d){
	  c[0] = c[1] = 0;
	  for(int i1=(A[d]!='?'?A[d]-'0':0);
		  i1<(A[d]!='?'?A[d]-'0'+1:10);++i1){
		if(d==0 && i1 == 0) continue;
		for(int i2=(B[d]!='?'?B[d]-'0':0);
			i2<(B[d]!='?'?B[d]-'0'+1:10);++i2){
		  if(d==0 && i2 == 0) continue;
		  for(int i3=(C[d]!='?'?C[d]-'0':0);
			  i3<(C[d]!='?'?C[d]-'0'+1:10);++i3){
			if(d==0 && i3 == 0) continue;
			if((i1+i2)%10 == i3){
			  if(i1+i2 >= 10) c[1] = (c[1] + c_[0]) % MOD;
			  else c[0] = (c[0] + c_[0]) % MOD;
			}
			else if((i1+i2+1)%10 == i3){
			  if((i1+i2+1) >= 10) c[1] = (c[1] + c_[1]) % MOD;
			  else c[0] = (c[0] + c_[1]) % MOD;
			}
		  }
		}
	  }
	  REP(i,2) c_[i] = c[i];
	}
	cout << c[0] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    /*
    let s = read::<String>().chars().collect::<Vec<char>>();

    let mut maxlen = 0;
    for i in 0..n-2 {
        for j in i+maxlen+1..n {
            if n - j < j - i || n - j < maxlen{
                break;
            }
            let sub = s[i..j].iter().map(|&c| c).collect::<String>();
            if sub.len() > maxlen {
                let rest = s[j..].iter().map(|&c| c).collect::<String>();
                println!("{} {} {} {}", sub, rest, sub.len(), maxlen);
                if rest.contains(&sub) {
                    maxlen = sub.len();
                }
            }
        }
    }
    println!("{}", maxlen);
    */

    let s = read::<String>();

    //use std::time::{Duration, Instant};
    //println!("{}", s);
    let mut maxlen = 0;
    for i in 0..n-2 {
        //let a = Instant::now();

        for j in i+1+maxlen..n {
            if n - j < j - i || n - j < maxlen{
                break;
            }
            let sub = &s[i..j];
            if sub.len() > maxlen {
                let rest = &s[j..];
                //println!("{} {}", sub.len(), maxlen);
                if rest.contains(&sub) {
                    maxlen = sub.len();
                } else {
                    break;
                }
            }
        }
        //let end = a.elapsed();
        //println!("{}.{:03}", end.as_secs(), end.subsec_nanos() / 1000000);
    }
    println!("{}", maxlen);

}


Measured memory_bytes: 4476
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
int main(){
	int K;
	cin >> K;
	queue<ll> q;
	for(int i = 1; i < 10; i++)
		q.push(i);
	for(int i = 1; i < K; i++){
		ll x = q.front();
		q.pop();
		if(x%10 != 0){
			q.push(x*10+x%10-1);
		}
		q.push(x*10+x%10);
		if(x%10 != 9){
			q.push(x*10+x%10+1);
		}
	}
	cout << q.front() << endl;
	
	
	return 0;
}


Measured memory_bytes: 1792
from itertools import accumulate


class Bit:
    # 参考1: http://hos.ac/slides/20140319_bit.pdf
    # 参考2: https://atcoder.jp/contests/arc046/submissions/6264201
    # 検証: https://atcoder.jp/contests/arc046/submissions/7435621
    # values の 0 番目は使わない
    # len(values) を 2 冪 +1 にすることで二分探索の条件を減らす
    def __init__(self, a):
        if hasattr(a, "__iter__"):
            le = len(a)
            self.n = 1 << le.bit_length()  # le を超える最小の 2 冪
            self.values = values = [0] * (self.n + 1)
            values[1:le + 1] = a[:]
            for i in range(1, self.n):
                values[i + (i & -i)] += values[i]
        elif isinstance(a, int):
            self.n = 1 << a.bit_length()
            self.values = [0] * (self.n + 1)
        else:
            raise TypeError

    def add(self, i, val):
        n, values = self.n, self.values
        while i <= n:
            values[i] += val
            i += i & -i

    def sum(self, i):  # (0, i]
        values = self.values
        res = 0
        while i > 0:
            res += values[i]
            i -= i & -i
        return res

    def bisect_left(self, v):  # self.sum(i) が v 以上になる最小の i
        n, values = self.n, self.values
        if v > values[n]:
            return None
        i, step = 0, n >> 1
        while step:
            if values[i + step] < v:
                i += step
                v -= values[i]
            step >>= 1
        return i + 1

def solve(M, N, A):
    A_sign = [-1 if a <= M else 1 for a in A]
    A_sign_cum = list(accumulate(A_sign))
    geta = N + 2
    bit = Bit(2*N + 4)
    bit.add(geta, 1)
    cnt = 0  # 中央値が M 以下になる区間の個数
    #if True:
    #    print(M, A_sign, A_sign_cum)
    for i, a in enumerate(A_sign_cum, 1):
        cnt += i - bit.sum(geta + a)
        #print(cnt, end=" ")
        bit.add(geta + a, 1)
    #print()
    #print(N * (N+1) // 4 + 1, cnt)
    return N * (N+1) // 4 + 1 <= cnt


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

    # cnt = 0
    # for i in range(N):
    #     for j in range(i+1, N+1):
    #         if sorted(A[i:j])[(j-i)//2] <= 5:
    #             cnt += 1
    #             print(i, j)
    # print(cnt)

    A_sorted = sorted(A)
    ng, ok = -1, N-1
    while ng + 1 < ok:
        c = (ng + ok) // 2
        M = A_sorted[c]
        if solve(M, N, A):
            ok = c
        else:
            ng = c
    print(A_sorted[ok])

main()


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


int n,r,c;
struct Point{
	int x,y,idx;
	int where(void)const{
		if(x==0)
			return 1;
		if(x==r)
			return 3;
		if(y==c)
			return 2;
		if(y==0)
			return 4;
		return 0;
	}
	bool operator<(const Point& rhs)const{
		if(where()!=rhs.where())
			return where()<rhs.where();
		if(where()==1)
			return y<rhs.y;
		if(where()==2)
			return x<rhs.x;
		if(where()==3)
			return y>rhs.y;
		return x>rhs.x;
	}
}p1,p2;
vector<Point> v;
stack<int> st;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>r>>c>>n;
	for(int i=1;i<=n;i++){
		cin>>p1.x>>p1.y>>p2.x>>p2.y;
		p1.idx=p2.idx=i;
		if(p1.where()&&p2.where()){
			v.emplace_back(p1);
			v.emplace_back(p2);
		}
	}
	sort(v.begin(),v.end());
	for(auto it:v){
		if(st.empty())
			st.push(it.idx);
		else if(it.idx==st.top())
			st.pop();
		else st.push(it.idx);
	}
	if(st.empty())
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}


Measured memory_bytes: 4980
import sys

S = str(input())

if S[0] != "A":
    print('WA')
    sys.exit()
    
if S[2:-1].count('C') != 1:
    print('WA')
    sys.exit()

temp = S.replace('A', '').replace('C', '')
if temp.islower():
    print('AC')
else:
    print('WA')

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

int main(){
    int n; cin >> n;
    long long a[n];

    bool z = false;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        if (a[i] == 0) z = true;
    }

    if (z) {cout << "0" << endl; return 0;}

    long long res = 1;
    for(int i=0; i<n; ++i){
        if (a[i] <= (long long)1e18 / res)
            res *= a[i];
        else {res = -1; break;}
    }
    cout << res << endl;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, M; cin >> N >> M;
  int ans = (1<<M) * (M*1900 + (N-M)*100);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long K;
  cin >> K;
  
  string S = "ACL";
  for (long i = 1; i < K; i++) {
      S = S + "ACL"; 
  }
  

  cout << S <<endl;
}

   
    


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

    int N,K;
    ll L,R;cin>>N>>K>>L>>R;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    vector<ll> S[2*N];
    for(int bit=0;bit<(1<<N/2);bit++){
        int cnt=0;
        ll sum=0;
        for(int i=0;i<N/2;i++){
            if(bit&(1<<i)){
                cnt++;
                sum+=A[i];
            }
        }
        S[cnt].push_back(sum);
        //cout<<cnt<<" "<<sum<<endl;
    }
    
    for(int i=0;i<N;i++){
        sort(all(S[i]));
    }
    
    ll ans=0;
    
    for(int bit=0;bit<(1<<(N-N/2));bit++){
        int cnt=0;
        ll sum=0;
        for(int i=0;i<N-N/2;i++){
            if(bit&(1<<i)){
                cnt++;
                sum+=A[i+N/2];
            }
        }
        if(K<cnt) continue;
        if(S[K-cnt].size()==0) continue;
        //cout<<S[K-cnt].size()<<endl;
        auto left=lower_bound(all(S[K-cnt]),L-sum),right=upper_bound(all(S[K-cnt]),R-sum);
        ans+=distance(left,right);
    }
    
    cout<<ans<<endl;
}




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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	for (int i = n - 1; i >= 0; i--) {
		cout << a.at(i);
                if(i!=0) cout << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3124
S = int(input())

i = 2
a_list = [S]
if S % 2 == 0:
	a = S/2
else:
	a = 3*S + 1

while(i>0):
	if a in a_list:
		print(i)
		break
	else:
		a_list.append(a)
		if a % 2 == 0:
			a = a/2
		else:
			a = 3*a + 1
	i += 1
	if i==1000:
		i=0
		break


Measured memory_bytes: 2940
using System;

class HappyBirthday{
    static void Main(string[] args){
        var ab = Console.ReadLine().Split(' ');
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);

        if(a>8 || b>8){
            Console.WriteLine(":(");
        }else{
            Console.WriteLine("Yay!");
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
res = 10**4
now = 10**10

for i in range(len(h)):
    if abs((t-(h[i]*0.006))-a) < now:
        res =  i+1
        now = abs((t-(h[i]*0.006))-a) 
else:
    print(res)


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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ll n;
	cin >>n;
	vector<ll> v(n+1);
	for(int i = 1; i <= n;++i) cin>>v[i];
	vector<vector<ll>> dp(n+2,vector<ll> (n+2));
	for(int L = n;L>0;L--) 
		 for(int R = L;R <= n;R++) 
		 	 dp[L][R] = max(v[L]-dp[L+1][R],v[R]-dp[L][R-1]);

	cout <<dp[1][n]<<'\n';
	return 0;
}

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

using namespace std;

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

const int N = 1e5 + 5;

int n;
int a[N];

int main() {

	scanf("%d", &n);

	int c1 = 0, c2 = 0, c4 = 0;

	for(int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		if(x % 4 == 0)
			c4++;
		else if(x % 2 == 0)
			c2++;
		else
			c1++;
	}

	puts(c1 <= c4 or c1 == c4 + 1 and !c2 ? "Yes" : "No");

    return 0;

}


Measured memory_bytes: 384
#include<stdio.h> 
const int N = 100;

int main(){
  int M[N][N];
  int n, u, k, v, i, j;

  scanf("%d", &n);
  
  for (i = 0; i < n; i++){
    for (j = 0; j < n; j++){
      M[i][j] = 0;
    }
  }

  for (i = 0; i <n; i++){
    for (j = 0; j <n; j++){
      M[i][j] = 0;
    }
  }
  
  for (i = 0; i < n; i++){
    scanf("%d %d", &u, &k);
    u--;
    for (j = 0; j < k; j++){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  for (i = 0; i < n; i++){
    for (j = 0; j < n; j++){
      if (j) printf(" ");
      printf("%d", M[i][j]);
    }
    printf("\n");
  }

  return 0;
}


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

int main() {
    ll n, k;
    cin >> n >> k;
    ll d = n % k;
    ll a = k - d;
    cout << min(a, d) << endl;
}


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

using namespace std;

const int MAXN = 1E5;
bool solved[MAXN + 1];
int wa[MAXN + 1];

int main()
{
    int n, m;
    cin >> n >> m;
    int correct = 0;
    int pen = 0;
    for (int i = 0; i < m; i++)
    {
        int p;
        string s;
        cin >> p >> s;
        if (!solved[p])
        {
            if (s == "AC")
            {
                solved[p] = true;
                correct++;
            }
            else
            {
                wa[p]++;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        if (solved[i])
            pen += wa[i];
    cout << correct << " " << pen << endl;
    return 0;
}


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

int main(){
    int x, n;
    cin >> x >> n;
    vector <int> p(n);
    for(int i = 0; i < n; i ++){
        cin >> p[i];
    }
    for(int i =0; i < x+1; i++){
        for(int j: {-1,1}){
            int a = x+j*i;
            if(count(p.begin(),p.end(),a) == 0){
                cout << a << endl;
                exit(0);
            }
        }
    }
}


Measured memory_bytes: 3604
H, W = gets.split.map(&:to_i)
if H == 1 || W == 1
  puts 1
  exit 0
end
if H.even? && W.even? 
  puts H * W / 2
  exit 0
end
if H.even?
  puts H * W / 2
else
  puts ((H - 1) * W / 2) + (W + 1) / 2
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/










int N, Q, A[101010], X[101010];
//---------------------------------------------------------------------------------------------------
ll B[101010], takasm[101010];
void init() {
    B[0] = A[0];
    rep(i, 1, N) B[i] = B[i - 1] + A[i];

    rep(i, 0, N) {
        if (N % 2 == 1 and i % 2 == 0) takasm[i] = A[i];
        if (N % 2 == 0 and i % 2 == 1) takasm[i] = A[i];
    }
    rep(i, 1, N) takasm[i] += takasm[i - 1];
}
ll get(int L, int R) {
    ll res = B[R];
    if (L) res -= B[L - 1];
    return res;
}
//---------------------------------------------------------------------------------------------------
pair<int, int> f(int x, int len) {
    int lft = lower_bound(A, A + N, x - len) - A;
    int rht = upper_bound(A, A + N, x + len) - A - 1;
    return { lft, rht };
}
//---------------------------------------------------------------------------------------------------
ll solve(int x) {
    int ng = -1, ok = inf;
    while (ng + 1 != ok) {
        int md = (ng + ok) / 2;
        auto p = f(x, md);
        if (p.first > p.second) {
            ng = md;
            continue;
        }

        int len = p.second - p.first + 1;
        if (N - 1 <= p.second + len) ok = md;
        else ng = md;
    }

    int L, R;
    tie(L, R) = f(x, ok);
    int turn = R - L + 1;

    int taka = N - R - 1;
    int aoki = turn;

    if (taka != aoki) {
        R--;
        aoki--;
        turn--;
    }
    
    ll res = get(R + 1, N - 1);
    if (L) res += takasm[L - 1];
    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> Q;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, Q) cin >> X[i];
    init();
    rep(i, 0, Q) printf("%lld\n", solve(X[i]));
}


Measured memory_bytes: 4096
// luogu-judger-enable-o2
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	string s;
	int n;
	cin>>n;
	cin>>s;
	int ans=0;
	int maxn=0;
	for(int i=0;i<=n-1;i++)
	{
		if(s[i]=='I')
		{
			ans++;
			maxn=max(ans,maxn);
		}
		else
		{
			ans--;
			maxn=max(maxn,ans);
		}	
	}
	cout<<maxn<<endl;
	return 0;
}

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

int main()
{
    int N; cin >> N;
    vector<long long> d(N);
    for(int i = 0; i < N; i++) cin >> d[i];
    long long sum = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            if(i != j) sum += d[i]*d[j];
        }
    }
    cout << sum/2 << endl;
    return 0;
}

Measured memory_bytes: 256
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;

#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
const int mod = 1e9 + 7;
int32_t  main()
{
	int n;
	cin >> n;
	int a[n];
	int s = 0;
	forn(i,n){
		cin>>a[i];
		s += a[i];
	}
	int suffixsum[n];
	int k =  0;
	for(int i = 0;i < n;i++)
	{
		k+= a[i];
		suffixsum[i] = (s - k) % mod;
	}
	int ans = 0;
	for(int i = 0;i < n - 1 ;i++)
	{
		int add = (a[i] * suffixsum[i]) % mod;
		ans = (ans + add) % mod;
	}
	cout<<ans;
}

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

int main() {
  int N,M;
  
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++)
    cin >> s.at(i);
  
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++)
    cin >> t.at(i);
  
  vector<int> k(N);
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++)
      if(s.at(i)==s.at(j))
        k.at(i)++;
    for(int j=0;j<M;j++)
      if(s.at(i)==t.at(j))
        k.at(i)--;
  }
  
  int max=0;
  for(int i=0;i<N;i++){
    if(max<k.at(i))
      max=k.at(i);
  }
  cout << max;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  int sum = 0;
  rep(i,n) sum += i+l;

  int diff = 100000;
  int ans;
  rep(i,n) {
    int d = abs(sum-(sum-(i+l)));
    if(d<diff){
      ans = sum-(i+l);
      diff = d;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	int N, A;
	cin >> N >> A;
	cout << (N*N - A) << endl;
	return 0;
}


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

pair<pair<string,int>,int> p[100];

int main(){
  int n; cin >> n;
  for(int i = 0;i < n;i++){
    string s;
    int score;
    cin >> s >> score;
    p[i] = make_pair(make_pair(s,-score),i+1);
  }  
  sort(p,p+n);
  for(int i = 0;i < n;i++){
      cout << p[i].second << endl;
  }
}

Measured memory_bytes: 256
from math import gcd
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
c=a[0]
for i in a[1:]:
  c=c*i//gcd(c,i)
ans=0
c%=mod
for i in a:
  ans+=c*pow(i,mod-2,mod)
  ans%=mod
print(ans)

Measured memory_bytes: 73844
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    int a , b = 0;
    cin >> a;
    for ( int i = 1 ; i <= a ; i++ ) {
        b += i;
    }
    cout << b;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 4005;
const int inf = 0x3f3f3f3f;
vector<int>VR,VG,VB;
char a[N];
ll ans=0,x=0;
int R,G,B;
int main()
{
	int n;
	scanf("%d%s",&n,a);
	for(int i=0;i<n;i++)
	if(a[i]=='R')R++;
	else if(a[i]=='G')G++;
	else B++;
	ans=(ll)R*G*B;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int k=j*2-i;
			if(k<n&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i])
			x++;
		}
	}
	cout<<ans-x;
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll A[N], B[N];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll ans = 0;
    queue<int> que;
    rep(j, N){
        int i = (j+N-1)%N, k = (j+1)%N;
        if(B[j] > B[i]+B[k]) que.push(j);
    }
    while(!que.empty()){
        int j = que.front();
        que.pop();
        int i = (j+N-1)%N, k = (j+1)%N;
        ll S = B[i]+B[k];
        if(A[j] > B[j]) break;
        if(B[j] <= S) continue;
        if(A[j]%S == B[j]%S){
            ans += (B[j]-A[j])/S;
            B[j] = A[j];
        }
        else{
            if(B[j]%S == 0){
                ans += B[j]/S-1;
                B[j] = S;
            }
            else{
                ans += B[j]/S;
                B[j] %= S;
            }
        }
        que.push(i), que.push(k);
    }
    bool res = true;
    rep(i, N) if(A[i] != B[i]) res = false;
    if(res) cout << ans << endl;
    else cout << -1 << endl;
}

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

int main(){
    
    long long X;
    long long sum = 100;
    cin>>X;
 for( long long i=1; i<X; i++){
    sum*=1.01;

   if(sum>=X){
       cout << i <<endl;
       break;
   }
 }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int m;
    cin>>m;
    vector<ll> vec(10);
    vector<ll> new_vec(10);
    
    rep(i,m) {
        ll d,c;
        cin>>d>>c;
        vec[d]+=c;
    }
    
    vector<int> to={0,2,4,6,8,1,3,5,7,9};
    
    ll ans=0;
    while(true) {
        rep(i,10) {
            ll add=vec[i]/2;
            if(i<=4) ans+=add;
            else ans+=2*add;
            
            vec[i]-=2*add;
            vec[to[i]]+=add;
        }
        
        bool finish=true;
        rep(i,10) if(vec[i]>1) finish=false;
        if(finish) break;
    }
    
    string s;
    rep(i,10) if(vec[i]) s+=(char)(i+'0');
    while(sz(s)>1) {
        int a=s.back()-'0';s.pop_back();
        int b=s.back()-'0';s.pop_back();
        s+=(to_string(a+b));
        ans++;
    }
    cout<<ans<<endl;
}



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

int main(){
  int a, b;
  cin >> a >> b;

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

  return 0;
}



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

using ll = long long;

constexpr ll INF = 1e18;

struct edge {
    int from, to;
    ll cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

vector<ll> dijkstra(graph const& g, int s) {
    const int V = g.size();
    vector<ll> d(V, INF);
    d[s] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> que;
    que.emplace(0, s);
    while(!que.empty()) {
        auto now = que.top();
        que.pop();
        const int v = now.second;
        if(d[v] < now.first) continue;
        for(auto& e : g[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.emplace(d[e.to], e.to);
            }
        }
    }
    return d;
}

int main() {
    int N, M, s, t, u, v;
    cin >> N >> M >> s >> t >> u >> v;
    s--; t--; u--; v--;
    graph g(N);
    for(int i = 0; i < M; ++i) {
        int a, b, c; cin >> a >> b >> c;
        g[a - 1].push_back(edge{a - 1, b - 1, c});
        g[b - 1].push_back(edge{b - 1, a - 1, c});
    }
    auto from_s = dijkstra(g, s);
    auto from_t = dijkstra(g, t);
    graph sg(N);
    for(int i = 0; i < N; ++i) {
        for(auto& e : g[i]) {
            if(from_s[t] == from_s[e.from] + e.cost + from_t[e.to]) {
                sg[i].push_back(e);
            }
        }
    }
    auto from_u = dijkstra(g, u);
    auto from_v = dijkstra(g, v);
    ll ans = INF;
    vector<pair<ll, ll>> memo(N, make_pair(INF, INF));
    std::function<pair<ll, ll> (int)> dfs = [&](int i) {
        if(memo[i].first != INF) return memo[i];
        auto res = make_pair(from_u[i], from_v[i]);
        for(auto& e : sg[i]) {
            auto tmp = dfs(e.to);
            res.first = min(res.first, tmp.first);
            res.second = min(res.second, tmp.second);
        }
        ans = min({ans, from_v[i] + res.first, from_u[i] + res.second});
        return memo[i] = res;
    };
    dfs(s);
    ans = min(ans, from_u[v]);

    cout << ans << endl;
}



Measured memory_bytes: 30304
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	S += "x";

	vll group;

	int start = 0;
	for (int i = 0; i < N; i++)
	{
		if (S[i] != S[i + 1])
		{
			group.emplace_back(i - start + 1);
			start = i + 1;
		}
	}

	if (group.size() == 1)
	{
		cout << N << endl;
		return 0;
	}


	vll accum;
	accum.emplace_back(group[0]);
	for (int i = 1; i < group.size(); i++)
	{
		accum.emplace_back(accum[i - 1] + group[i]);
	}

	ll ans = 0;
	if (S[0] == '1')
	{
		ans = accum[min(K*2, ll(group.size()-1))];

		for (ll i = 2; i < group.size(); i+=2)
		{
			ans = max(ans, accum[min(i + K * 2, ll(group.size() - 1))] - accum[i - 1]);
		}
	}
	else
	{
		ans = accum[min(K * 2- 1, ll(group.size()-1))];

		for (ll i = 1; i < group.size(); i+=2)
		{
			ans = max(ans, accum[min(i + K * 2, ll(group.size()-1))] - accum[i - 1]);
		}
	}

	cout << ans << endl;

}





Measured memory_bytes: 2676
import math
a, b, V = [int(s) for s in input().split()]

def judge(theta, a, b, V):
  theta_rad = math.radians(theta)
  tan = math.tan(theta_rad)
  y = (V - a**3*tan/2)/a**2
  if y >= 0.:
    if y+a*tan <= b:
      return True
    else:
      return False
  else:
    z = math.sqrt(V/tan/a*2)
    if z*tan <= b:
      return True
    else:
      return False

theta_eval = [0., 89.9999999999]

while theta_eval[1]-theta_eval[0] >= 1e-7:
  delta = [1.0, 1.0]
  while judge(theta_eval[0]+delta[0], a, b, V) == False or theta_eval[0]+delta[0] >= theta_eval[1]:
    delta[0] = delta[0]/2
  while judge(theta_eval[1]-delta[1], a, b, V) == True:
    delta[1] = delta[1]/2
  theta_eval[0] += delta[0]
  theta_eval[1] -= delta[1]

print(theta_eval[0])

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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a,a+n);
  int N=a[n-1];
  int min=abs(a[n-1]/2-a[0]);
  int R=a[0];
  for (int i=1; i<n-1; i++) {
    int diff=abs(a[n-1]/2-a[i]);
    if (diff<=min) {
      R=a[i];
      min=diff;
    }
  }
  cout<<N<<" "<<R<<endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    vector<int> cnt(4);
    rep(i,0,6){
        int x;
        cin>>x;
        x--;
        cnt[x]++;
    }
    sort(all(cnt));
    if(cnt[0]==1&&cnt[1]==1&&cnt[2]==2&&cnt[3]==2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, n+1){
        ll num = n/i;
        ll first = i;
        ll last = i+i*(num-1);
        ans += (first+last)*num;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 3608