akhauriyash/Code-Regression huggingface dataset:
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    v[n-1]/=2;
    cout<<accumulate(all(v),0);

    

    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string a,b,c;cin >>a>>b>>c;
   cout <<(char)(a[0]-'a'+'A');
   cout <<(char)(b[0]-'a'+'A');
   cout <<(char)(c[0]-'a'+'A')<<endl;
}


Measured memory_bytes: 3596
N,M=map(int,input().split())
KA=[]
A=[]
a=0
for i in range(N):
    KA.append(list(map(int,input().split())))
for i in range(N):
    KA[i].remove(KA[i][0])
for i in range(N):
    for j in range(len(KA[i])):
        A.append(KA[i][j])
for i in range(1,M+1):
    if N==A.count(i):
        a+=1
print(a)

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string>
using namespace std;

vector<long long > gr[100001];
long long n, m, used[100001];
long long dfs(long long vert) {
	used[vert] = 1;
	if (gr[vert].size() != 0) {
		for (auto i : gr[vert]) {
			if (!used[i]) {
				used[vert] = max(used[vert], dfs(i) + 1);
			}
			else used[vert] = max(used[vert], used[i] + 1);
		}
	}
	return used[vert];
}

int main() {
	cin >> n >> m;
	long long a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		gr[a].push_back(b);
	}
	for (int i = 1; i < n + 1; i++) {
		if (!used[i]) {
			dfs(i);
		}
	}
	long long ans = 0;
	for (int i = 1; i < n + 1; i++) {
		ans = max(ans, used[i]);
	}
	cout << ans - 1;
	//system("pause");
	return 0;
}

Measured memory_bytes: 7808
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List
import Data.Maybe


main = do
    [n, m] <- map read . words <$> getLine
    xs <- sort . map read . words <$> getLine
    let inter = sort . zipWith subtract xs $ tail xs
    print $ sum $ take (max 0 $ m - n) inter

Measured memory_bytes: 32892
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);

		String O=sc.next();
		String E=sc.next();
		String res="";
		if(O.length()>E.length()) {
			for(int i=0; i<E.length(); i++) {
				res=res+O.charAt(i)+""+E.charAt(i);
			}
			res=res+O.charAt(O.length()-1)+"";
			System.out.println(res);
		}

		if(O.length()==E.length()) {
			for(int i=0; i<E.length(); i++) {
				res=res+O.charAt(i)+""+E.charAt(i);
			}
			System.out.println(res);
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i, n) for (long i = 0; i < (n); ++i)

using namespace std;

void solve(long N) {
  long total = 0;
  vector<long> ix;
  // sum up ascending order
  for (long i = 1; total < N; i++) {
    ix.emplace_back(i);
    total += i;
  }

  // remove excess
  if (total > N) {
    auto ext = find(ix.cbegin(), ix.cend(), total - N);
    ix.erase(ext);
  }

  // print out
  rep (i, ix.size())
    cout << ix[i] << endl;
}

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

  long N;
  cin >> N;
  solve(N);
  return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define P pair<int, int>
struct data{
	int place;
	int cost;

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};



