akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
long long a[100005],n,A,B;
inline int read()
{
    int x=0,t=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return x*t;
}

bool judge(long long x){
    long long temp=x*B;
    long long sub=A-B;//题目条件A一定大于B 
    long long sum=0;
    for(int i=n;i>=1;i--){
        if(a[i]>temp){
            if((a[i]-temp)%sub)
                sum+=(a[i]-temp)/sub+1;
            else
                sum+=(a[i]-temp)/sub;
        }
    }
    if(sum<=x)
        return true;
    return false;
}
int main(){
	long long r,l;
	n=read();
	A=read();
	B=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		r+=a[i]/B+1;//粗略求出最大的时候的次数 
	}
	sort(a+1,a+n+1);
	l=1;
	while(l<r){
		long long mid=(l+r)>>1;
		if(judge(mid)){
			r=mid;
		}else l=mid+1;
	}
	printf("%lld",l);
	
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> p(N), v(N);
  iota(v.begin(), v.end(), 1);
  for (int i = 0; i < N; i++) cin >> p[i];
  bool isok = p == v;
  for (int i = 0; i < N; i++)
    for (int j = i + 1; j < N; j++) {
      swap(p[i], p[j]);
      isok |= p == v;
      swap(p[i], p[j]);
    }
  cout << (isok ? "YES" : "NO") << '\n';
  return 0;
}


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

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

    if (x == 0){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
s = str(input())

l = len(s)
count=0
best=0
i=0
while i<l:
    while s[i]== "A" or s[i]== "G" or s[i]== "T" or s[i]== "C":
        count+=1
        i+=1
        if i==l:
            break
    if count>best:
        best = count
    count=0
    i+=1
if count > best:
    best=count
print(best)

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
typedef long long ll;
int main() {
	int n,i;
	ll L[90];
	scanf("%d",&n);
	L[0] = 2;
	L[1] = 1;
	for(i = 2;i <= n; i++)
	{
		L[i] = L[i -1] + L[i - 2];
	}
	printf("%lld",L[n]);
return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (H, W, M) = readLine()!!.split(' ').map { it.toInt() }
    val arrH = IntArray(H+1)
    val arrW = IntArray(W+1)
    val arr = mutableSetOf<Pair<Int, Int>>()

    arrH[0] = 0
    arrW[0] = 0

    repeat(M) {
        val (h, w) = readLine()!!.split(' ').map { it.toInt() }

        arrH[h]++
        arrW[w]++
        arr.add(h to w)
    }

    val hmax = arrH.max()!!
    val wmax = arrW.max()!!

    val ans = hmax + wmax

    val lstH = arrH.withIndex().filter { it.value == hmax }.map { it.index}
    val lstW = arrW.withIndex().filter { it.value == wmax }.map { it.index}

    lstH.forEach { i ->
        lstW.forEach { j ->
            if (i to j !in arr) {
                println(ans)
                return
            }
        }
    }
    println(ans - 1)
}


Measured memory_bytes: 116476
import java.util.Scanner;

public class Main {

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

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

		long A = sc.nextInt();
		long B = sc.nextInt();

		sc.close();
		System.out.println(lcm(A,B));
	}


}


Measured memory_bytes: 21972
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main() {
  ll n,k;
  cin >> n >> k;
  if(k % 2 == 0){
    ll hf = k / 2;
    ll a = n / k, b = (n + hf) / k;
    cout << a*a*a + b*b*b << endl;
  }else{
    ll a = n / k;
    cout << a*a*a << endl;
  }
}

Measured memory_bytes: 256
import math
a, b, c = map(float, input().split())
print(a * b * math.sin(c / 180 * math.pi) / 2)
print(math.sqrt(a ** 2 + b ** 2 - 2 * math.cos(c / 180 * math.pi) * a * b) + a + b)
print(a * b * math.sin(c / 180 * math.pi) / a)



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

using namespace std;

#define ll long long

ll x[200005];

