akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long X[200000];
long sum[200000];
long sum2[200000];
void Calc(){
	long L = rel();
	int N = rei();
	for(int i=0;i<N;i++){
		X[i] = rel();
	}
	for(int i=1;i<N;i++){
		sum[i] = X[i-1] + sum[i-1];
	}
	for(int i=1;i<N;i++){
		sum2[i] = L-X[N-i] + sum2[i-1];
	}
	if(N == 1){
		cout << max(X[0],L-X[0]) << endl; 
		return;
	}
	long ans = 0;
	{
		long c = 0;
		c = X[N-2] + max(X[N-1]-X[N-2],L-(X[N-1]-X[N-2]));
		ans = max(ans,c);
	}
	{
		long c = 0;
		c = L-X[1] + max(X[1]-X[0],L-(X[1]-X[0]));
		ans = max(ans,c);
	}
	for(int i=2;i<N-1;i++){
		int left = i;
		int right = N-i;
		long c;
		if(left < right){
			c = max(2*(sum[left] + sum2[right]-sum2[right-left-1]) - (L-X[N-right]),2*(sum[left] + sum2[right]-sum2[right-left]) - (X[left-1]));
			if(X[i]-X[i-1] > L-(X[i]-X[i-1])){
				c += X[i]-X[i-1] - (L-(X[i]-X[i-1]));
			}
		}
		else if(right < left){
			c = max(2*(sum[left]-sum[left-right-1] + sum2[right]) - X[left-1],2*(sum[left]-sum[left-right] + sum2[right]) - (L-X[N-right]));
			if(X[i]-X[i-1] > L-(X[i]-X[i-1])){
				c += X[i]-X[i-1] - (L-(X[i]-X[i-1]));
			}
		}
		else{
			c = 2*(sum[left] + sum2[right]) - min(X[left-1],L-X[N-right]);
			if(X[i]-X[i-1] > L-(X[i]-X[i-1])){
				c += X[i]-X[i-1] - (L-(X[i]-X[i-1]));
			}
		}
		ans = max(ans,c);
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
set<ll> divisor(ll n) {
  set<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.insert(i);
      if (i != n / i) res.insert(n / i);
    }
  }
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll k; cin>>k;
  vll a(k);
  rep(i,k) cin>>a[i];
  reverse(all(a));
  
  ll l=2, r=2; // ラウンドi直後の最小と最大を保持する
  rep(i,k){
    l=(l+a[i]-1)/a[i]; // [l,r]においてa_iの倍数である最小とは ceil(l/a_i)*a_i
    r=r/a[i]; // 最大は floor(r/a_i)*a_i
    // ceil(l/a_i) <= floor(r/a_i) の関係が成り立たない場合
    // つまり、[l,r]においてa_iの倍数が存在しない場合、そのラウンドから直後の状態は作れない
    if(l>r){
      cout<<-1<<endl;
      return 0;
    }
    l=l*a[i];
    r=r*a[i]+a[i]-1;
  }
  cout<<l<<" "<<r<<endl;
}

Measured memory_bytes: 1024
<?php
$X = trim(fgets(STDIN));
$m = floor(sqrt($X));
$mm = 0;
for($i=2;$i<$m;$i++) {
  $j = 1;
  while (!(pow($i, $j) <= $X && $X < pow($i, $j + 1))){
    $j++;
  }
  $mm=max(pow($i,$j),$mm);
  //printf("%d*%d %d\n",$i,$j,$mm);
}
printf("%d\n",max($m*$m,$mm));


Measured memory_bytes: 3828
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import Counter
n=int(input())
a=[int(i) for i in input().split()]
d=Counter(a) ;ans=0
for i in d:
    ans+=(d[i]*(d[i]-1))//2
for i in a:
    print(ans-(d[i]-1))


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