int main(){
	int n, t, a;
	int h[1001] = {};
	cin >> n >> t >> a;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	int ans = -1;
	double gosa = 999999;
	for(int i = 1; i <= n; i++){
		double g = abs(a - (t*1.0 - h[i]*0.006));
		if(g < gosa){
			ans = i;
			gosa = g;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim arrayA As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim ans As Double = 0
    For i As Integer = 0 To n - 1
      ans += 1 / arrayA(i)
    Next
    Console.WriteLine((1 / ans).ToString())
  End Sub
End Class

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	ll n;
	cin >> n;
	ll ans = (n * (n - 1)) / 2;
	cout << ans;

}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    if(n%2 == 0) cout << n/2-1;
    else cout << n/2;
 }



Measured memory_bytes: 256
#include <bits/stdc++.h>
template<typename T, typename U>
inline auto cmn (T& a, U b) {if (a > b) {a = b; return true;} return false;}
template<typename T, typename U>
inline auto cmx (T& a, U b) {if (a < b) {a = b; return true;} return false;}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  constexpr int inf = 1 << 30;
  auto p  = std::vector<int>(n);
  for (auto& x : p) std::cin >> x;
  auto dp = std::vector<std::vector<int>>(n + 1, std::vector<int>(4, inf));
  dp.at(0).at(0) = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) {
      auto crr = dp.at(i).at(j);
      if (crr == inf) continue;
      for (int k = j; k <= p.at(i); k++) {
        cmn(dp.at(i + 1).at(p.at(i) - k), crr + k * (1 + (i != 0)));
      }
    }
  }
  int ret = inf;
  for (int j = 0; j < 4; j++) {
    auto crr = dp.at(n).at(j);
    if (crr == inf) continue;
    cmn(ret, dp.at(n).at(j) + j);
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 3312
import java.util.*;
 
class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int n1 = n/100;
   int n2 = (n-n1*100)/10;
   int n3 = n-n1*100-n2*10;
   if(n1==7||n2==7||n3==7){
		System.out.println("Yes");
   }else{
     System.out.println("No");
   }
 }
}


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

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

	if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

signed main(){
    FASTER;
    int x,n;cin>>x>>n;
    vi v(n);cin>>v;
    sort(all(v));
    int ans=INF,an;
    for(int i=-1e5;i<=1e5;i++){
        if(binary_search(all(v),i))continue;
        if(ans>abs(i-x)){
            ans=abs(i-x);
            an=i;
        }
    }
    cout<<an;
    
}



Measured memory_bytes: 3656
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
if(a*b>c*d){
System.out.println(a*b);
}else{
System.out.println(c*d);
}


}
}

Measured memory_bytes: 23124
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
           int N = int.Parse(Console.ReadLine());

            int Ans = 1000-N % 1000;

          if(Ans==1000)Ans=0;
            Console.WriteLine(Ans);
        }
    }
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAX INT_MAX
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 998244353
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
ll fastPowMod(ll a, ll p,ll mod){ if(p==0) return 1; ll z = fastPowMod(a,p/2,mod); z = (z*z)%mod; if(p%2) z = (z*a)%mod; return z; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}


void solve()
{
    int n,k;
    cin>>n>>k;
    vi a(n+1,0);
    srep(i,1,n) cin>>a[i];
    vi dp(n+1,MAX);
    dp[1]=0;
    srep(i,2,n)
    {
        for(int j=i-1;j>=max(i-k,1);j--)
        {
            dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];
}

int main()
{
    fastio
    /*int t;
    cin>>t;
    
    rep(i,t)
    {*/
        solve();
        cout<<"\n";
    //}
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
ans = 0
for i in range(1, n+1):
    count = 0
    if i % 2 == 0:
        continue
    for j in range(1, i+1):
        if i % j == 0:
            count += 1
    if count == 8:
        ans += 1
print(ans)

Measured memory_bytes: 39792
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

struct UnionFind {
  vector<int> d;
  UnionFind() {}
  UnionFind(int n) :d(n, -1) {}
  bool unite(int x, int y) {
    int a = root(x), b = root(y);
    if (a == b) return false;
    if (size(a) < size(b)) swap(a, b);
    d[a] += d[b];
    d[b] = a;
    return true;
  }
  int size(int v) { return -d[root(v)]; }
  int root(int v) { return d[v] < 0 ? v : d[v] = root(d[v]); }
  bool same(int x, int y) { return root(x) == root(y); }
};

void Calc() {
  var(int, n, m);
  int ans = 0;
  vector<pair<int, int>> a(m);
  rep(i, m) {
    in, a[i].first, a[i].second;
    a[i].first--, a[i].second--;

  }
  rep(i, m) {
    UnionFind uni(n);
    rep(j, m) {
      if (i == j)continue;
      uni.unite(a[j].first, a[j].second);
    }
    err(n, uni.size(a[0].first));
    if (n != uni.size(a[0].first)) {
      ans++;
    }
  }
  cout << (ans) << endl;

}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define all_comb(b, n, k) for(LU b = (1LLU << (k)) - 1; ! (b >> (n)); \
b = (0 < (k) ? (b | b-1) + (1LLU << (__builtin_popcountll(b ^ ((b | b-1) + 1)) - 2)) : 1LLU << (n)))

#define bit(b, i) (((b) >> (i)) & 1)
#define bc __builtin_popcountll

int n, a[21][21];

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, n) {
		cin >> a[i][j];
	}
	}
	
	LL MOD = 1e9 + 7;
	vector<LL> dp(1 << n);
	dp.front() = 1;
	inc(i, n) {
	inc(j, n) {
		if(a[i][j] == 0) { continue; }
		all_comb(b, n, i) {
			if(bit(b, j) == 0) { (dp[b | (1 << j)] += dp[b]) %= MOD; }
		}	
	}
	}
	
	cout << dp.back() << endl;
	
	return 0;
}


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