int main()
{
	int n,k;
	
	scanf("%d%d",&n,&k);
	
	for (int i=0;i<n;i++) scanf("%lld",&x[i]);
	
	ll ans=60000000000;
	
	for (int i=0;i<n-k+1;i++)
	{
	
		ll T=0;
	
		if (x[i]*x[i+k-1]>=0) T=max(abs(x[i+k-1]),abs(x[i]) );
	
		else T=max(-x[i],min(2*-x[i]+x[i+k-1],-x[i]+2*x[i+k-1]));
	
		if (T<ans) ans=T;
	
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const ll INF = 1e9+10;

template< typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid, Monoid) >;
  
  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  //SegmentTree(n,f,M1):サイズnの初期化，fは2つの苦汗の要素をマージする二項演算，M1はモノイドの単位元
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
    sz = 1;
    while(sz < n) sz<<=1;
    seg.assign(2*sz,M1);
  }

  //set(k,x):k番目の要素にxを代入
  void set(int k, const Monoid &x){
    seg[k+sz] = x;

  }
  
  //build():segTreeの構築
  void build(){
    for(int k = sz-1; k>0; --k){
      seg[k] = f(seg[2*k+0], seg[2*k+1]);
    }
  }

  //update(k,x):k番目の要素をxに変更
  void update(int k, const Monoid &x){
    k += sz;
    seg[k] = x;
    while(k>>=1) seg[k] = f(seg[2*k+0],seg[2*k+1]);
  }

  //区間[a,b)のMonoidを計算
  Monoid query(int a, int b){
    Monoid L = M1, R = M1;
    for(a += sz, b+=sz; a < b; a>>=1, b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }

  //operator[k]:k番目の要素を返す
  Monoid operator[](const int &k) const{
    return seg[k+sz];
  }

};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<PLL> v(N);
  ll ans = 0;
  rep(i,N){
    cin >> v[i].first >> v[i].second;
    ++v[i].second;
    ans = max(ans,v[i].second-v[i].first);
    v[i].second = -v[i].second;
  }
  sort(all(v));
  rep(i,N) v[i].second = -v[i].second;
  SegmentTree< PLL > rangeseg(N, [](PLL a, PLL b){
      PLL p;
      p.first = max(a.first,b.first);
      p.second = max(p.first,min(a.second,b.second));
      return p; }, PLL(1,INF));

  rep(i,N) rangeseg.set(i, v[i]);
  rangeseg.build();
  PLL p,q;
  p = rangeseg.query(0,N);
  ans += p.second-p.first;
  repp(i,1,N){
    p = rangeseg.query(0,i);
    q = rangeseg.query(i,N);
    ans = max(ans, p.second - p.first + q.second - q.first);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  string str;
  cin>>str;
  set<string> SET;
  int K;
  cin>>K;
  for (int r = 1; r <= K; r++)
  {
    for (int i = 0; i < str.size() -r+1 ; i++)
    {
      string sstr = str.substr(i,r);
      // DEBUG(sstr);
      SET.insert(sstr);
    }
    
  }
  auto itr = SET.begin();
  for (int i = 0; i < K-1; i++)
  {
    itr++;
    // DEBUG(*itr);
  }
  
  cout<<*(itr)<<endl;
  


  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 1664
// import chie template :) {{{
import std;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  string s;
  cin.scan(s);

  writeln(canFind(s, '7') ? "Yes" : "No");
}


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

ll calc(ll x, ll y) {
    ll tmp;
    if (x == y) {
        tmp = 0;
    } else if (x < y) {
        tmp = y - x;
    } else {
        tmp = INT_MAX;
    }
    return tmp;
}

int main() {
    ll x, y;
    cin >> x >> y;

    ll output;
    ll a, b, c, d;

    a = calc(x, y);
    b = calc(-1 * x, y) + 1;
    c = calc(x, -1 * y) + 1;
    d = calc(-1 * x, -1 * y) + 2;

    output = min(min(a, b), min(c, d));

    cout << output << endl;

    return 0;
}


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