int main(){
    int n;
    int arr[200];
    cin >> n;
    for(int i = 0; i < 2*n; i++){
        cin >> arr[i];
    }
    sort(arr, arr+(2*n));
    int total = 0;
    for(int i = 0; i < 2*n; i+=2){
        total+=arr[i];
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n, answer = -1, sw = 0, divider = 1;
	int *s;
	scanf("%d", &n);
	s = (int *)malloc(sizeof(int)*n);
	for (int i = 0; i < n; i++) {
		scanf("%d", s + i);
	}
	do{
		answer++;
		divider = divider * 2;
		for (int i = 0; i < n; i++) {
			if (s[i] % divider != 0) {
				sw = 1;
				break;
			}
		}
	} while (sw == 0);
	printf("%d\n", answer);
	return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int smax=190;
const int nmax=1<<15;

int cnt[nmax+1];

int main(void){

	for(int a=smax;a>=0;--a){
		for(int b=a;b>=0;b--){
			if(a*a+b*b>nmax)
				continue;
			for(int c=b;c>=0;c--){
				if(a*a+b*b+c*c>nmax)
					continue;
				for(int d=c;d>=0;d--){
					if(a*a+b*b+c*c+d*d>nmax)
						continue;
					cnt[a*a+b*b+c*c+d*d]++;
				}
			}
		}
	}

	int n;
	while(cin >> n){
		if(n==0)
			break;
		cout << cnt[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	int i, j;
	int n, k;
	vector<int>list;
	vector<int>sa, sa2;

	cin >> n >> k;

	for (i = 0; i < n; i++) {
		int num;
		cin >> num;

		list.push_back(num);
	}

	sort(list.begin(), list.end(), greater<int>());


	for (i = 1; i < n; i++) {
		sa.push_back(list[i - 1] - list[i]);
	}

	for (i = 1; i < n; i++) {
		sa2.push_back(list[0] - list[i]);
	}

	sa2.insert(sa2.begin(), 0);

	//long long minn = 999999999;
	int minn = 999999999;

	for (i = 0; i < sa2.size() - (k - 1); i++) {
		minn = min(minn, abs(sa2[i] - sa2[i + (k - 1)]));


	}

	cout << minn << endl;






	getchar();
	getchar();
	return 0;
}

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

using namespace std;

#define mod 1000000007
#define sz(c)  (int) c.size()
#define all(c) c.begin(), c.end()
#define tr(container,it) for(__typeof(container.begin()) it = container.begin();it != container.end(); it++)
#define present(s,x) s.find(x) != s.end()
#define cpresent(c,x) find(all(c),x) != c.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a; i<b;i++)
#define ini(n) scanf("%d",&n)
#define opn printf("\n")

 
#define TRACE
 
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)    
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif 

typedef pair<int,int> pi;
typedef vector<pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi , greater<int> >minpq;
typedef priority_queue<pi,vp,greater<pi> > mpq;

vi a;
vi b;
int N;
void com(){
	int pro = 1;
	for(int i=1 ; pro<=N; i++){
		pro *= 6;
		a.pb(pro);
	}
	
	pro = 1;
	for(int i=1; pro<=N ; i++){
		pro *=9 ;
		b.pb(pro);
	}
}
int S[100002];

int dp(int n){
	if(n==0){
		return 0;
	}
	if(S[n] != -1){
		return S[n];
	}
	int ans1 = 1 + dp(n-1);
	int ans2 = 1e8;
	for(int i=0; i<sz(a) ;i++){
		if(n>=a[i])
			ans2 = min(ans2 , 1+dp(n-a[i]) );
	}
	int ans3 = 1e8;
	for(int i=0; i<sz(b) ;i++){
		if(n>=b[i])
			ans3 = min(ans3 , 1+dp(n-b[i]) );
	}
	return S[n] = min(min(ans1,ans2),ans3);
	
}
int main(){
	//ios_base::sync_with_stdio(false);cin.tie(NULL);

	cin>>N;
	fill(S,S+100002,-1);
	com();
	int n = N;
	int ans = dp(n);
	cout<<ans<<endl;
	
}

	

	



Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>

void solve()
{
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, p[100];
    cin >> n;
    FOR(i, 1, n + 1)
    {
        cin >> p[i];
    }
    int ans = 0;
    FOR(i, 2, n)
    {
        if (p[i] < p[i - 1] && p[i] > p[i + 1]) {
            ans++;
        } else if (p[i] > p[i - 1] && p[i] < p[i + 1]) {
            ans++;
        }
    }
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2,3,"Ofast","unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
    char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
    in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
    in int read()
    {
        int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
        x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
    }
    in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
    in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
    in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
    in void flush() {if(C>1<<22) ot();}
    template <typename T>
    in void write(T x,char t)
    {
        int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
        if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
    }
    in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
#define pb push_back
const int N=3e3+5;
int n,p,c[N][N],s[N][N],ans;
in void M(int &x) {x-=p;x+=x>>31&p;}
in int qpow(int a,int b,int p=::p) {int c=1;for(;b;b>>=1,a=1ll*a*a%p)if(b&1)c=1ll*a*c%p;return c;}
int main()
{
	n=read(),p=read();c[0][0]=s[0][0]=1;
	for(int i=1;i<=n+1;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++) M(s[i][j]=s[i-1][j-1]+1ll*j*s[i-1][j]%p),M(c[i][j]=c[i-1][j-1]+c[i-1][j]);
	}
	for(int i=0;i<=n;i++)
	{
		int _2=qpow(2,n-i),__2=qpow(2,n-i,p-1),t=(i&1)?p-1:1,res=0;
		t=1ll*t*c[n][i]%p*qpow(2,__2)%p;
		for(int j=0,j2=1;j<=i;j++) M(res+=1ll*s[i+1][j+1]*j2%p),j2=1ll*j2*_2%p;
		M(ans+=1ll*res*t%p);
	}
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233


Measured memory_bytes: 58724
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,w;
    cin>>n>>w;
    ll wt[n+1],val[n+1],val_sum=0;
    for(ll i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];
        val_sum+=val[i];
    }
    ll dp[val_sum+1][n+1],ans=0;
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<=val_sum;i++)
    {
        for(ll j=0;j<=n;j++)
        {
            if(i==0)
                dp[i][j]=0;
            else if(j==0)
                dp[i][j]=w+1;
            else if(i>=val[j])
                dp[i][j]=min(dp[i][j-1],wt[j]+ dp[i-val[j]][j-1]);
            else
                dp[i][j]=dp[i][j-1];
        }
        if(dp[i][n]<=w)
            ans=i;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>
#include <iostream>

int main(void){
	int i=1, x;
	int n;	
	scanf("%d", &n);
	for(i=1;i<=n;i++){
		x = i;
		if(i%3==0) printf(" %d",i);
		else{
			while(1){
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				x/=10;
				if(!x) break;
			}
		}
	}
	printf("\n");
	return 0;
}



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

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

using namespace std;

int n;
string s;
int cnt[30];
int cnt2[10];

int main() {
  cin >> n >> s;
  rep(i,n) ++cnt[s[i]-'a'];
  rep(i,26) {
    if( cnt[i] == 0 ) continue;
    ++cnt2[cnt[i]];
  }
  int answer = 0;
  rep(i,10) {
    if( cnt2[i] == 0 ) continue;
    if( i == 1 ) {
      if( cnt2[i] ) {
	answer += cnt2[i] * 2;
      }
      continue;
    }
    if( cnt2[i] == 1 ) {
      answer += 4;
    } else {
      answer += ( 4 + cnt2[i] * 2 - 1 );
      ++answer;
    }
  }
  if( answer - 1 >= 1 ) --answer;
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
        using namespace std;
         
        int main() {
          string s;
          cin >> s;//.at(0) >> s.at(1) >> s.at(2) >> s.at(3);
          //sort(s.begin(),s.end());
          int ans=0;
          for(int i=0; i<6; i++)
          if(s.at(i)=='1') ans++;
          cout << ans << endl;
          return 0;
        }

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

int gcd(int x,long int y)
{
    return y?gcd(y,x%y):x;
}

int main()
{
    int a[200000];
    int n;
    while(cin>>n)
    {
        int i;
        int t=0;
        int num=0;
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
        for(i=0;i<n;i++)
            if(a[i]==t+1)
                t++;
            else
                num++;
        if(t)
            printf("%d\n",num);
        else
            printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

string longestRepeatedSubstring(string str)
{
    int n = str.length();
    int LCSRe[n+1][n+1];


    memset(LCSRe, 0, sizeof(LCSRe));

    string res;
    int res_length  = 0;

    int i, index = 0;
    for (i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            if (str[i-1] == str[j-1] &&
                LCSRe[i-1][j-1] < (j - i))
            {
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1;


                if (LCSRe[i][j] > res_length)
                {
                    res_length = LCSRe[i][j];
                    index = max(i, index);
                }
            }
            else
                LCSRe[i][j] = 0;
        }
    }

    if (res_length > 0)
        for (i = index - res_length + 1; i <= index; i++)
            res.push_back(str[i-1]);

    return res;
}

ll binarySearch(vector<ll> v, ll n, ll k, ll start)
{
    ll p = start;
    for (ll a = n; a >= 1; a /= 2)
    {
        while (a + p < n && v[a+p] <= k)
        {
            p += a;
        }
    }
    if (k > v[p])
    {
        return p + 1;
    }
    else
    {
     return p;
    }
}

int main()
{
    double t, x;
    cin >> t >> x;
    cout << setprecision(10) << t / x;


    return 0;
}



Measured memory_bytes: 256
// PrimとおもったらKruskal
// Built?
// https://atcoder.jp/contests/abc065/tasks/arc076_b
#include<bits/stdc++.h>
using namespace std;

#define MAX_V 100005
#define MAX_N 100005
#define INF 10000000000
typedef long long ll;
typedef pair<ll,ll> V;
typedef pair<ll,int> P;
priority_queue<P,vector<P>,greater<P> > xque;
priority_queue<P,vector<P>,greater<P> > yque;


struct UFT{
	// Union-Find Tree
	int par[MAX_N];
	int depth[MAX_N];
	void init(){
		for(int i=0;i<MAX_N;i++){
			par[i]=i;
			depth[i]=0;
		}
		return;
	}
	UFT(){
		init();
	}

	int get_root(int i){
		if(par[i]==i){
			return i;
		}
		int rt = get_root(par[i]);
		par[i] = rt;
		return rt;
	}
	void merge(int i,int j){
		int x = get_root(i);
		int y = get_root(j);
		if(depth[x]>depth[y]){
			par[y] = x;
		}else{
			par[x] = y;
			if(depth[x]==depth[y]){
				depth[y]++;
			}
		}
		return;
	}
	bool same(int i,int j){
		return get_root(i) == get_root(j);
	}

};

struct EDGE{int from,to,cost;};



bool comp(EDGE a,EDGE b){
	return a.cost < b.cost;
}

int vn;
V vertex[MAX_V];
vector<EDGE> es;

ll cost(V a,V b){
	return min(abs(a.first-b.first),abs(a.second-b.second));
}



int main() {
	cin >> vn;
	ll total_cost=0;
	UFT uft;
	for(int i=0;i<vn;i++){
		ll a,b;
		cin >> a >> b;
		xque.push(P(a,i));
		yque.push(P(b,i));
		vertex[i] = V(a,b);
	}
	int pxi = xque.top().second;xque.pop();
	int pyi = yque.top().second;yque.pop();	
	for(int i=0;i<vn-1;i++){
		int xi = xque.top().second;xque.pop(); 
		ll c = cost(vertex[pxi],vertex[xi]);
		es.push_back((EDGE){pxi,xi,c});
		pxi = xi;
		int yi = yque.top().second;yque.pop(); 
		c = cost(vertex[pyi],vertex[yi]);
		es.push_back((EDGE){pyi,yi,c});
		pyi = yi;
	}
	sort(es.begin(),es.end(),comp);

	for(int i=0;i<es.size();i++){
		if(!uft.same(es[i].from,es[i].to)){
			total_cost += es[i].cost;
			uft.merge(es[i].from,es[i].to);
		}
	}


	// for(int i=0;i<es.size();i++){
	// 	cout << es[i].from << " " << es[i].to << " " << es[i].cost << " " << endl;
	// }

	cout << total_cost << endl;
    return 0;
}



Measured memory_bytes: 11748
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
d, x = map(int, input().split())

a = list(int(input()) for i in range(n))

ans = x
for i in range(n):
    ans += 1
    ans += (d-1)//a[i]
print(ans)

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

int main(){
  int k,n;
  cin >>k >>n;
  int a[n];
  int ans=100000000;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i>=1){ans=min(ans,k-(a[i]-a[i-1]));}
  }
  ans=min(ans,k-(k-a[n-1])-a[0]);
  cout << ans << endl;

}

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

int main(void){
    int n,x;
    cin>>n>>x;

    long long ans=0;
    int a[n];
    cin>>a[0];
    if(a[0]>x){
        ans += a[0]-x;
        a[0] = x;
    }
    for(int i=1;i<n;i++){
        cin>>a[i];
        if(a[i-1]+a[i] > x){
            int eat = a[i-1]+a[i] -x;
            a[i] -= eat;
            ans += eat;
        }
    }
    
    cout<<ans<<endl;
}

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

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] N = new int[2];
            N = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = N[0]; int y = N[1];
            int[] grpA = new int[7] { 1, 3, 5, 7, 8, 10, 12 };
            int[] grpB = new int[4] { 4, 6, 9, 11 };
            int[] grpC = new int[1] { 2 };
            if (grpA.Contains(x) && grpA.Contains(y) || grpB.Contains(x) && grpB.Contains(y) || grpC.Contains(x) && grpC.Contains(y))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

int isprime(int x) {
	if (x == 2) return 1;
	else if (x < 2 || x % 2 == 0) return 0;
	int i = 3;
	while (i <= sqrt(x)) {
		if (x%i == 0) return 0;
		i = i + 2;
	}
	return 1;
}
int main() {
	int a[10000], n, i, j = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (isprime(a[i]) == 1) j++;
	}
	printf("%d\n", j);
}


Measured memory_bytes: 2044
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b;
	cout<<(a+b)%24;
	return 0;
}


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