const int MOD = 1000000007;
template<class T> inline void add_mod(T &a, const T b) {
	a += b;
	if(a >= MOD) a -= MOD;
}

long dp[35];

int main(){
	int n;

	dp[0] = 1;
	for(int i = 1; i <= 30; i++) {
		if(i - 1 >= 0) add_mod(dp[i], dp[i-1]);
		if(i - 2 >= 0) add_mod(dp[i], dp[i-2]);
		if(i - 3 >= 0) add_mod(dp[i], dp[i-3]);
	}

	while(true) {
		scanf("%d", &n);
		if(n == 0) break;
		printf("%ld\n", dp[n] / 3650 + 1);
	}
}



Measured memory_bytes: 3184
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 100005
using namespace std;

int n;
struct Node{
	int l,r;
}node[N]; 

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

bool cmp(Node p,Node q){
	if(p.r!=q.r)return p.r<q.r;
	return p.l<q.l;
}

int main(void){
	n=read();
	for(int i=1;i<=n;i++){
		int w,len;
		w=read();
		len=read();
		node[i].l=w-len;
		node[i].r=w+len;
	}
	sort(node+1,node+1+n,cmp);
	int now=-0x3f3f3f3f,ans=0;
	for(int i=1;i<=n;i++){
		if(node[i].l>=now){
			ans++;
			now=node[i].r;
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)

int f(int a) {
	if (a % 4 == 0) {
		return 4;
	}
	else if (a % 2 == 0) {
		return 2;
	}
	else {
		return 1;
	}
}

int main() {

	int n; cin >> n;

	map<int, int> m;
	for (int i = 0; i < n; i++) {
		int buf; cin >> buf;
		m[f(buf)]++;
	}

	if (m[2] > 0) {
		m[1]++;
	}

	if (m[4] + 1 >= m[1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    string yes = "YES", no = "NO";
    string s;
    cin >> s;
    map<char, int> mp;
    for(auto& c : s) {
        mp[c]++;
    }
    vi v{mp['a'],mp['b'],mp['c']};
    sort(all(v));
    cout << (v.back()-v.front() <= 1 ? yes : no) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;cin>>a;cin>>b;
  int c=2;
  int d=a.size(),e=b.size();
  if(d>e)c=0;
  if(d<e)c=1;
  if(d==e){
    for(int i=0;i<d;i++){
      int y=a[i]-'a'+49;
      int z=b[i]-'a'+49;
      if(y>z){
        c=0;
        break;
      }
      if(y<z){
        c=1;
        break;
      }
    }
  }
  if(c==0)cout<<"GREATER"<<endl;
  if(c==1)cout<<"LESS"<<endl;
  if(c==2)cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Synthetic Kadomatsu
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int M = 3;
const int MAX_N = 8;
const int NBITS = 1 << MAX_N;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[M], ls[MAX_N], bnums[NBITS], lsums[NBITS];
int dp[M + 1][NBITS];

/* subroutines */

inline int calcmp(int bits, int a) {
  return (bnums[bits] - 1) * 10 + abs(a - lsums[bits]);
}

inline void setmin(int &a, int b) { if (a > b) a = b; }

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < M; i++) scanf("%d", as + i);
  for (int i = 0; i < n; i++) scanf("%d", ls + i);

  int nbits = 1 << n;
  bnums[0] = lsums[0] = 0;
  for (int bits = 1, msb = 1, bi = 0; bits < nbits; bits++) {
    if ((msb << 1) <= bits) msb <<= 1, bi++;
    bnums[bits] = bnums[bits ^ msb] + 1;
    lsums[bits] = lsums[bits ^ msb] + ls[bi];
  }

  for (int i = 0; i <= M; i++) fill(dp[i], dp[i] + nbits, INF);
  dp[0][0] = 0;

  for (int i = 0; i < M; i++)
    for (int bits = 0; bits < nbits; bits++)
      if (dp[i][bits] < INF)
	for (int bitsi = 1; bitsi < nbits; bitsi++)
	  if (! (bits & bitsi))
	    setmin(dp[i + 1][bits | bitsi],
		   dp[i][bits] + calcmp(bitsi, as[i]));

  int mind = INF;
  for (int bits = 0; bits < nbits; bits++) setmin(mind, dp[M][bits]);

  printf("%d\n", mind);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    long N, A, B;
    cin >> N >> A >> B;
    long waru  = N / (A + B);
    long amari = N % (A + B);
    if(A == 0){
        cout << "0" << endl;
    }else if(amari >= A){
        cout << waru * A + A << endl;
    }else if(amari < A){
        cout << waru * A + amari << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int,int>
#define vvi vector<vector<int> >
#define vpi vector<pii>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define lowbit(x) x&(-x)
#define HS 173LL
using namespace std;
int read()
{
	int x = 0;
	char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch))
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x;
}
int dx1[20],dx2[20];
long long d,p[18];
vector<long long> v;
void dfs(int s,int e,vector<pair<long long,long long>> &w,long long val,long long cnt)
{
	if(s==e)
	{
		w.pb(mp(val,cnt));
		return;
	}
	for(int i=-9;i<=9;i++)
		if(s==0)
			dfs(s+1,e,w,val+i*v[s],cnt*dx2[i+10]);
		else
			dfs(s+1,e,w,val+i*v[s],cnt*dx1[i+10]);
}
long long solve(int l)
{
	v.clear();
	for(int i=0;l-i-1>i;i++)
		v.pb(p[l-i-1]-p[i]);
	vector<pair<long long,long long>> v1,v2;
	dfs(0,(v.size()+1)/2,v1,0,1);
	dfs((v.size()+1)/2,v.size(),v2,0,1);
	map<long long,long long> mp;
	for(auto i:v2)
		mp[i.first]+=i.second;
	long long ret=0;
	for(auto i:v1)
		ret+=mp[i.first+d]*i.second;
	if(l%2)
		ret*=10LL;
	return ret;
}
int main()
{
	p[0]=1LL;
	for(int i=1;i<18;i++)
		p[i]=p[i-1]*10LL;
	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
			dx1[i-j+10]++;
	for(int i=1;i<10;i++)
		for(int j=0;j<10;j++)
			dx2[i-j+10]++;
	cin>>d;
	long long res=0LL;
	for(int i=2;i<=18;i++)
		res+=solve(i);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 207040
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    int cnt = 1;
    int pre = 0;
    bool init = 1;
    rep(i,n){
        if(i == 0) continue;
        if(v[i-1] < v[i]){
            if(pre == 0 && !init){
                cnt++;
                init = 1;
            }else if(init){
                pre = 1;
                init = 0;
            }
        }else if(v[i-1] > v[i]){
            if(pre == 1 && !init){
                cnt++;
                init = 1;
            }else if(init){
                pre = 0;
                init = 0;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3652
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 105005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n-(h-1))*(n-(w-1)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
   int a,b;
   cin>>a>>b;
   int cur=1;
   for(int i=0; i<a; i++){
       if(cur+b<2*cur) cur+=b;
       else cur*=2;
   }
   cout<<cur;
    
    
    return 0;
    
}

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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    public void go() throws IOException
    {
        StringTokenizer tok = new StringTokenizer(in.readLine());
        int a = Integer.parseInt(tok.nextToken());
        tok = new StringTokenizer(in.readLine());
        String s = tok.nextToken();
        if (a < 3200)
        {
            out.println("red");
        }
        else
        {
            out.println(s);
        }

        out.flush();
        in.close();
    }

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


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

int main()
{
	double x1,y1;
	double x2,y2;
	double x3,y3;
	double xp,yp;
	double abc;
	double pab,pac,pbc;
	
	while(scanf("%lf %lf",&x1,&y1)!=EOF){
		scanf("%lf %lf",&x2,&y2);
		scanf("%lf %lf",&x3,&y3);
		scanf("%lf %lf",&xp,&yp);
		
		abc=(x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
		if(abc<0) abc*=(-1.0);
		
		pab=(x1-xp)*(y2-yp)-(x2-xp)*(y1-yp);
		if(pab<0) pab*=(-1.0);
		
		pac=(x1-xp)*(y3-yp)-(x3-xp)*(y1-yp);
		if(pac<0) pac*=(-1.0);
		
		pbc=(x2-xp)*(y3-yp)-(x3-xp)*(y2-yp);
		if(pbc<0) pbc*=(-1.0);
		
		if(abc==(pab+pac+pbc)){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

void __print(ll x) {cerr << x;}
void __print(ld x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

int main(){
	// #ifndef ONLINE_JUDGE
 //        freopen("../input.txt", "r", stdin);
 //        freopen("../output.txt", "w", stdout);
 //    #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    ll tc = 0;
    while(tc++ < t){
        ll n;cin>>n;
        vl cnt(n+1);
        ll cur = 7%n;
        ll ans = 1;
        while(1){
            if(cur == 0)    break;
            if(cnt[cur])    {ans = -1;break;}
            cnt[cur]++;
            cur = (cur*10 + 7)%n;
            ans++;
        }
        cout<<ans;
    }
}

Measured memory_bytes: 11112
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] x = new int[n];

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }

        int[] x1  = x.clone();
        Arrays.sort(x1);
        int med1 = x1[n/2];
        int med2 = x1[n/2-1];

        for (int i = 0; i < n; i++) {
            if (x[i] < med1)
                System.out.println(med1);
            else
                System.out.println(med2);
        }
    }
}


Measured memory_bytes: 91388
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

int main(void){
  //dp[i+1][s][j] = (i桁目までで条件を満たす数の総数)　s 未満フラグ01、j3フラグ01
  int n; cin >> n;
  int a[n]; rep(i,n) cin >> a[i];
  int ans = MOD;
  rep(i,101){
    int sum = 0;
    rep(j,n){
      sum += abs(i-a[j])*abs(i-a[j]);
    }
    if(sum < ans) ans = sum;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
//const ll mod = 1000'000'007;
#define int long long

//const int MAX = 1123456789;
const int MOD = 1000'000'007;

int com[212345],fact[212345];


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
}
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void factri(){
    fact[0]=1;fact[1]=1;
    rep(i,212345){
        fact[i+1]=(fact[i]*(i+1))%MOD;
    }
}
// テーブルを作る前処理
void COMinit(int N) {
    com[0]=1;
    com[1]=N;

    for(int i=1;i<=212345;i++){
        int t=((com[i-1]*(N-i+1)))%MOD;
        //dump(fact[i]);
        com[i]=(t)*(inv[i])%MOD;
    }
}

// 二項係数計算
long long COM(int k){
    return com[k]%MOD;
}

ll mod_pow(ll a, ll b, ll r) {
return b <= 0? 1: (b % 2? a: 1) * mod_pow(a * a % r, b / 2, r) % r;
}
signed main(){
    int N,a,b;

    cin>>N>>a>>b;
    factri();
    init();
    COMinit(N);
    int ans=0;
    ans+=COM(a)+MOD;ans%=MOD;
    ans+=COM(b)+MOD;ans%=MOD;
    dump(ans);
    dump((mod_pow(2,N,MOD)-1)%MOD);
    cout<<(((mod_pow(2,N,MOD)+MOD)%MOD -ans)-1 +MOD)%MOD<<endl;
 
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, M; cin >> N >> M;
    bool possible[N];
    int num_balls[N];
    rep(i, N){
        possible[i] = false;
        num_balls[i] = 1;
    }
    possible[0] = true;
    rep(i, M){
        int x, y;
        cin >> x >> y; x--; y--;
        num_balls[x]--; num_balls[y]++;
        if(possible[x] == true){
            possible[y] = true;
            if(num_balls[x] == 0) possible[x] = false;
        }
    }
    int ans=0;
    rep(i, N){
        if(possible[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

void solve(){}

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

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

    if(n%2==0){
        cout << setprecision(20) << (double)1/2 << endl;
    }else{
        double ans = 0;
        ans = (double)(n/2+1)/n;
        cout << setprecision(20) << ans << endl;
    }
    return 0;
}

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

int main() {
  int N; 
  cin >> N;
  if (N % 2 == 0) {
    cout << (N/2) * (N/2);
  }else{
    cout << ((N-1)/2)*((N-1)/2+1);
  }
}

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

int n;
vector<int> x, y;

double dist(int a, int b){
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b]));
}

bool solve(){
    for(int i=0;i<n;i++){
        if(dist(n, 0) + dist(0, i) >= dist(n+1, i)) return false;
    }
    return true;
}

int main(){
    while(1){
        cin >> n;
        if(n == 0) break;
        x.assign(n+2, 0);
        y.assign(n+2, 0);
        cin >> x[n] >> y[n] >> x[n+1] >> y[n+1];
        for(int i=0;i<n;i++){
            cin >> x[i] >> y[i];
        }

        if(solve()){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

int N,K;
vector<int> d;
vector<vector<int>> A;

void input(){
  cin >> N >> K;
  d.resize(K);
  A.resize(K, vector<int>());
  for(int i = 0; i < K; i++){
    cin >> d.at(i);
    A.at(i).resize(d.at(i));
    for(int j = 0; j < d.at(i); j++){
      cin >> A.at(i).at(j);
    }
  }
}

void solve(){
  int ans = 0;
  for(int i = 1; i<= N; i++){
    bool have = false;
    for(auto v : A){
      for(auto p : v){
        if(p == i) have = true;
      }
    }
    if(!have) ans++;
  }
  cout << ans << endl;
}

int main(){
  input();
  solve();
}

Measured memory_bytes: 3640
# from math import gcd
import sys
input = sys.stdin.readline
n = int(input())
As = list(map(int, input().split()))

def gcd(n, m):
    # 最大公約数
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return a

class segmented_tree:
    X_unit = 1 << 30
    X_f = lambda self, a, b: gcd(a,b)
    def __init__(self, N):
        self.N = N
        self.X = [self.X_unit] * (2*N)
        
    def build(self, seq):
        for i, x in enumerate(seq, self.N):
            self.X[i] = x 
        # 後ろから入れていく
        for i in range(self.N-1, 0, -1):
            self.X[i] = self.X_f(self.X[i<<1], self.X[i<<1|1])

    # 1点更新
    def set_val(self, i, x):
        i += self.N
        self.X[i] = x
        while i > 1:
            i >>= 1
            self.X[i] = self.X_f(self.X[i<<1],self.X[i<<1|1])
    
    # 区間取得
    def fold(self, l, r):
        l += self.N
        r += self.N
        vl = self.X[l]
        vr = self.X[r-1]
        # 外から決めていく
        while l < r:
            # print(l,r)
            if l & 1:
                vl = self.X_f(vl, self.X[l])
                l += 1
            if r & 1:
                r -= 1
                vr = self.X_f(vr, self.X[r])
            l >>= 1
            r >>= 1
        return self.X_f(vl,vr)
  
st = segmented_tree(n)
st.build(As)
mx = 0
for i in range(n):
    if i == 0:
        a = st.fold(i+1,n)
    else:
        a = st.fold(0,i)
    if i+1 < n:
        b = st.fold(i+1,n)
    else:
        b = a        
    mx = max(mx,gcd(a,b))
print(mx)

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end(), greater<int>());
    long sum = 0;
    for (int i = k; i < n; i++)
    {
        sum += h[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef double db;
int const xn=1e5+5;
int n,m,a[xn],t[xn],p[xn];
db d[xn],tt[xn];
ll k;
ll rd()
{
  ll ret=0,f=1; char ch=getchar();
  while(ch<'0'||ch>'9'){if(ch=='-')f=0; ch=getchar();}
  while(ch>='0'&&ch<='9')ret=ret*10+ch-'0',ch=getchar();
  return f?ret:-ret;
}
void pw()
{
  memcpy(t,p,sizeof t);
  for(int i=1;i<=n;i++)p[i]=t[t[i]];//n
}
void ch()
{
  memcpy(tt,d,sizeof tt);
  for(int i=1;i<=n;i++)d[i]=tt[p[i]];
}
int main()
{
  n=rd(); db x=0,pr=0;
  for(int i=1;i<=n;i++)scanf("%lf",&x),d[i]=x-pr,pr=x;
  m=rd(); k=rd();
  for(int i=1;i<=m;i++)a[i]=rd();
  for(int i=1;i<=n;i++)p[i]=i;
  for(int i=1;i<=m;i++)swap(p[a[i]],p[a[i]+1]);
  for(;k;k>>=1ll,pw())
    {
      if(k&1)ch();
    }
  db pos=0;
  for(int i=1;i<=n;i++)
    pos+=d[i],printf("%.1f\n",pos);
  return 0;
}

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 200000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
if k >= n:
    for i in range(n):
        ans += cmb(n-1, i, mod) * cmb(n, i, mod)
        ans %= mod


else:
    for i in range(k+1):
        ans += cmb(n-1, i, mod) * cmb(n, i, mod)
        ans %= mod

print(ans)


Measured memory_bytes: 81776
#include<stdio.h>
int main(){
  int i,j,K,n,t,count=0;
  scanf("%d",&K);
  int N[K];
  for(i=0;i<K;i++)
    scanf("%d",&N[i]);
    for(i=0;i<K-1;i++){
  for(j=K-1;i<j;j--){
      if(N[j]<N[j-1]){
	int t=N[j];
	N[j]=N[j-1];
	N[j-1]=t;
	count++;
      }
    }
  }
  for(n=0;n<K;n++){
    if(n == K-1)
      printf("%d",N[n]);
    else printf("%d ",N[n]);
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> l_w(n+1,0);
    vector<int> r_e(n+1,0);
// 12
//  W E W E W E E E W  W W  E
// 0 1 2 3 4 5 6 7 8 9 10 11 12
    for(int i=0; i<=n-1; i++){
        l_w[i+1]=l_w[i];
        if(s[i]=='W') l_w[i+1]++;
    }
    for(int i=n; 1<=i; i--){
        r_e[i-1]=r_e[i];
        if(s[i-1]=='E') r_e[i-1]++;
    }

    int mi= 1e9;
    REP(i,n)
        mi = min(mi, l_w[i]+r_e[i+1]);

    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a;
  ll ans=1;
 
  cout<<a*a*a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#define PI 3.141592
using namespace std;

int main(){
    int a, b;
    double x=0, y=0, dig=0;
    while(scanf("%d,%d",&a, &b)){
        if(a==0&&b==0) break;
        x += a*sin(dig*PI/180.0);
        y += a*cos(dig*PI/180.0);
        dig += b;
    }
    cout << (int)x << endl << (int)y << endl;
    return 0;
}

Measured memory_bytes: 1212
def main():
    A, B = map(int, input().split())
    ans = 0
    for i in range(A, B+1):
        tmp = str(i)
        if tmp[0] == tmp[4] and tmp[1] == tmp[3]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


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

using ll = long long;

auto small_cmp = [](const pair<ll, ll>& a, const pair<ll, ll>& b){
    return min(a.first, a.second) < min(b.first, b.second); };
auto big_cmp = [](const pair<ll, ll>& a, const pair<ll, ll>& b){
    return max(a.first, a.second) < max(b.first, b.second); };
pair<ll, ll> normalize(const pair<ll, ll>& p){
    return minmax(p.first, p.second); }

ll solve_with_fixed_small_y_large_x(const ll small_y, const ll large_x, ll an_x, ll an_y, vector<pair<ll, ll>> v){
    for(auto x : v){
        if(x.first < x.second) swap(x.first, x.second);
        an_x = min<ll>(an_x, x.first);
        an_y = max<ll>(an_y, x.second); }
    //cout <<  (large_x - an_x) * (an_y - small_y) << endl;
    return (large_x - an_x) * (an_y - small_y); }

ll solve_with_fixed_small_y_large_y(const ll small_y, const ll large_y, ll st, ll dr, vector<pair<ll, ll>> v){
    //cout << small_y << ' ' << large_y << ' ' << st << ' ' << dr << endl;
    transform(begin(v), end(v), begin(v), &normalize);
    map<ll, vector<ll>> evenimente;
    evenimente[st+1].push_back((ll)1e9 + 1000);
    evenimente[st].push_back(-1);
    evenimente[0].push_back(dr);
    for(const auto x : v){
        evenimente[0].push_back(x.first);
        evenimente[x.first].push_back(-1);
        evenimente[x.first + 1].push_back(x.second);
        evenimente[x.second].push_back(-1);
        evenimente[x.second + 1].push_back((ll)1e9 + 1000); }
    ll cur_dr = dr, rez = (ll)1e9 * (ll)1e9;
    for(auto& x : evenimente){
        for(const auto y : x.second) cur_dr = max(cur_dr, y);
        if(cur_dr > 1e9) break;
        //cout << x.first << ' ' << cur_dr << endl;
        rez = min(rez, cur_dr - x.first); }

    //cout << '@' << rez * (large_y - small_y) << endl;
    return rez * (large_y - small_y); }


ll solve_with_fixed_small_y(const ll an_x, const ll small_y, vector<pair<ll, ll>> v){
    if(all_of(begin(v), end(v), [&](const pair<ll, ll>& p){
        return p.first <= an_x && p.second <= an_x; })){
        return solve_with_fixed_small_y_large_x(small_y, an_x, an_x, small_y, v); }
    auto big = *max_element(begin(v), end(v), big_cmp);
    v.erase(max_element(begin(v), end(v), big_cmp));
    big = normalize(big);

    ll rez = solve_with_fixed_small_y_large_x(small_y, big.second, an_x, big.first, v);

    rez = min<ll>(rez, solve_with_fixed_small_y_large_y(small_y, big.second,
        min<ll>(big.first, an_x), max<ll>(big.first, an_x), v));
    return rez; }
 
int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v(n);
    for(auto& x : v) cin >> x.first >> x.second;
    if(n == 1){
        cout << 0 << endl;
        return 0; }

    auto small = *min_element(begin(v), end(v), small_cmp);
    v.erase(min_element(begin(v), end(v), small_cmp));
    small = normalize(small);

    cout << solve_with_fixed_small_y(small.second, small.first, v) << endl;
    return 0; }


Measured memory_bytes: 99144
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  char op;
  int i=0;
  string cu;
  int an[20001];
  int bn[20001];
  while(true)
  {
    cin>>a>>op>>b;
    an[i]=a;
    bn[i]=b;
    cu[i]=op;
    if(op=='?'){break;}
    i++;
  }
  for(int k=0;k<i;k++)
  {
    if(cu[k]=='+')
    {
      cout<<an[k]+bn[k]<<endl;
    }
    if(cu[k]=='-')
    {
      cout<<an[k]-bn[k]<<endl;
    }
    if(cu[k]=='*')
    {
      cout<<an[k]*bn[k]<<endl;
    }
    if(cu[k]=='/')
    {
      cout<<an[k]/bn[k]<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3132