int main()
{
	long long int k,n,max=0;
	cin>>k>>n;
	
	vector<long long int >v(n);
	
	cin>>v[0];
	
	for(long long int i=1;i<n;i++)
	{
		cin>>v[i];
		if(max < (v[i]-v[i-1]))
		{
			max=v[i]-v[i-1];
		}
	}
	if(max< (k-v[n-1]+v[0]))
	{
		max=k-v[n-1]+v[0];
	}
	cout<<k-max;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=8e5+9,inf=1e8;
	int head[N],nex[N],to[N],fl[N],cnt=1;
	inline void add(int u,int v,int flow){
	//	cout<<u<<" "<<v<<" "<<flow<<endl;
		nex[++cnt]=head[u],head[u]=cnt,to[cnt]=v,fl[cnt]=flow;
		nex[++cnt]=head[v],head[v]=cnt,to[cnt]=u,fl[cnt]=0;
	}
	int S,T,dist[N],cur[N];
	queue<int> q;
	inline bool bfs(){
		while(!q.empty()) q.pop();
		for(int i=1;i<=T;i++) dist[i]=inf;
		q.push(S),dist[S]=0;

		while(!q.empty()){
			int u=q.front();q.pop();
			if(u==T) return 1;
			for(int i=head[u];i;i=nex[i])
				if(fl[i] && dist[to[i]]==inf){
					dist[to[i]]=dist[u]+1;
					q.push(to[i]);
				}
		}
		return 0;
	}
	inline int dfs(int u,int flow){
		if(u==T) return flow;
		int rest=flow,k;
		for(int &i=cur[u];rest && i;i=nex[i])
			if(fl[i] && dist[to[i]]==dist[u]+1){
				k=dfs(to[i],min(fl[i],flow));
				fl[i]-=k,fl[i^1]+=k,rest-=k;
			}
		return flow-rest;
	}

	int n,mat[N],vis[N];
	vector<int> pos[N],E[N],ans[N];
	inline bool fortry(){
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
			if(!mat[i+n-1]){q.push(i);break;}

		int tot=0;
		while(!q.empty()){
			int u=q.front();q.pop();tot++;
			for(int i=0;i<pos[u].size();i++) if(!vis[pos[u][i]]){
				int id=pos[u][i];
				vis[pos[u][i]]=1,ans[id].push_back(mat[id]-n+1),ans[id].push_back(u);
				q.push(mat[id]-n+1);
			}
		}
		if(tot!=n) return 0;
		return 1;
	}
	int main(){
		n=read<int>();
		S=n-1+n+1,T=S+1;
		for(int t=1;t<n;t++){
			int k=read<int>();
			for(int i=1;i<=k;i++){
				int u=read<int>();
				E[t].push_back(u),pos[u].push_back(t);
				add(t,u+n-1,1);
			}
			add(S,t,1);
		}
		for(int i=1;i<=n;i++) add(i+n-1,T,1);
		int mxfl=0;
		while(bfs()){
			for(int i=1;i<=T;i++) cur[i]=head[i];
			int d;
			do{d=dfs(S,inf),mxfl+=d;}while(d);
		}
		if(mxfl!=n-1) puts("-1"),exit(0);
		for(int u=1;u<n;u++)
			for(int i=head[u];i;i=nex[i])
				if(!fl[i]){mat[u]=to[i],mat[to[i]]=u;break;}
		if(!fortry()) puts("-1"),exit(0);
		for(int i=1;i<n;i++)
			printf("%d %d\n",ans[i][1],ans[i][0]);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 83280
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*
2d pointer array
int **dp;
in main function
int row,col;
dp=new int*[n];
rep(i,n)dp[i]=new int[m]
*/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  int arr[n+1];
  repre(i,1,n)cin>>arr[i];
  unordered_map<int,int>mp;
  repre(i,1,n)
  {
    mp[arr[i]]=i;
  }
  repre(i,1,n)cout<<mp[i]<<" ";

  return 0;
}

int modInv(int a, int m){
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y){
if (a == 0){
    *x = 0, *y = 1;
    return b;
}
int x1, y1;
int gcd = gcdExtended(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}

int mpower(int x, int y, int p){
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
}
return res;
}

int power(int x, int y){
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
    y = y>>1;
    x = x*x;
}
return res;
}