int main(){
  int X;
  int MAX = 1;
  cin >> X;
  fflush(stdout);
  int max_b = int(sqrt(double(X)) + 1.0E-10);
  for(int b=2; b<=max_b; ++b){
    int p = int(log(double(X)) / log(double(b)) + 1.0E-10);
    int m = 1;
    for(int i=0; i<=p; ++i){
      m *= b;
      if(m > X){
        m /= b;
        break;
      }
    }
    if(MAX < m){
      MAX = m;
    }
  }
  
  cout << MAX << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<lint>;
using vvi = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, q;
    cin >> n >> q;
    vvi g(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vi c(n, 0);
    vector<bool> fl(n, false);

    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;

        c[p] += x;
    }

    queue<int> que;
    que.push(0);
    fl[0] = true;

    while (!que.empty()) {
        int node = que.front();
        que.pop();

        fl[node] = true;

        for (auto&& s : g[node]) {
            if (fl[s]) continue;
            c[s] += c[node];
            fl[s] = true;
            que.push(s);
        }
    }

    rep(i, n) {
        cout << c[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 16372
import java.util.*;

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

        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if (u.equals(s)) {
            a = a - 1;
        } else {
            b--;
        }

        System.out.print(a);
        System.out.print(" ");
        System.out.print(b);
    }
}

Measured memory_bytes: 23764
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long A=sc.nextLong();
        long B=sc.nextLong();
        long C=sc.nextLong();
        
        if(C-A-B<0){
            System.out.println("No");
            return;
        }
        
        long LEFT=(A+B-C)*(A+B-C);
        long RIGHT=4*A*B;
        if(LEFT>RIGHT){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

using namespace std;
using ll = long long;

int const N = 100 * 1000 + 16;

int a[16];

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    x /= 400;
    x = min(x, 8);
    a[x]++;
  }

  int cnt = 8 - count(a, a+8, 0);

  cout << (cnt?:1) << " " << cnt + a[8] << endl;
}

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

