akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int H,N; cin>>H>>N;
	int A[N],B[N];
	rep(i,0,N) cin>>A[i]>>B[i];
	int dp[H+10001];
    rep(i,0,H+10001) dp[i] = inf;
    dp[0] = 0;
	rep(i,0,N)rep(j,A[i],H+10001){
		dp[j] = min(dp[j], dp[j - A[i]] + B[i]);
	}int ans = inf;
	rep(i,H,H+10001) ans = min(ans, dp[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
n,m = map(int,input().split())
par = [-1]*n
for i in range(m):
  x,y = map(int,input().split())
  unite(x,y)

k = int(input())
for i in range(k):
  a,b = map(int,input().split())
  if same(a,b):
    print("yes")
  else:
    print("no")



Measured memory_bytes: 7160
/////////////////////////   _LeMur_
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>
 
using namespace std;
 
const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 998244353;
 
long long n , a , b;
 
int main(){
	cin >> n >> a >> b;
	if((b - a) % 2 == 0)
		cout << (b - a) / 2 << endl;
	else{
		cout << min( a + (b - a - 1) / 2 , n - b + 1 + (n - (a + n - b + 1)) / 2 ) << endl;
	}
	cin >> n;
    return 0;
}

Measured memory_bytes: 256
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()

loopin=input()

A11,A12,A13,A21,A22,A23,A31,A32,A33=0,0,0,0,0,0,0,0,0


for x in range(int(loopin)):
	bingo = input()
	if bingo==a:
		A11=1
	elif bingo==b:
		A12=1	
	elif bingo==c:
		A13=1	
	elif bingo==d:
		A21=1	
	elif bingo==e:
		A22=1	
	elif bingo==f:
		A23=1	
	elif bingo==g:
		A31=1	
	elif bingo==h:
		A32=1
	elif bingo==i:
		A33=1


if (A11+A12+A13)==3:
	print("Yes")
elif (A21+A22+A23)==3:
	print("Yes")
elif (A31+A32+A33)==3:
	print("Yes")
elif (A11+A21+A31)==3:
	print("Yes")
elif (A12+A22+A32)==3:
	print("Yes")
elif (A13+A23+A33)==3:
	print("Yes")
elif (A11+A22+A33)==3:
	print("Yes")
elif (A13+A22+A31)==3:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s;
	bitset<3> bs(s, 0, 3, 'x', 'o');
	cout << 700 + bs.count() * 100 << endl;
	return 0;
}

Measured memory_bytes: 256
n, y = gets.strip.split.map(&:to_i)
ans = [-1, -1, -1]

(0..n).each do |i|
  (0..n - i).each do |j|
    k = n - i - j
    ans = [i, j, k] if i * 10000 + j * 5000 + k * 1000 == y
  end
end

puts ans.join(' ')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

template<class T> struct Dinic {
  struct Edge { int to, rev; T cap; };
  const T inf = numeric_limits<T>::max();
  const int n;
  VV<Edge> g;
  V<> dist, i;
  Dinic(int n) : n(n), g(n), dist(n), i(n) {}
  void add_edge(int from, int to, T cap) {
    assert(from != to);
    assert(cap >= 0);
    if (!cap) return;
    g[from].emplace_back(Edge{to, (int) g[to].size(), cap});
    g[to].emplace_back(Edge{from, (int) g[from].size() - 1, 0});
  }
  void bfs(int s) {
    fill(begin(dist), end(dist), -1);
    queue<int> que;
    dist[s] = 0;
    que.push(s);
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (const auto& e : g[v]) {
        if (dist[e.to] != -1 or !e.cap) continue;
        dist[e.to] = dist[v] + 1;
        que.push(e.to);
      }
    }
  }
  T dfs(int v, int s, T f) {
    if (v == s) return f;
    for (; i[v] < (int) g[v].size(); ++i[v]) {
      Edge& e = g[v][i[v]];
      if (dist[e.to] >= dist[v] or !g[e.to][e.rev].cap) continue;
      T d = dfs(e.to, s, min(f, g[e.to][e.rev].cap));
      if (d > 0) {
        g[e.to][e.rev].cap -= d;
        e.cap += d;
        return d;
      }
    }
    return 0;
  }
  T max_flow(int s, int t) {
    assert(s != t);
    T res = 0;
    while (true) {
      bfs(s);
      if (dist[t] == -1) return res;
      fill(begin(i), end(i), 0);
      while (true) {
        T f = dfs(t, s, inf);
        if (!f) break;
        res += f;
      }
    }
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  VV<> g(n);
  UnionFind uf(2 * n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v, --u, --v;
    uf.unite(u, n + v);
    uf.unite(v, n + u);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  Dinic<int> d(n + 2);
  int S = n, T = S + 1;
  for (int v = 0; v < n; ++v) {
    if (uf.same(0, v)) {
      d.add_edge(S, v, 1);
      for (int w : g[v]) {
        d.add_edge(v, w, 1);
      }
    } else {
      d.add_edge(v, T, 1);
    }
  }
  cout << (2 * d.max_flow(S, T) == n ? "Second" : "First") << '\n';
}

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

using namespace std;

const int N = 1e5 + 5;

int t;
int n, m;
int par[N];
bool vis[N];

vector < vector < int > > v;

void fail(){
	cout << "No";
	exit(0);
}

void solve() {
	cin >> n >> m;
	v.resize(n + 5);
	for(int i = 0 ; i < m ; i++){
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}

	queue < int > q;

	q.push(1);
	vis[1] = true;
	while(q.size()){
		int node = q.front();
		q.pop();
		for(int to : v[node]){
			if(vis[to]) continue;
			else {
				q.push(to);
				vis[to] = true;
				par[to] = node;
			}
		}
	}
	for(int i = 1 ; i <= n; i++){
		if(!vis[i]) fail();
	}
		cout << "Yes" << endl;

		for(int i = 2 ; i <= n ; i++) {
			cout << par[i] << endl;
		}

}

int main(){
	t = 1;

	while(t--){
		solve();
	}
}

Measured memory_bytes: 10332
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vii vector <int>::iterator 
#define vd vector <double>
#define vdd vector <double>::iterator
#define vs vector <string>
#define vss vector <string>::iterator
#define vc vector <char>
#define vcc vector <char>::iterator
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
#define SORT(x)     sort(x.begin(),x.end())
#define fill(x,y)   memset(x, y, sizeof(x))
#define PI 2*acos(0.0)
#define fio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
bool isprime(int n){
    int i;
    if(n==1)
        return false;
    else if(n==2)
        return true;
    for(i=2;i*i<=n;i++){
        if(n%i==0)
            return false;
    }
    return true;
}
int main(){
    fio;
    ll n , a , b , cn=0 , flg=0 ,i;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a >> b;
        if(a==b)
            cn++;
        else
            cn=0;
        if(cn == 3)
            flg=1;
    }
    if (flg == 1 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

#define ll long long

vector<string> a;

void solve() {
    string tmp;
    cin >> tmp;
    a.push_back(tmp);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--)
        solve();
    cout << "AC x " << count(a.begin(), a.end(), "AC") << "\n";
    cout << "WA x " << count(a.begin(), a.end(), "WA") << "\n";
    cout << "TLE x " << count(a.begin(), a.end(), "TLE") << "\n";
    cout << "RE x " << count(a.begin(), a.end(), "RE") << "\n";
    return 0;
}

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

namespace ABC132
{
    class D2
    {
        static long[,] c;
        static void Main(string[] args)
        {
            //input
            var nk = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var n = nk[0]; var k = nk[1];
            var mod = 1000000007;
            init(4005);
            //for i: 0 - k
            //n-k_C_i * n-1_C_i
            for (long i = 1; i <= k; i++)
            {
                if (n - k + 1 < i) Console.WriteLine(0);
                else Console.WriteLine((CalcCombination(n - k + 1, i) * CalcCombination(k - 1, i - 1)) % mod);
            }
        }

        public static long[,] init(long x)
        {
            c = new long[x + 5, x + 5];
            c[0, 0] = 1;
            for (long i = 1; i <= x; i++)
            {
                for (long j = 0; j <= i; j++)
                {
                    if (j == 0) c[i, j] = c[i - 1, j];
                    else c[i, j] = (c[i - 1, j] + c[i - 1, j - 1]) % 1000000007;
                }
            }
            return c;
        }

        public static long CalcCombination(long n, long k)
        {
            return c[n, k];
        }

    }
}


Measured memory_bytes: 138452
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if((s[2]==s[3])&&(s[4]==s[5]))
	{
		cout<<"Yes"<<"\n";
	}
	else
	{
		cout<<"No"<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3652
int ans = 0;
#include <bits/stdc++.h>

using namespace std;

int main(){
   int ans = 0;
  
  int a, b, c;
  
  cin >> a >> b >> c;
  
  for(int i = a; i < b + 1; i++){
  
   
    if(i % c == 0) ans++;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct{
    int a,b,c,d,e,f;
}DICE;
int main(void){
    DICE *p;
    int u,v,w,x,y,z,length,i;
    p=malloc(sizeof(DICE)*1);
    char M[100]={};
    scanf("%d %d %d %d %d %d",&u,&v,&w,&x,&y,&z);
    p->a=u; p->b=v; p->c=w; p->d=x; p->e=y; p->f=z;
    scanf("%s",M);
    length=strlen(M);
    for(i=0;i<length;i++){
        if(M[i]=='E'){
             (p+i+1)->c=(p+i)->a; (p+i+1)->a=(p+i)->d; (p+i+1)->d=(p+i)->f; (p+i+1)->f=(p+i)->c; 
             (p+i+1)->b=(p+i)->b; (p+i+1)->e=(p+i)->e;
        }
        if(M[i]=='N'){
             (p+i+1)->e=(p+i)->a; (p+i+1)->a=(p+i)->b; (p+i+1)->b=(p+i)->f; (p+i+1)->f=(p+i)->e; 
             (p+i+1)->c=(p+i)->c; (p+i+1)->d=(p+i)->d;
        }
        if(M[i]=='S'){
             (p+i+1)->e=(p+i)->f; (p+i+1)->f=(p+i)->b; (p+i+1)->b=(p+i)->a; (p+i+1)->a=(p+i)->e; 
             (p+i+1)->c=(p+i)->c; (p+i+1)->d=(p+i)->d; 
        }
        if(M[i]=='W'){
             (p+i+1)->f=(p+i)->d; (p+i+1)->d=(p+i)->a; (p+i+1)->a=(p+i)->c; (p+i+1)->c=(p+i)->f; 
             (p+i+1)->b=(p+i)->b; (p+i+1)->e=(p+i)->e;   
        }
    }
    printf("%d\n",p[i].a);
    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int main (void)
{
    int debt = 100000;
    int weeks, interest;
    int i;

    scanf("%d", &weeks);

    for(i = 1; i <= weeks; i++){
        interest = debt * 5 / 100;
        if(interest % 1000 >= 5){
            interest /= 1000;
            interest++;
            interest *= 1000;
        }
        else{
            interest /= 1000;
            interest *= 1000;
        }
        debt += interest;
    }
    printf("%d\n", debt);

    return (0);
}


Measured memory_bytes: 2044
N, Y = gets.split.map(&:to_i)
0.upto(N) do |n1|
    0.upto(N-n1) do |n2|
        if (10000 * n1 + 5000 * n2 + 1000 * (N-n1-n2) == Y)
            print("#{n1} #{n2} #{N-n1-n2}")
            exit
        end
    end
end
print("-1 -1 -1")

Measured memory_bytes: 1788
function main()
	mod=10^9+7
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	ans=0
	for a=A
		ans+=invmod(a,mod)
		ans%=mod
	end
	for i=2:10^3
		c=0
		for j=1:N
			n=0
			while A[j]%i==0
				A[j]=div(A[j],i)
				n+=1
			end
			if c<n
				c=n
			end
		end
		ans=ans*i^c%mod
	end
	sort!(A)
	i=1
	while i<=N&&A[i]==1
		i+=1
	end
	while i<=N
		while i<N&&A[i]==A[i+1]
			i+=1
		end
		ans=ans*A[i]%mod
		i+=1
	end
	println(ans)
end
main()


Measured memory_bytes: 169448
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  int R;
  cin >> R;
  if(R<1200){
    cout << "ABC\n";
    return 0;
  }else if(R<2800){
    cout << "ARC\n";
    return 0;
  }

  cout << "AGC\n";
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }

/*
 <url:https://beta.atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(S:chars);
    let mut S:Vec<char> = S;
    println!("{}",if S.len()==2{ S.into_iter().collect::<String>()}else{S.into_iter().rev().collect::<String>()});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 100005
int a[N];
int res[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read(),res[a[i]]=i;
	for(int i=1;i<=n;i++) printf("%d ",res[i]);
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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


int main(){

    string s;
    char st;
    int q,counter=0,a,b;
    cin>>s>>q;
    deque<char> dq;
    for(char a:s){
        dq.push_back(a);
    }
    rep(i,q){
        cin>>a;
        if(a==1){
            counter++;
        }
        else{
            cin>>b>>st;
            if(b==1 and counter%2==0 or b==2 and counter%2==1){
                dq.push_front(st);
            }
            else{
                dq.push_back(st);
            }
        }
    }
    if(counter%2==1){
        while(!dq.empty()){
            cout<<dq.back();
            dq.pop_back();
        }
    }
    else{
        while(!dq.empty()){
            cout<<dq.front();
            dq.pop_front();
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)

int main() {
	char s[10001],*pt;
	int J, I;
	while (~fscanf(stdin, "%s", s) != NULL) {
		J = I = 0;
		pt = s;
		while (*pt) {
			if (*pt == 'J'&&*(pt + 1) == 'O'&&*(pt + 2) == 'I')  J++;
			else if (*pt == 'I'&&*(pt + 1) == 'O'&&*(pt + 2) == 'I') I++;
			pt++;
		}
		P(d, J);
		P(d, I);
	}
	return 0;
}

Measured memory_bytes: 556
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Exception
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.Trans.State.Strict
import           Data.Array.Base
import           Data.Array.ST                    (STUArray, runSTUArray)
import           Data.Bits
import           Data.Bool
import qualified Data.ByteString.Char8            as B
import           Data.Char
import           Data.Coerce
import qualified Data.Foldable                    as F
import           Data.Function
import           Data.Int
import qualified Data.IntMap.Strict               as IM
import qualified Data.IntSet                      as IS
import qualified Data.List                        as L
import qualified Data.Map.Strict                  as M
import           Data.Monoid
import           Data.Ord
import qualified Data.Set                         as S
import           Data.STRef
import           Data.Tuple
import           Data.Word
import           Debug.Trace
import           GHC.Arr                          (Array, Ix (..), STArray)
import           GHC.Exts
import           System.Exit
import           System.IO

main :: IO ()
main = do
    [a,b,c,k] <- map read.words <$> getLine
    putStrLn . maybe "Unfair" show $ solve a b c k

solve a b c k
    | res > limit = Nothing
    | otherwise = Just res
  where
    !res | odd k = b - a
         | otherwise = a - b

limit :: Integer
limit = 10 ^ 18


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

int main() {
    string S; cin >> S;
    bool flag = true;
    for(int i = 0; i < S.length(); i++) {
        if (i % 2 == 0) {
            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
                flag = false;
            }
        } else {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
                flag = false;
            }
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

n = int(input())
a = list(map(int, input().split()))

def gcd(a, b):
    while True:
        if b == 0:
            return a
        a, b = b, a % b

lcm = 1
for i in a:
    g = gcd(lcm, i)
    lcm *= i // g

ans = 0
mod = 10**9 + 7
for i in a:
    ans += lcm // i
ans %= mod
print(ans)


Measured memory_bytes: 4084
#include<iostream>
#include<cstring>
using namespace std;
long long int n,a,b;
long long int h[100007];

bool check(int x){
	long long int s=0;
	long long int i,j,k;
	for(i=0;i<n;i++){
		k=h[i]-x*b;
		if(k>0)s+=(k-1)/(a-b)+1;
	}
	if(s<=x)return true;
	return false;
}

int main(){
	long long int s[2];
	int i,j,k;
	cin>>n>>a>>b;
	for(i=0;i<n;i++){
		cin>>h[i];
	}
	s[0]=0;
	s[2]=1000000007;
	while(s[2]-s[0]>1){
		s[1]=(s[0]+s[2])/2;
		if(check(s[1]))s[2]=s[1];
		else s[0]=s[1];
	}
	cout<<s[2]<<endl;
	return 0;
}
		




Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 12 11:04:24 2020

@author: liang
"""

W, H, x, y = map(int, input().split())

ans = [0] * 2

ans[0] = H*W/2
if x == W/2 and y == H/2:
    ans[1] = 1
else:
    ans[1] = 0
print(" ".join(map(str, ans)))

Measured memory_bytes: 9156
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}

int main(){
    string s;
    cin>>s;
    int n=s.size(),ch=0,p=0;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(s[i]=='W'){
            ans+=p;
        }else{
            p++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

typedef long long LL;
const int N = 55;

const LL MAX = (LL)1e16 + 1000;

LL a[N];

int main() {
  LL K;
  scanf("%lld", &K);
  for (LL n = 2; n <= 50; n++) {
    LL k = K;
    for (int j = 0; j < n; j++) {
      k -= (K + 1) / (n + 1);
      a[j] = n - K - 1 + (K + 1) / (n + 1) * (n + 1);
      if (k < 0) break;
    }

    if (k >= 0) {
      for (int j = 0; j < n; j++) {
        LL t = min(k, (MAX - a[j]) / (n + 1));
        a[j] += t * (n + 1);
        k -= t;
        if (k == 0) break;
      }

      if (k == 0) {
        printf("%lld\n", n);
        for (int j = 0; j < n; j++) {
          printf("%lld ", a[j]);
        }
        puts("");
        break;
      }
    }
  }
  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  char c[a];
  char kari;
  char first;
  int count = 0;
  int ans = 0;
  for(int i = 0;i < a;i++){
    cin >> kari;
    if(i == 0){
      if(kari == 'L'){
        c[count] = 'L';
        first = 'L';
      }
      if(kari == 'R'){
        c[count] = 'R';
        first = 'R';
      }
    }else{
      if(kari == c[count]){
        ans++;
      }else{
        count++;
        c[count] = kari;
      }
    }
  }
  if(count % 2 == 1){
    if((count+1)/2 <= b){
      ans += count;
    }else{
      ans += b*2;
    }
  }else{
    if(count/2 < b){
      ans += count;
    }else{
      ans += b*2;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 384
mod = 10**9+7
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
Tmax = (0,-1)
Amax = (0,-1)
h = [0]*N
not_confirmed = [True]*N
for i in range(N):
    if Tmax[0] < T[i]:
        Tmax = (T[i],i)
        not_confirmed[i] = False
    if Amax[0] < A[N-1-i]:
        Amax = (A[N-1-i],N-1-i)
        not_confirmed[N-1-i] = False
    h[i] = min(T[i],A[i])
if (Amax[1] < Tmax[1]) or (Tmax[0] != Amax[0]):
    print(0)
    exit()

ans = 1
for i in range(N):
    ans *= h[i] if not_confirmed[i] else 1
    ans %= mod
print(ans)

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


int main() {
    int a, b;
    cin >> a >> b;
    int time = a+b;
    if(time >= 24){
        cout << time - 24 << endl;
    }
    else{
        cout << time << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  long long sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  long long ans=1e15,t=0;
  for(int i=0;i<n-1;i++){
    t+=a[i];
    ans=min(ans,abs(t-(sum-t)));
  }
  cout << ans << endl;
}

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

int main(){
    Init();
    ll k; cin >> k;
    ll ans = 1;
    ll num = 7;
    vi chk(1000001, 0);

    while(num%k != 0){
        num %= k;
        chk[num]++;
        if(chk[num] >= 2){
            cout << -1 << endl;
            return 0;
        }
        num = num*10 +7;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11112
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007

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

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

ll fact(ll n){
    if(n==0)
        return 1;
    else
        return n*fact(n-1);
}

const int MAX = 1000001;

// array to store prime factors
int factor[MAX] = { 0 };

// function to generate all prime factors
// of numbers from 1 to 10^6
void generatePrimeFactors()
{
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (int i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (int i = 4; i < MAX; i += 2)
        factor[i] = 2;

    // A modified version of Sieve of Eratosthenes to
    // store the smallest prime factor that divides
    // every number.
    for (int i = 3; i * i < MAX; i++) {
        // check if it has no prime factor.
        if (factor[i] == i) {
            // Initializes of j starting from i*i
            for (int j = i * i; j < MAX; j += i) {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

// function to calculate number of factors
int calculateNoOFactors(int n)
{
    if (n == 1)
        return 1;

    int ans = 1;

    // stores the smallest prime number
    // that divides n
    int dup = factor[n];

    // stores the count of number of times
    // a prime number divides n.
    int c = 1;

    // reduces to the next number after prime
    // factorization of n
    int j = n / factor[n];

    // false when prime factorization is done
    while (j != 1) {
        // if the same prime number is dividing n,
        // then we increase the count
        if (factor[j] == dup)
            c += 1;

        /* if its a new prime factor that is factorizing n,
           then we again set c=1 and change dup to the new
           prime factor, and apply the formula explained
           above. */
        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        // prime factorizes a number
        j = j / factor[j];
    }

    // for the last prime factor
    ans = ans * (c + 1);

    return ans;
}

void solve(){

    ll N;
    cin>>N;
    generatePrimeFactors();
    ll i,c=0;
    for(i=1;i<N;i++){
        ll x = calculateNoOFactors(i);
        //cout<<x<<"\n";
        c += x;
    }
    cout<<c;



}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("D:\\codes\\1input.txt","r",stdin);
    //freopen("D:\\codes\\1output.txt","w",stdout);
    ll T=1;
    //cin>>T;
    for(ll t=1;t<=T;t++){
        //cout<<"Case #"<<t<<": ";
        solve();
        //cout<<"\n";
    }
}


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

class uf{
  int n;
  vector<int> rank, parent;
public:
  uf();
  uf(int _n){
    init(_n);
  }
  void init(int _n){
    n = _n;
    rank.resize(n);
    parent.resize(n);
    for (int i = 0; i < n; i++) {
      rank[i] = 0;
      parent[i] = i;
    }
  }
  int find(int x){
    if(x == parent[x])return x;
    else return parent[x] = find(parent[x]);
  }
  
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      parent[x] = y;
    }else{
      parent[y] = x;
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
};

struct sphere{
  double x, y, z, r;
};

struct edge{
  int from, to;
  double cost;
  bool operator<(const edge &a)const{
    return cost < a.cost;
  }
  bool operator>(const edge &a)const{
    return cost > a.cost;
  }
};
double dist(sphere a, sphere b){
  double res = sqrt( (a.x - b.x)*(a.x - b.x) +
                     (a.y - b.y)*(a.y - b.y) +
                     (a.z - b.z)*(a.z - b.z) ) - (a.r + b.r);
  if(res < 0)return 0;
  else return res;
}

vector<vector<edge> > makeG(vector<sphere> s){
  vector<vector<edge> > res(s.size());
  for (int i = 0; i < s.size(); i++) {
    for (int j = i + 1; j < s.size(); j++) {
      res[i].push_back((edge){i, j, dist(s[i], s[j])});
      res[j].push_back((edge){j, i, dist(s[i], s[j])});
    }
  }
  return res;
}

double kruscal(vector<vector<edge> > g){
  priority_queue<edge, vector<edge>, greater<edge> > que;
  uf utree(g.size());
  for (int i = 0; i < g.size(); i++) {
    for (int j = 0; j < g[i].size(); j++) {
      que.push(g[i][j]);
    }
  }
  double res = 0;
  while(!que.empty()){
    edge e = que.top();que.pop();
    if(!utree.same(e.to, e.from)){
      utree.unite(e.to, e.from);
      res += e.cost;
    }
  }
  return res;
}
int main(int argc, char *argv[]){
  int n;
  while(cin >> n, n){
    vector<sphere> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s[i].x >> s[i].y >> s[i].z >> s[i].r;
    }
    vector<vector<edge> >g = makeG(s);
    // for (int i = 0; i < g.size(); i++) {
    //   for (int j = 0; j < g[i].size(); j++) {
    //     std::cout << g[i][j].to << " " << g[i][j].cost << std::endl;
    //   }
    // }
    printf("%.3lf\n", kruscal(g));
  }
  return 0;
}

Measured memory_bytes: 2024
#include <cstdio>
#include <vector>
#include <algorithm>
#define INT_MAX 100000

using namespace std;

int lmap[201][201],smap[201][201];
int dp[201][2];
vector<int> order;

int main(){
  int n,m,r,i,j,k;
  while(scanf("%d %d",&n,&m),n){
    order.clear();
    for(i=0;i<201;i++){
      for(j=0;j<201;j++)
	lmap[i][j]=smap[i][j]=INT_MAX;
      dp[i][0]=dp[i][1]=0;
    }

    for(i=0;i<m;i++){
      int x,y,t;
      char w;
      scanf("%d %d %d %c",&x,&y,&t,&w);
      if(w=='L')
	lmap[x][y]=lmap[y][x]=min(lmap[x][y],t);
      else
	smap[x][y]=smap[y][x]=min(smap[x][y],t);
    }
    
    scanf("%d",&r);
    for(i=0;i<r;i++){
      scanf("%d",&j);
      order.push_back(j);
    }

    for(i=1;i<=n;i++) lmap[i][i]=smap[i][i]=0;

    for(k=1;k<=n;k++)
      for(i=1;i<=n;i++)
	for(j=1;j<=n;j++){
	  lmap[i][j] = min(lmap[i][j],lmap[i][k]+lmap[k][j]);
	  smap[i][j] = min(smap[i][j],smap[i][k]+smap[k][j]);
	}
    
    // for(i=1;i<=n;i++){
    //   for(j=1;j<=n;j++)
    // 	if(lmap[i][j]<INT_MAX)
    // 	  printf("%3d ",lmap[i][j]);
    // 	else
    // 	  printf("--- ");
    //   putchar('\n');
    // }
    // putchar('\n');
    // for(i=1;i<=n;i++){
    //   for(j=1;j<=n;j++)
    // 	if(smap[i][j]<INT_MAX)
    // 	  printf("%3d ",smap[i][j]);
    // 	else
    // 	  printf("--- ");
    //   putchar('\n');
    // }
    // putchar('\n');

    for(i=r-2;i>=0;i--)
      for(j=1;j<=n;j++){
	int mint=INT_MAX;
	for(k=1;k<=n;k++){
	  int tmp;
	  if(k!=j)
	    tmp = dp[k][~i&1]+lmap[order[i+1]][k]+smap[k][j]+lmap[j][order[i]];
	  else
	    tmp = dp[k][~i&1]+lmap[order[i+1]][order[i]];
	  mint = min(mint,tmp);
	}
	dp[j][i&1] = mint;
      }

    printf("%d\n",dp[order[0]][0]);
  }
}

Measured memory_bytes: 1140
/*..................................
manojeet24
....................................*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fl(i,a,b) for(int i=a;i<b;i++)
#define flr(i,a,b) for(int i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
int dp[3003][3003];
//for finding only the length of the LCS;
int solve(string s,string t,int n1,int n2)
{
    if(n1==-1 || n2==-1)
        return 0;
    if(dp[n1][n2]>0)
        return dp[n1][n2];
    if(s[n1]==t[n2])
        return dp[n1][n2]=solve(s,t,n1-1,n2-1)+1;
    else
        return dp[n1][n2]=max(solve(s,t,n1,n2-1),solve(s,t,n1-1,n2));
}
string lcs(string s,string t,int n1,int n2)
{
    string ans;
    int dp[n2+1][n1+1];
    fl(i,0,n1+1)
        dp[0][i]=0;
    fl(i,0,n2+1)
        dp[i][0]=0;
    fl(i,0,n2)
    {
        fl(j,0,n1)
        {
            if(t[i]==s[j])
                dp[i+1][j+1]=dp[i][j]+1;
            else
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
  /*  fl(i,0,n2+1)
    {
        fl(j,0,n1+1)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    int i=n2,j=n1;
    while(i>0 && j>0)
    {
        if(t[i-1]==s[j-1])
        {
            ans=t[i-1]+ans;
            i--,j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    return ans;
}
int main()
{
    string s,t;
    cin>>s>>t;
    int n1=s.size(),n2=t.size();
   // int ans=solve(s,t,n1-1,n2-1);
    //cout<<ans;
    cout<<lcs(s,t,n1,n2);
}




Measured memory_bytes: 35456
a,b,c=map(int,input().split())
k=int(input())
ans=0
while(b<=a):
    b=b*2
    ans+=1
m=max(a,b)
while(c<=m):
    c=c*2
    ans += 1
if ans<=k:
    print("Yes")
else:
    print("No")







Measured memory_bytes: 61652
<?php
list($n, $m) = ints();
for ($i = 0; $i < $n; ++$i) $a[] = ints();
for ($i = 0; $i < $m; ++$i) $c[] = ints();
for ($i = 0; $i < $n; ++$i) {
    $min_d = PHP_INT_MAX;
    $min_j = 0;
    for ($j = 0; $j < $m; ++$j) {
        $d = abs($c[$j][0] - $a[$i][0]) + abs($c[$j][1] - $a[$i][1]);
        if ($d < $min_d) {
            $min_d = $d;
            $min_j = $j;
        }
    }
    $ans[] = $min_j + 1;
}
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

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

Measured memory_bytes: 3768
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val fs = mutableMapOf<Long, Long>()

    for (i in 1L..n) {
        var y = i
        var x = 2L
        while (x * x <= i) {
            if (y % x == 0L) {
                fs[x] = (fs[x] ?: 0) + 1
                y /= x
                continue
            }
            x++
        }
        if (y > 1) fs[y] = (fs[y] ?: 0) + 1
    }

    var ans = 0

    // 75 * 1
    ans += fs.filter { it.value >= 74 }.count()
    // 25 * 3
    ans += fs.filter { it.value >= 24 }.count() * fs.filter { it.value >= 2 }.count().let { it - 1 }
    // 15 * 5
    ans += fs.filter { it.value >= 14 }.count() * fs.filter { it.value >= 4 }.count().let { it - 1 }
    // 5 * 5 * 3
    ans += fs.filter { it.value >= 4 }.count().let { it * (it - 1) / 2 } * fs.filter { it.value >= 2 }.count().let { it - 2 }

    println(ans)
}


Measured memory_bytes: 33716
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int[] a = new int[3];
for(int i = 0;i < 3;i++){
a[i] = sc.nextInt();
}
Arrays.sort(a);
System.out.println(a[2] - a[0]);
}}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
const ll INF = LLONG_MAX / 10;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    pair<ll, ll> BA[N];
    for(int i = 0; i < N; i++) {
        cin >> BA[i].second;
    }
    for(int i = 0; i < N; i++) {
        cin >> BA[i].first;
    }
    sort(BA, BA + N);
    pair<ll, ll> A[N];
    for(int i = 0; i < N; i++) {
        A[i] = {BA[i].second, i};
    }
    sort(A, A + N);
    bool isok = true;
    for(int i = 0; i < N; i++) {
        isok &= A[i].first <= BA[i].first;
    }
    if(!isok) {
        cout << "No" << endl;
        return 0;
    }
    int cnt = 0;
    for(int i = 0; A[i].second != 0; i = A[i].second) {
        cnt++;
    }
    if(cnt < N - 1) {
        cout << "Yes" << endl;
        return 0;
    }
    isok = false;
    for(int i = 0; i < N - 1; i++) {
        isok |= BA[i].first >= A[i + 1].first;
    }
    cout << (isok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    ll n; cin>>n;
    vll x(n), y(n), h(n);
    REP(i,n) cin>>x[i]>>y[i]>>h[i];
    // REP(i,3)cout<<x[i]<<endl;
    ll high=0;
    REP(i,101){
        REP(j,101){
            REP(k,n){
                // if(i==100 && j==0) cout<<h[k]<<endl;
                if (h[k]==0) continue;
                else{
                    high = h[k] + abs(i-x[k]) + abs(j-y[k]);
                    
                    break;
                }
            }
            bool ok = true;
            REP(k,n){
                ll part = high - abs(i-x[k]) - abs(j-y[k]);
                if (h[k]>0 && part != h[k]) ok = false;
                else if (h[k]==0 && part > 0) ok = false;
            }
            if (ok) {
                cout<<i<<' '<<j<<' '<<high<<endl;
                // cout<<"asssssss"<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 400010

char S[SIZE];
int memo_[SIZE];

int main(){
  int N;

  scanf("%s", S);
  N = strlen(S);

  int depth = 0;
  ll ans = 0;
  int* memo = memo_ + 200000;
  stack<pair<char,int>> st;

  for (int i=0; i<N; i++) {
    if (S[i] == '(') {
      st.push({'(', 0});
      memo[depth]++;
      depth++;
    } else if (S[i] == ')'){
      st.push({')', memo[depth]});
      memo[depth] = 0;
      depth--;
      ans += memo[depth];
    } else {
      auto p = st.top(); st.pop();
      if (p.first == '(') {
        depth--;
        memo[depth]--;
      } else {
        ans -= memo[depth];
        depth++;
        memo[depth] = p.second;
      }
    }
    cout << ans << endl;
  }


  return 0;
}



Measured memory_bytes: 5664
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
using namespace std;

int main()
{
	int x, y;

	cin >> x >> y;

	printf("%d", (x + y) % 24);

	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};

int n;
ll a[300010],sum=0;

int main(int argc, char const *argv[]) {
  std::cin >> n;
  n*=3;
  for(int i=0; i<n; i++) std::cin >> a[i];
  sort(a,a+n);
  ll cnt=0,j=n-2;
  while(cnt<n/3){
    sum+=a[j];
    cnt++;
    j-=2;
  }
  std::cout << sum << '\n';
  return 0;
}


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

int main() {
  int A, B; cin >> A >> B;
  string S = "", T = "";
  for (int i = 0; i < B; i++) S += (char)('0' + A);
  for (int i = 0; i < A; i++) T += (char)('0' + B);
  cout << min(S, T) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace ZDY{
    #define res register
    #define ri res ll
    #define ll long long
    #define db double
    #define sht short
    #define il inline
    #define MB template <class T>
    #define Fur(i,x,y) for(ri i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(ri i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fl(i,x) for(ri i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define inf 21474836473
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdin)
    #define l2(n) (ceil(log2(n)))
    MB il T ABS(T x){return x>0?x:-x;}
    MB il T MAX(T x,T y){return x>y?x:y;}
    MB il T MIN(T x,T y){return x<y?x:y;}
    MB il T GCD(T x,T y){return y?GCD(y,x%y):x;}
    //#define gc() getchar()
    il char gc(){static char buf[1000000],*s,*t;return s==t?(((t=(s=buf)+fread(buf,1,1000000,stdin))==s)?-1:*s++) : *s++;}
    il int gi(){int x=0,f=0;char c=gc();while(c<'0'||'9'<c){if(c=='-')f=!f;c=gc();}while('0'<=c&&c<='9'){x=x*10+c-48;c=gc();}return f?(-x):x;}
}using namespace ZDY;using namespace std;
#define N 100010
int n,a[N],k,ans=1000000000;
int main(){
    n=gi();k=gi();
    Fur(i,1,n)a[i]=gi();
    sort(a+1,a+n+1);
    Fur(i,1,n-k+1)
        ans=MIN(ans,a[i+k-1]-a[i]);
    printf("%d\n",ans);
}

Measured memory_bytes: 1664
package main

import (
	"fmt"
	"sort"
)

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	n := nextInt()
	p := make([]int, n)

	for i := range p {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	p[n-1] /= 2

	ans := 0
	for _, v := range p {
		ans += v
	}
	fmt.Println(ans)
}


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

int main(){
	while(1){
				int n,s,t,max,min,sum = 0;
				cin >> n;
				if(n == 0)break;
				else{
					cin >> s;
					max = min = sum = s;
					for(int i = 0; i < (n - 1);++i){
						cin >> t;
						if( t > max ){ max = t;}
						if( t < min ){ min = t;}
						sum += t;
					}
					cout << (sum - max - min) / (n - 2) << endl;
				}

	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    string s;
    cin>>s;
    ll x=1,k,n=s.size();
    cin>>k;
    rep(i,n-1) if(s[i]!=s[i+1]) x=0;
    if(x){cout<<k*n/2;return 0;}
    if(s[0]==s[n-1]){
        int left=1,right=1;
        rep(i,n-1){
            if(s[i]==s[i+1]) left++;
            else break;
        }
        rep(i,n-1){
            if(s[n-i-1]==s[n-i-2]) right++;
            else break;
        }
        ll sum=0,a=1;
        for(int i=left;i<n-right;i++){
            if(s[i]==s[i+1]) a++;
            else sum+=a/2,a=1;
        }
        sum+=a/2;
        cout<<sum*k+left/2+right/2+(left+right)/2*(k-1);
    }
    else{
        ll sum=0,a=1;
        rep(i,n-1){
            if(s[i]==s[i+1]) a++;
            else sum+=a/2,a=1;
        }
        sum+=a/2;
        cout<<sum*k;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#define R register
#define IN inline
#define gc getchar()
#define W while
#define ll long long
#define MX 300050
#define mod 1000000007
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	W (!isdigit(c)) c = gc;
	W (isdigit(c))
	x = (x << 1) + (x << 3) + c - 48, c = gc;
}
short go[8][2] = {{2, 1}, {4, 3}, {6, 5}, {3, 3}, {7, 1}, {2, 1}, {2, 2}, {4, 4}};
ll dp[MX][8];
char buf[MX];
int len;
int main(void)
{
	scanf("%s", buf + 1);
	len = std::strlen(buf + 1);
	dp[0][0] = 1; R int j;
	for (R int i = 0; i < len; ++i)
	{
		for (j = 0; j <= 7; ++j)
		{
			if(buf[i + 1] != '0') dp[i + 1][go[j][1]] += dp[i][j], dp[i + 1][go[j][1]] %= mod;
			if(buf[i + 1] != '1') dp[i + 1][go[j][0]] += dp[i][j], dp[i + 1][go[j][0]] %= mod;
		}
	}
	printf("%d\n", (dp[len][1] + dp[len][3]) % mod);
}

Measured memory_bytes: 19328