bool isPrime(int n){
if (n <= 1)  return false;
if (n <= 3)  return true;
if (n%2 == 0 || n%3 == 0) return false;
int p=sqrt(n);
for(int i=5;i<=p;i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
        return false;
return true;
}


Measured memory_bytes: 5668
<?php
$i = explode(' ',trim(fgets(STDIN)));

$N = intval($i[0]);
$A = intval($i[1]);
$B = intval($i[2]);
$res = 0;

for($i = 1;$i < $N + 1;$i++){
    $sum = 0;
    for($j = 0;$j < strlen(strval($i));$j++){
        $sum += intval(strval($i)[$j]);
    }
    if($sum >= $A && $sum <= $B) $res += $i;
}

print $res;
?>


Measured memory_bytes: 3576
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1000000000 + 7;
static const ll INF = 1LL << 50;
using namespace std;


//繰り返し二乗法
template <typename T>
T doubling(T a, T p) {
	if (p == 0)return 1;//出口
	if (p % 2 == 0) {//pを半分にしていく
		T half = doubling(a, p / 2);
		return half%mod * half % mod;
	}
	else {//pが奇数ならpを偶数にする
		return a * doubling(a, p - 1)%mod;
	}
}

//combination その2
template<typename T>
T combination(T n, T r) {
	if (r > n - r)return combination<T>(n, n - r);
	T mul = 1;
	T div = 1;
	for (int64_t i = 0; i < r; i++) {
		mul *= (n - i);
		div *= (i + 1);
		mul %= mod;
		div %= mod;
	}
	//逆元
	T ans = mul * doubling(div, mod - 2) % mod;//a^(-1)=a~(p-2) (mod p)
	return ans;
}

//素因数分解
template<typename T>
map<T, T>prime_fact(T n) {
	map<T, T>mp;
	for (unsigned long long i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			mp[i]++;
		}
	}
	if (n != 1) {//sqrt(n)を超えた素数を処理(あっても1つ)
		mp[n]++;
	}
	return mp;
}