using namespace std;

#define     forn(i,ii,n)         for(int i=ii; i<=n; ++i)
#define     ford(i,n,ii)         for(int i=n; i>=ii; --i)
#define     repit(i, c)         for( auto i = (c).begin(); i != (c).end();++i )
 
#define     pb                  push_back
#define     eb                  emplace_back
#define     sz(xx)              (int) xx.size()
#define     mk                  make_pair
#define     mem(x,v)            memset(x,v,sizeof x)
#define		clr(xx)				xx.clear()
#define		ff 					first
#define		ss 					second
#define		all(x)				x.begin(),x.end()
#define		nl 					cout << endl
#define     kase(x)             cout << "Case " << x <<": "
#define     fastt               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     dbg(args...)        do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;
 

template< typename T > void print(const T& v) {    cerr << v << ' ' ;}
template< typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}
 
/*typedef*/
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ull> vul;
typedef pair<int,int> pii;
typedef pair<int,ull> piul;
typedef pair<int,double> pid;
typedef vector<pii> vii;
typedef vector<pid> vid;
typedef vector<piul> viul;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef set<int> si;
typedef priority_queue <pii, vector<pii>, greater<pii> > pq;	///for djkstra
/*typedef ends*/

/*functions*/
template<typename T> T extGcd(T a, T b, T& x, T& y) { if(a==0) { x=0,y=1; return b; } T x1,y1,gcd = extGcd(b%a,a,&x1,&y1); x= y1-(b/a)*x1, y = x1; return gcd;}
template<typename T> T bigMod(T a, T p, T m) { if(p==1) return a; T x = bigMod(a,p/2,m)%m; x = (x*x)%m; return (p&1) ? (x*a)%m : x;}
template<typename T> T modMul(T a, T b, T m) { return ((a%m)*(b%m))%m; }
template<typename T> T modAdd(T a, T b, T m) { return ((a%m)+(b%m)+m)%m; }
template<typename T> T modSub(T a, T b, T m) { return (a-b+m)%m; }
template<typename T> T modInverse(T a , T m) { return bigMod(a,m-2,m); }  ///m must be prime