int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 1;
	for (auto x : prime_fact<ll>(m)) {
		ans *= combination<ll>(x.second + n - 1, x.second);
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,i,z,x=0;
  scanf("%d%d%d",&a,&b,&c);
  for(i=a;i<=b;i++){
    z=c%i;
    if(z==0)x++;
  }
  printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 596
import math

x1,y1,x2,y2 = raw_input().split()

tei  = float(x2) - float(x1)
taka = float(y2) - float(y1)

if tei == taka:
    st = math.sqrt(2)
    answ = st * tei
    print answ
if tei != taka:
    answ = (tei*tei) + (taka*taka)
    print math.sqrt(answ)

Measured memory_bytes: 6476
#include <stdio.h>

int main(void)
{
	long S;
	int h, m, s;

	scanf("%d", &S);

	h = S / 3600;
	m = (S / 60) %  60;
	s = S % 60;

	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (auto&& e : v) cin >> e;
  for (auto&& e : c) cin >> e;
  uint m = 1U << n;
  int ans(0);
  for (uint i = 0; i < m; i++) {
    int X(0), Y(0);
    for (uint j = 0; j < n; j++) {
      if ((i & (1U << j)) != 0) {
        X += v[j];
        Y += c[j];
      }
    }
    ans = max(ans, X - Y);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <climits>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> as(n);
    for(int i=0; i<n; ++i){
        cin >> as[i];
    }
    if(n%2){
        cout << 0 << endl;
        return 0;
    }
    sort(as.begin(), as.end());
    if(as[n/2-1]==as[n/2]){
        cout << 0 << endl;
        return 0;
    }
    cout << as[n/2]-as[n/2-1] << endl;
    return 0;
}


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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int N=read();
	int a[N];
	bool flag[8]={false};
	int fr=0;
	REP(i,N){
		a[i]=read();
		if(1<=a[i]&&a[i]<=399) flag[0]=true;
		else if(400<=a[i]&&a[i]<=799) flag[1]=true;
		else if(800<=a[i]&&a[i]<=1199) flag[2]=true;
		else if(1200<=a[i]&&a[i]<=1599) flag[3]=true;
		else if(1600<=a[i]&&a[i]<=1999) flag[4]=true;
		else if(2000<=a[i]&&a[i]<=2399) flag[5]=true;
		else if(2400<=a[i]&&a[i]<=2799) flag[6]=true;
		else if(2800<=a[i]&&a[i]<=3199) flag[7]=true;
		else fr++;
	}
	int cnt=0;
	REP(i,8){
		if(flag[i]==true) cnt++;
	}
	
	int min=cnt;
	if(cnt==0&&fr>=1) min = 1;
	int max=cnt+fr;
	cout << min << ' ' << max;
	
}

Measured memory_bytes: 256
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    A = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    A.sort()
    ans = 0
    p = 0
    if n == 2:
        print(A.pop(-1))
        exit()

    ans += A.pop(-1)
    p = 2

    for i in range(n-1):
        maxnum = A.pop(-1)
        p += 2
        if p > n:
            p -= 2
            break
        else:
            ans += maxnum * 2
    if p == n:
        print(ans)
    else:
        ans += maxnum * (n-p)
        print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 31780
n,q=map(int,input().split())
s=list(map(str,input()))
arr=[list(map(int,input().split())) for j in range(q)]

result=[0]
cnt=0
for i in range(1,len(s)):
	if s[i-1]+s[i]=="AC":
		cnt+=1
		result.append(cnt)
	elif s[i-1]+s[i]!="AC":
		result.append(cnt)
        

for a,b in arr:
	print(result[b-1]-result[a-1])

Measured memory_bytes: 30452
#include <iostream>
#include <string.h>

using namespace std;

int main(){
	int N, K;
	char S[50];
	
	
	cin>>N>>K;
	cin>>S;
	
	for(int i=0;i<N;i++ ){
		if(i==K-1){
			if(S[i]=='A') S[i] ='a'; 
			if(S[i]=='B') S[i] ='b';
			if(S[i]=='C') S[i] ='c';
		}
	}
	
	cout<<S;
	
	return 0;
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , a[N];

bool solve() {
  int even = 0;
  rep(i,0,n) even += ~a[i] & 1;
  if(even % 2 == 1) return 1;
  else if(even + 1 != n || *min_element(a,a+n) == 1) return 0;
  else {
    rep(i,0,n) if(a[i] & 1) --a[i];
    int g=a[0];
    rep(i,1,n) g=__gcd(g,a[i]);
    rep(i,0,n) a[i]/=g;
    return 1^solve();
  }
}

int main(){
  cin >> n;
  rep(i,0,n) cin >> a[i];
  cout << (solve() ? "First" : "Second") << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

//const int MAX_N = 301;

char A[301][301];
int N;

bool IsGood(int deltax)
{
    for(int y =0; y < N; ++y)
    {
        const int dy = (y - deltax + N) % N;
        for(int x = 0; x < N; ++x)
        {
            const int dx = (x + deltax) % N;
            if(A[x][y] != A[dy][dx]) return false;
        }
    }
    return true;
}
int main(int, char *[])
{
    cin >> N;
    for(int y = 0; y < N; ++y)
        for(int x = 0; x < N; ++x)
            cin >> A[y][x];

    int num_pat = 0;
    for(int dx = 0; dx < N; ++dx)
        if(IsGood(dx)) ++num_pat;

    cout << num_pat*N << endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
q = int(input())
for _ in range(q):
    b, e, t = map(int,input().split())
    # tmp = a[:]
    for k in range(e-b):
        # a[b+k] = tmp[t+k]
        # a[t+k] = tmp[b+k]
        a[b+k], a[t+k] = a[t+k], a[b+k]

print(*a)


Measured memory_bytes: 5832
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
import std.range;
import std.functional;
import std.traits;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto n = readNum!int;
  auto str = new string[](n);
  foreach(ref s; str){
    s = sort(readStr.representation.dup).to!string;
  }

  ulong ret;
  sort(str);

  auto g = str.Lgroup;
  foreach(ref e; g){
    ret += e[1] > 1 ? e[1] * (e[1] - 1) / 2 : 0;
  }

  writeln(ret);
}

LGroup!(pred, Range) Lgroup(alias pred = "a == b", Range)(Range r)
{
    return typeof(return)(r);
}

/// ditto
struct LGroup(alias pred, R)
if (isInputRange!R)
{
    import std.typecons : Rebindable, tuple, Tuple;

    private alias comp = binaryFun!pred;

    private alias E = ElementType!R;
    static if ((is(E == class) || is(E == interface)) &&
               (is(E == const) || is(E == immutable)))
    {
        private alias MutableE = Rebindable!E;
    }
    else static if (is(E : Unqual!E))
    {
        private alias MutableE = Unqual!E;
    }
    else
    {
        private alias MutableE = E;
    }

    private R _input;
    private Tuple!(MutableE, ulong) _current;

    ///
    this(R input)
    {
        _input = input;
        if (!_input.empty) popFront();
    }

    private this(R input, Tuple!(MutableE, ulong) current)
    {
        _input = input;
        _current = current;
    }

    ///
    void popFront()
    {
        if (_input.empty)
        {
            _current[1] = 0;
        }
        else
        {
            _current = tuple(_input.front, 1u);
            _input.popFront();
            while (!_input.empty && comp(_current[0], _input.front))
            {
                ++_current[1];
                _input.popFront();
            }
        }
    }

    static if (isInfinite!R)
    {
        ///
        enum bool empty = false;  // Propagate infiniteness.
    }
    else
    {
        ///
        @property bool empty()
        {
            return _current[1] == 0;
        }
    }

    /// Returns: the front of the range
    @property auto ref front()
    {
        assert(!empty, "Attempting to fetch the front of an empty Group.");
        return _current;
    }

    static if (isForwardRange!R)
    {
        ///
        @property typeof(this) save()
        {
            return LGroup(_input.save, _current);
        }
    }
}


Measured memory_bytes: 12284
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a[3];
	rep(i,3) cin >> a[i];
	sort(a, a+3);
	if((a[1]-a[0])%2==0) cout << (a[2]*2-a[0]-a[1])/2 << endl;
	else cout << (a[2]*2-a[0]-a[1])/2 + 2 << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n,m;
	cin>>n>>m;
	multiset<int> cnt;
	REP(i,1,n) {
		int val;
		cin>>val;
		cnt.insert(val);
	}
	while(m--) {
		int req = *--cnt.end();
		cnt.erase(--cnt.end());
		req>>=1;
		cnt.insert(req);
	}
	ll sum = 0;
	for(int i:cnt)sum+=i;
	cout<<sum;
}//1 0 2 3 1
//1 1 3 6 7

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 8368
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	text := s.Text()

	words := strings.Split(text, " ")

	var add int
	for _, v := range words {
		val, _ := strconv.Atoi(v)
		add += val
	}

	if add == 17 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


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

typedef long long int  ll;
#define int ll


/* Driver program to test above functions */
int32_t main()
{

    int n, k;
    cin>>n>>k;
    int arr[n];
    for(int i = 0; i<n; i++){
        cin>>arr[i];
    }
    sort(arr, arr + n);
    int count = 0;
    for(int i = 0; i<n-k; i++){
        count += arr[i];
    }
    cout<<count<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
void bfs(int);
int deque(void);
void enqueue(int);
int front(void);
int empty(void);

#define N 100
#define INF 10000000


int n;
int M[N][N];
int d[N];
int Q[N];
int head,tail;

int main(){
  int u;
  int k;
  int v;
  int i,j;

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

  bfs(0);
  return 0;
}



int deque(){
  int x=Q[head];
  head=(head+1)%N;
  return x;
}

void enqueue(int x){
  Q[tail]=x;
  tail=(tail+1)%N;
}


int front(){
  return Q[head];
}


int empty(){
  if(head==tail)return 1;
  else return 0;
}



void bfs(int s){
  int i,u,v;
  enqueue(s);
  for(i=0;i<n;i++){
    d[i]=INF;
  }
  d[s]=0;
    while(empty()!=1){
      u=front();
      deque();
      for(v=0;v<n;v++){
	if(M[u][v]==0)continue;
	if(d[v]!=INF)continue;
	d[v]=d[u]+1;
	enqueue(v);
      }
    }
    for(i=0;i<n;i++){
      printf("%d ",i+1);
      if(d[i]==INF)printf("-1\n");
      else printf("%d\n",d[i]);
    }
  }

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

int main()
{
	int  x , a ,b ;
	cin >> x >> a >> b; 
	if(abs(x-a)<abs(x-b))	cout<<"A"<<'\n';
	else cout<<"B"<<'\n';
	return 0;
 } 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const ll inf = 10e17;
const ll mod = inf;//1000000007;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);


ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans = mulmod(ans, n - i);

	 return mulmod(ans, inv[r]);
	// return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

bool binary_check(ll mid, ll key)
{
	return mid >= key;
}

ll binary_search()
{
//	ll ng = 0;
//	ll ok = x;
//
//	while (abs(ok - ng) > 1)
//	{
	//	ll mid = (ok+ng) / 2;
	//	if (binary_check(mid, k)) ok = mid;
	//	else ng = mid;
	//}

	return 0;
	//return ok;
}

ll solve(void)
{
	ll x;
	cin >> x;

	for (ll a = -1200; a <= 1200; a++) {
		for(ll b = -1200; b <= 1200; b++) {
			if (x == a * a*a*a*a - b * b*b*b*b) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}


	return 0;
}

int main(void)
{
	while (solve())
	{
	}
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <functional>
using namespace std;

int main(){
    int a;
    cin >> a;
    int ans = 1000-(a % 1000);
    if(ans!=1000){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __f{
    __f(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
};

int main(){

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


    for(int i = 1; i <= 50000; ++i){
        if(i*108/100 == n){
            ppp(i); return 0;
        }
    }
    ppp(":(");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    int b = 1;
    for (int i = 1; i < n; i++) {
        if (w[i - 1].back() != w[i].front()) b = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            if (w[i] == w[j]) b = 0;
        }
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
  char s[11];
  cin>>s;
  if(s[0]=='Y' and s[1]=='A' and s[2] =='K' and s[3] =='I')
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vector<int> L(N);
    for (int& x : L) cin >> x;
    sort(L.begin(), L.end());
    ll res = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        int lim = L[i] + L[j];
        int k = distance(L.begin(), lower_bound(L.begin(), L.end(), lim));
        res += max(0, k - j - 1);
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		int ct = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');
		int[] v = new int [ct];
		int count = 0;
		for (var i = 0; i < ct; i++)
		{
			v[i] = int.Parse(input[i]);
		}
		var vl = v.ToList();
		vl.Sort();
		int ans = vl[ct/2]-vl[ct/2-1];
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 19424
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int a[505][505], ans[505*505][4];
int h, w, idx = 0;
int main(){
    scanf("%d%d", &h, &w);
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            scanf("%d", &a[i][j]);
        }
    }
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w - 1; ++j){
            if(a[i][j] % 2 == 1){
                ans[idx][0] = i;
                ans[idx][1] = j;
                ans[idx][2] = i;
                ans[idx][3] = j + 1;
                a[i][j+1] += 1;
                idx++;
            }
        }
    }
    for(int i = 1; i <= h - 1; ++i){
        if(a[i][w] % 2 == 1){
            ans[idx][0] = i;
            ans[idx][1] = w;
            ans[idx][2] = i + 1;
            ans[idx][3] = w;
            a[i+1][w] += 1;
            idx++;
        }
    }
    printf("%d\n", idx);
    for(int i = 0; i < idx; ++i){
        printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
    }
    return 0;
}


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

int main() {
	int N, K; cin >> N >> K;
	double ans = 0.00000000000;
	for( int i = 1; i <= N; i++ ){
		int j = 0;
		double coin = 1.00000000000;
		for( ; i*pow(2,j) < K;j++ )coin = coin/2; 
		ans += ((double)1.00000000000/N) * coin;
	}
	
	
	cout << std::fixed;
	cout << std::setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	string S, T;
	cin >> S >> T;

	string B = T;

	int cnt = 0;
	while (true)
	{
		//judge
		int s = 0, b = 0;
		while (b < B.size())
		{
			if (s == S.size())
			{
				cout << cnt << endl;
				return;
			}
			if (S[s] == B[b])
			{
				b++;
			}
			s++;
		}
		cnt++;

		//next
		string tmp = B;
		for (int i = 0; i < T.size(); i++)
		{
			tmp += B[i] + B;
			if (tmp.size() > S.size())
			{
				cout << cnt << endl;
				return;
			}
		}
		B = tmp;
	}
}

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


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string a, b, c;
    int la, lb, lc;
    cin >> a >> b >> c;
    la = a.size(); lb = b.size(); lc = c.size();

    static bool buf_ab[8001], buf_bc[8001], buf_ac[8001];
    for(int i=0;i<=8000;++i) buf_ab[i] = buf_bc[i] = buf_ac[i] = true;
    bool *ab = buf_ab + 4000, *bc = buf_bc + 4000, *ac = buf_ac + 4000;

    for(int offset = -lb; offset <= la; ++offset){
        for(int i=0;i<lb;++i){
            if(0 <= offset + i && offset + i < la){
                if(a[offset+i] != '?' && b[i] != '?' && a[offset+i] != b[i]) ab[offset] = false;
            }
        }
    }
    for(int offset = -lc; offset <= la; ++offset){
        for(int i=0;i<lc;++i){
            if(0 <= offset + i && offset + i < la){
                if(a[offset+i] != '?' && c[i] != '?' && a[offset+i] != c[i]) ac[offset] = false;
            }
        }
    }
    for(int offset = -lc; offset <= lb; ++offset){
        for(int i=0;i<lc;++i){
            if(0 <= offset + i && offset + i < lb){
                if(b[offset+i] != '?' && c[i] != '?' && b[offset+i] != c[i]) bc[offset] = false;
            }
        }
    }
    int ans = la + lb + lc;
    for(int ob = -lb-lc; ob <= la+lc; ++ob){
        for(int oc = -lb-lc; oc <= la+lb; ++oc){
            if(ab[ob] && ac[oc] && bc[oc-ob]){
                ans = min(ans, max({la, ob+lb, oc+lc}) - min({0, ob, oc}));
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            String s = in.next();
            int ones = 0;
            int zeros = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '0'){
                    zeros++;
                }else{
                    ones++;
                }
            }
            out.println(2 * Math.min(ones, zeros));
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


Measured memory_bytes: 24532
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;

int main(){
  ll N,K;
  cin >> N >> K;
  double ans=0;
  for(ll i=0;i<N;i++){
    int nn = i+1;
    double tmp = 1.0/N;
    while(nn<K){
      nn*=2;
      tmp/=2;
    }
    ans += tmp;
  }
  printf("%.12f\n",ans);
}


Measured memory_bytes: 3124
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N, L; std::cin >> N >> L;
  int first = L;
  int end = N + L - 1;
  LL sum = 0;
  if (first > 0) {
    for (int i = 2; i <= N; ++i) {
      sum += L + i - 1;
    }
  } else if (end < 0) {
    for (int i = 1; i < N; ++i) {
      sum += L + i - 1;
    }
  } else {
    for (int i = 1; i <= N; ++i) {
      sum += L + i - 1;
    }
  }
  std::cout << sum << std::endl;
}


Measured memory_bytes: 256