/*****************************************************************************/

const int maxn = 1e5+1;
const ll mod = 1e9+7;
ll fact[maxn+1];
void factorial(){
    fact[0]=1;
    forn(i,1,maxn) fact[i] = modMul(fact[i-1],(ll)i, mod);
}
ll ncr(int n, int r){
    if(r>n) return 0;
    return modMul(fact[n],modInverse(modMul(fact[r],fact[n-r],mod),mod),mod);
}


int main()
{
	
     //  freopen("in.txt", "r", stdin);
     //    freopen("out.txt", "w", stdout);

    fastt;
    factorial();

    int n, k;
    cin>>n>>k;
    ll a[n];
    forn(i,0,n-1) cin>>a[i];
    sort(a,a+n);
    ll ans  = 0;
    forn(i,0,n-1){
        ll cntmx = ncr(i,k-1);
        ll cntmn = ncr(n-i-1,k-1);
        ans = modAdd(ans,modMul(a[i],modSub(cntmx,cntmn, mod),mod),mod);
        //dbg(cntmx,cntmn, ans);
    }

    cout << ans  << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = 1LL << 61;
const ll MOD = 1000000007 /*988244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, m, n, t, r, k, w, l, ans, i, j;
string S, T;
vl A, B;
void solve() {
    n = S.length();
    rep(i, n) {
        vl A(26, 0), B(26, 0);
        rep(j, n) {
            a = 0;
            if(j <= i)
                A[S[j] - 'a']++;
            else
                B[S[j] - 'a']++;
        }

        rep(j, 26) {
            if(A[j] * B[j])
                a++;
        }
        ans = max(ans, a);
    }

    cout << ans << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> S;
    solve();
}

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

string s;

int main(){
    cin>>s;
    if (s=="SUN") cout<<7;
    if (s=="MON") cout<<6;
    if (s=="TUE") cout<<5;
    if (s=="WED") cout<<4;
    if (s=="THU") cout<<3;
    if (s=="FRI") cout<<2;
    if (s=="SAT") cout<<1;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int x;
  int q;
  for(ii=0;ii<5;ii++){
    cin >> x;

    if(x == 0){
      q = ii+1;
    }
    
  }

  cout << q << endl;
  
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

long long a[N], b[N];

void solve() {
  int n; scanf("%d", &n);
  long long capacity = 1;
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    scanf("%lld", a+i);
    if (a[i] > capacity) {
      printf("-1");
      return;
    }
    b[i] = capacity;
    if (capacity > 1e15) continue;
    capacity = (capacity-a[i])*2;
  }
  for (int i = n; i >= 0; --i) {
    a[i] += a[i+1];
    ans += min(b[i], a[i]);
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    sort(d.begin(),d.end());
    int ans=d[N/2]-d[N/2-1];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>

using namespace std;

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

	int d = a / b;
	int r = a % b;
	double f = a / static_cast<double>(b);

	cout << d << " " << r << " " << fixed << setprecision(8) << f << "\n";
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    string s; cin >> s;
    int n = sz(s);
    int ans = 1;
    rep(i,n) {
        if (i%2 && s[i] == 'R') ans = 0;
        if (i%2 == 0 && s[i] == 'L') ans = 0;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define FOR(i,m,n) for(int i=(m); i<(n); ++i)
typedef vector<int> vi;
typedef pair<int,int> P;
typedef vector<P> vp;
#define fi first
#define se second
inline int in() { int x; cin >> x; return x; }
const int INF = 1001001001;
#define chmin(x,y) x = min(x,y)

void solve() {
  int h = in(), n = in();
  vi v(h, INF); v[0] = 0;
  vp p(n); FOR(i,0,n) p[i] = {in(),in()};
  int ans = INF;
  FOR(i,0,h) {
    FOR(j,0,n) {
      int idx = i + p[j].fi;
      chmin((idx>=h ? ans : v[idx]), v[i]+p[j].se);
    }
  }
  cout << ans << endl;
}

#undef int
int main() {
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> v(h+2);
    for(int i = 1; i <= h; i++)
        cin >> v[i];

    for(int i = 0; i < h+2; i++){
        if(i == 0 || i == h+1){
            for(int j = 0; j < w+2; j++){
                cout << '#';
                if(j == w+1)
                    cout << endl;
            }
        }else{
            cout << '#' << v[i] << '#' << endl;
        }
    }
}


Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(s:#));
    s.chars()
        .map(|x| if x == '+' { 1 } else { -1 })
        .sum::<i64>()
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "+-++" => "2",
    test2: "-+--" => "-2",
    test3: "----" => "-4",
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char str[45];
ll dp[45][45];
string a,b;
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",str+1);
	reverse(str+n+1,str+n+n+1);
	int limt=1<<n;
	ll ans=0;
	for(int s=0;s<limt;s++){
		a=b="";
		memset(dp,0,sizeof dp);
		for(int i=0;i<n;i++){
			if((1<<i)&s) a+=str[i+1];
			else b+=str[i+1];
		}
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=0;j<=(int)a.size();j++){
				if(j+1<=(int)a.size() && str[n+i]==a[j])
					dp[i][j+1]+=dp[i-1][j];
				if(i-j<=(int)b.size() && str[n+i]==b[i-j-1])
					dp[i][j]+=dp[i-1][j];
			}
		}
		ans+=dp[n][a.size()];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 1002
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int solve(){
	
}

int main(){
	int a[3], b[2];
	scanf("%d%d%d%d%d",&a[0],&a[1],&a[2],&b[0],&b[1]);
	sort(a, a+3);sort(b, b+2);
	printf("%d\n", a[0]+b[0]-50);
	return 0;
}

Measured memory_bytes: 3264
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	long long int ans = MOD * MOD;
	for (long long int i = 1; i*i <= N; i++) {
		if (N%i)continue;
		ans = min(ans, i + N / i);
	}
	cout << ans - 2 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

bool used[10];
bool tabu[10];
int keisu[10];
int cnt, ans;

void dfs(int k, int sum){
    if (k == cnt) {
        if (!sum) {
            ans++;
        }
        return;
    }
    
    for (int i = 0; i < 10; i++) {
        if (used[i] || (i == 0 && tabu[k])) {
            continue;
        }
        used[i] = true;
        dfs(k+1, sum+i*keisu[k]);
        used[i] = false;
    }
    return;
}

int main(){
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<string> str(n);
        map<char, int> id;
        cnt = 0;
        ans = 0;
        
        for (int i = 0; i < 10; i++) {
            used[i] = false;
            tabu[i] = false;
            keisu[i] = 0;
        }

        for(int i = 0; i < n; i++){
            cin >> str[i];
            string s = str[i];
            for (int j = 0; j < s.size(); j++) {
                if (id.find(s[j]) == id.end()) {
                    id[s[j]] = cnt++;
                }
                if (j == 0 && s.size() > 1) { // 0にならない記号か
                    tabu[id[s[j]]] = true;
                }
                if (i != n - 1) {
                    keisu[id[s[j]]] += (int)pow(10, s.size() - j - 1);
                }else{
                    keisu[id[s[j]]] -= (int)pow(10, s.size() - j - 1);
                }
            }
        }
        dfs(0, 0);
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1256
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		long K = io.nextLong();
		PriorityQueue<Point> array = new PriorityQueue<Point>();
		for(int i=0;i<N;i++){
			Point n = new Point(io.nextInt(),io.nextInt());
			array.offer(n);
		}
		
		int ans=0;
		long sum=0;
		while(sum<K){
			Point now = array.poll();
			ans = now.a;
			sum += now.b;
//			System.out.println(ans+" "+sum+" "+array.size());
		}
		
		System.out.println(ans);
	}
}

class Point implements Comparable<Point>{
	int a,b;
	public Point(int a,int b){
		this.a = a;
		this.b = b;
	}
	@Override
	public int compareTo(Point o) {
		return Integer.compare(a,o.a);
		
	}
}

Measured memory_bytes: 87716
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt += x & 1;
  }
  puts(cnt & 1 ? "NO" : "YES");
  return 0;	
}

Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {
    static void swap(int[] data, int i, int j) {
        int tmp = data[i];
        data[i] = data[j];
        data[j] = tmp;
    }

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

        int w = scanner.nextInt(), n = scanner.nextInt();
        int[] data = new int[w];

        for (int i = 0; i < w; ++i) {
            data[i] = i + 1;
        }

        scanner.useDelimiter("[,\n]");
        for (int i = 0; i < n; ++i) {
            int a = scanner.nextInt(), b = scanner.nextInt();
            swap(data, a - 1, b - 1);
        }
        for (int i = 0; i < w; ++i) {
            System.out.println(data[i]);
        }
    }
}


Measured memory_bytes: 26176
using System;
using System.Collections.Generic;

class Program{

    const int INT_MAX = 2147483647;
    static void Main(string[] args)
    {
        // ufは連結は出来るけど後戻りが出来ない<incremental?というのか>
        int[] nm = Scan.IntArray(2);
        int n, m;
        n = nm[0];
        m = nm[1];
        int[,] edge = Scan.IntSquareArray(m, 2);
        int cnt = 0;
        for (int i = 0; i < m; i++)
        {
            // i が取り除く<辺を張らない>インデックス
            UnionFind uf = new UnionFind();
            uf.Init(n);
            for (int j = 0; j < m; j++)
            {
                if(i != j)
                {
                    uf.Unite(edge[j, 0], edge[j, 1], 0);
                }
            }
            if (!uf.Same(edge[i, 0], edge[i, 1]))
            {
                cnt++;
            }
        }
        Out.Num(cnt);
    }
}

public class Scan
{
    public static int[] IntArray(int t)
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] ar = new int[t];
        for (int i = 0; i < t; i++)
        {
            ar[i] = int.Parse(str[i]);
        }
        return ar;
    }

    public static int[,] IntSquareArray(int h, int w)
    {
        int[,] resAr = new int[h, w];
        for (int i = 0; i < h; i++)
        {
            int[] ar = Scan.IntArray(w);
            for (int j = 0; j < w; j++)
            {
                resAr[i, j] = ar[j];
            }
        }
        return resAr;
    }
}

public class Out
{
    public static void Num<T>(T a)
    {
        Console.WriteLine(a);
    }
}

public class UnionFind
{
    public int[] parent;
    public int[] rank;
    public long[] weightDiff;

    public void Init(int size)
    {
        parent = new int[size + 5];
        rank = new int[size + 5];
        weightDiff = new long[size + 5];
        for (int i = 0; i < size; i++)
        {
            parent[i] = i;
            rank[i] = 0;
            weightDiff[i] = 0;
        }
    }

    public int Root(int x)
    {
        if(parent[x] == x)
        {
            return x;
        }
        else
        {
            int r = Root(parent[x]);
            weightDiff[x] += weightDiff[parent[x]];
            return parent[x] = r;
        }
    }

    public bool Unite(int x, int y, long w) // Add edge x <- y (weight: w)
    {
        w = w + GetWeight(x) - GetWeight(y);
        x = Root(x);
        y = Root(y);
        if (x == y) return false;
        if(rank[x] < rank[y])
        {
            int tmp = x; x = y; y = tmp;
            w *= -1;
        }
        if(rank[x] == rank[y])
        {
            ++rank[x];
        }
        parent[y] = x;
        weightDiff[y] = w;
        return true;
    }

    public bool Same(int x, int y)
    {
        return Root(x) == Root(y);
    }

    public long GetWeight(int x)
    {
        Root(x);
        return weightDiff[x];
    }

    public long Diff(int x, int y) // x -> y
    {
        return GetWeight(y) - GetWeight(x);
    }
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size() - 1;
    int i = 0;
    int cnt = 0;
    while(i <= n){
        if(s[i] != s[n]){
            cnt++;
        }
        i++;
        n--;
    }
    cout << cnt;
    return 0;
}


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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli n, m, _max = 0;
	if ( cin >> n >> m );
	else return false;
	
	string plate[n];
	
	for (int i = 0; i < n; ++i) {
		cin >> plate[i];
	}
	
	lli row[n][m], col[n][m];
	MEM( row, 0 );
	MEM( col, 0 );
	
	for (int i = 0; i < n; ++i) {
		int l = -1, r = -1, j = 0;
		while ( j < m ) {
			l = r+1;
			for ( j = l; j < m and plate[i][j] == '.'; ++j);
			r = j;
			for (int k = l; k < r; ++k) row[i][k] = r-l;
		}
	}
	
	for (int i = 0; i < m; ++i) {
		int u = -1, d = -1, j = 0;
		while ( j < n ) {
			u = d+1;
			for ( j = u; j < n and plate[j][i] == '.'; ++j);
			d = j;
			for (int k = u; k < d; ++k) col[k][i] = d-u;
		}
	}
	
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			_max = max( _max, row[i][j] + col[i][j] - 1 );
		}
	}
	
	cout << _max << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}


Measured memory_bytes: 66816