akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
using namespace std;

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

    if(n<10){
        cout<<n<<endl;
    }else if(n<100){
        cout<<9<<endl;
    }else if(n<1000){
        cout<<9+n-99<<endl;
    }else if(n<10000){
        cout<<9+900<<endl;
    }else if(n<100000){
        cout<<9+900+n-9999<<endl;
    }else{
        cout<<90909<<endl;
    }

    
    return 0;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), K = Integer.parseInt(ST.nextToken()); boolean snukeFed[] = new boolean[N];
		for (int i = 1; i <= K; i++)
		{
			int Snukes = Integer.parseInt(BR.readLine());
			ST = new StringTokenizer(BR.readLine());
			for (int j = 0; j < Snukes; j++)
			{
				int Snuke = Integer.parseInt(ST.nextToken()) - 1;
				snukeFed[Snuke] = true; 
			}
		}
		
		int Count = 0;
		for (int i = 0; i < snukeFed.length; i++) if (!snukeFed[i]) Count++;
		System.out.println(Count);
	}
}


Measured memory_bytes: 26948
#include <bits/stdc++.h>
using namespace std;
 
 string arr;
 long long dp[105][4][2];
int k;
 
long long back(int in, int nnzer, bool flag  ){
 
	 if(nnzer>k) return 0;
 	if(in> arr.size()) {  if(nnzer==k) return 1; else return 0;  }
	
	if(dp[in][nnzer][flag]!=-1) return dp[in][nnzer][flag];
	
 	 int limit = 9;
 	 if(!flag) limit=  arr[in-1]-'0';
	long long res =0;
	
	res+=	back(in+1,  nnzer,  flag || limit!=0);
		
 	for(int i=1; i<=limit; ++i){
 
	res+=	back(in+1,  nnzer+1, flag || i<limit);	
 	
 	}
 	
	return dp[in][nnzer][flag] = res;
 }
 
 
 
int main() {
 
	string a;
	cin>>a;
	cin>>k;
	memset(dp, -1, sizeof dp);
	 arr=a;
	 
	long long  c= back(1,0,false);
	 
	 cout<<(c)<<'\n';   
	return 0;
}
 

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


int main(){
  int N, R;
  cin >> N >> R;
  int rate;

  if (N >= 10){
    rate = R;
  }else{
    rate = R + 100 * (10 - N);
  }

  cout << rate << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,t=0;
	cin>>n;
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
		{
			if(n==i*j)
			{
				t=1;
				break;
			}
			if(t==1) break; 
		}
	switch(t)
	{
		case 0:cout<<"No";break;
		case 1:cout<<"Yes";break;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<queue>
#include<iostream>
using namespace std;
int main()
{
    char s[10000];
    cin>>s;
    cout<<s[0];
    int num=0,i;
    int len=strlen(s);
    for(i=1;i<len-1;i++)
        num+=1;
    cout<<num<<s[len-1]<<endl;
}


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

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

#define fr first
#define sc second

const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const char c[4] = { 'R','L','U','D' };

int main(){
	ll n;
	ll x[1002],y[1002];
	scanf("%lld",&n);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%lld%lld",&x[i],&y[i]);
	}
	
	ll cnt[2] = {};
	for(int i = 1 ; i <= n ; i ++){
		cnt[abs(x[i]+y[i])%2] ++;
	}
	if(cnt[0] != 0 && cnt[1] != 0){
		puts("-1");
		return 0;
	}
	
	if(cnt[0] != 0){
		vector<ll> vec;
		ll sum = 0;
		for(int i = 0 ; i < 20 ; i ++){
			vec.push_back(sum+1);
			sum += 2*(sum+1);
		}
		cout << 40 << endl;
		for(int i = vec.size()-1 ; i >= 0 ; i --){
			cout << vec[i] << " " << vec[i];
			if(i==0)cout << endl;
			else cout << " ";
		}
		for(int q = 1 ; q <= n ; q ++){
			string ret = "";
			for(int i = vec.size()-1 ; i >= 0 ; i --){
				for(int s = 0 ; s < 4 ; s ++){
					for(int t = s ; t < 4 ; t ++){
						ll nx = x[q]+(dx[s]+dx[t])*vec[i];
						ll ny = y[q]+(dy[s]+dy[t])*vec[i];
						if(abs(nx)+abs(ny) <= vec[i]-1){
							x[q] = nx;
							y[q] = ny;
							ret += c[s];
							ret += c[t];
							goto nex2;
						}
					}
				}
				nex2:;
			}
			cout << ret << endl;
		}
	}
	else {
		vector<ll> vec;
		ll sum = 1;
		for(int i = 0 ; i < 19 ; i ++){
			vec.push_back(sum+1);
			sum += 2*(sum+1);
		}
		cout << 39 << endl;
		for(int i = vec.size()-1 ; i >= 0 ; i --){
			cout << vec[i] << " " << vec[i] << " ";
		}
		cout << 1 << endl;
		for(int q = 1 ; q <= n ; q ++){
			string ret = "";
			for(int i = vec.size()-1 ; i >= 0 ; i --){
				for(int s = 0 ; s < 4 ; s ++){
					for(int t = s ; t < 4 ; t ++){
						ll nx = x[q]+(dx[s]+dx[t])*vec[i];
						ll ny = y[q]+(dy[s]+dy[t])*vec[i];
						if(abs(nx)+abs(ny) <= vec[i]-1){
							x[q] = nx;
							y[q] = ny;
							ret += c[s];
							ret += c[t];
							goto nex;
						}
					}
				}
				nex:;
				//cout << x[q] << " " << y[q] << endl;
			}
			if(x[q] == 1)ret += "R";
			else if(x[q] == -1)ret += "L";
			else if(y[q] == 1)ret += "U";
			else ret += "D";
			cout << ret << endl;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

const int N=2e5+5;
vector<int> visited(N);
vector<vector<int> > graf(N);
void dfs(int tr)
{
    for(auto p:graf[tr])
        if(!visited[p])
            visited[p]=visited[tr]+1,dfs(p);
}
int main()
{
	int n;
	scanf("%i",&n);
	for(int i=1;i<n;i++)
    {
        int a,b;
        scanf("%i %i",&a,&b);
        a--;b--;
        graf[a].pb(b);
        graf[b].pb(a);
    }
    visited[0]=1;
    dfs(0);
    int maxx=0,gde;
    for(int i=0;i<n;i++)
        if(visited[i]>maxx)
            maxx=visited[i],gde=i;
    fill(all(visited),0);
    visited[gde]=1;
    dfs(gde);
    maxx=0;
    for(int i=0;i<n;i++)
        maxx=max(visited[i],maxx);
    if(maxx%3==2)
        printf("Second\n");
    else
        printf("First\n");
    return 0;
}


Measured memory_bytes: 18176
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void output_vector(const vector<T> &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());

    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int N;
    string T;
    cin >> N >> T;
    int L = int(T.size());
    vector<int> P3(N + 1, 1);

    for (int i = 1; i <= N; i++)
        P3[i] = 3 * P3[i - 1];

    vector<int> P(P3[N], 0);
    vector<int> last(L + 1, 0);

    for (int n = 1; n <= N; n++) {
        int P_n = P3[n], P_low = P3[n - 1];

        for (int i = P_low; i < P_n; i++)
            P[i] = P[i % P_low];

        vector<int> D(P_n, -1);

        for (int i = 0; i < P_n; i++)
            D[i] = i / P_low;

        vector<int> last_updated(P_n, 0);
        vector<bool> partial_flips(L + 1, false);

        auto &&get_D = [&](int index, int now) {
            bool flip = partial_flips[now] ^ partial_flips[last_updated[index]];

            if (flip && D[index] > 0)
                D[index] = 3 - D[index];

            last_updated[index] = now;
            return D[index];
        };

        auto &&increment = [&](int index, int now) {
            D[index] = (get_D(index, now) + 1) % 3;
        };

        vector<int> next_last(L + 1, -1);
        next_last[0] = last[0] + 2 * P_low;

        for (int i = 0; i < L; i++) {
            partial_flips[i + 1] = partial_flips[i];

            if (T[i] == 'S') {
                partial_flips[i + 1] = !partial_flips[i];
            } else {
                increment(last[i], i);
                increment(last[i] + P_low, i);
                increment(last[i] + 2 * P_low, i);
            }

            for (int x = 0; x < 3; x++)
                if (get_D(last[i + 1] + x * P_low, i + 1) == 2)
                    next_last[i + 1] = last[i + 1] + x * P_low;
        }

        for (int i = 0; i < P_n; i++)
            P[i] += get_D(i, L) * P_low;

        last = next_last;
        dbg(P);
        dbg(last);
    }

    output_vector(P);
}


Measured memory_bytes: 11184
#include<bits/stdc++.h>
#define N 100005
#define LL long long
using namespace std;
const int mo=1e9+7,I2=(mo+1)/2;
vector<int> G[N],E[N];
int n,a[N],ufs[N],g[N],d[N],c[N],w[N],lw,vis[N],nu[N],ans=1,cnt,tot,L[N],X[N],cir[N],fc[N],xf[N],f[N];
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
LL C(int n,int m){ return 1LL*fc[n]*xf[m]%mo*xf[n-m]%mo;}
int find(int x){ return ufs[x] ? ufs[x]=find(ufs[x]) : x;}
void dfs(int t)
{
	int i; vis[t]=1,w[++lw]=t;
	for(i=0;i<G[t].size();i++)
		if(!vis[G[t][i]]) dfs(G[t][i]);
}
int DFS(int t)
{
	int i,cnt=0;
	for(i=0;i<E[t].size();i++)
		if(!cir[E[t][i]]) cnt++;
	if(cnt>1) ans=0;
	for(i=0;i<E[t].size();i++)
		if(!cir[E[t][i]]) return DFS(E[t][i])+1;
	return 0;
}
void solve(int t)
{
	int i,j,x,y,z;
	lw=cnt=0,dfs(t);
	for(i=1;i<=lw;i++)
		if(d[w[i]]&1) break;
	if(i>lw){ c[lw]++; return ;}
	for(i=1;i<=lw;i++)
		for(j=0;j<E[w[i]].size();j++){
			if(find(E[w[i]][j])==find(w[i])) y=w[i],x=E[w[i]][j];
			else ufs[E[w[i]][j]]=w[i];
		  }
	tot=0,cir[x]=cir[y]=1;
	for(i=y;i!=x;i=a[i]) cir[i]=1;
	for(i=y;i!=x;i=a[i]){
		nu[i]=++cnt,z=DFS(i);
		if(z) ++tot,L[tot]=z,X[tot]=cnt;
	  }
	nu[x]=++cnt,z=DFS(x);
	if(z) ++tot,L[tot]=z,X[tot]=cnt;
	for(i=2;i<=tot;i++){
		if(L[i]>X[i]-X[i-1]) ans=0;
		if(L[i]<X[i]-X[i-1]) ans=(ans+ans)%mo;
	  }
	if(L[1]>X[1]+cnt-X[tot]) ans=0;
	if(L[1]<X[1]+cnt-X[tot]) ans=(ans+ans)%mo;
}
void dp(int t)
{
	int i,sum=0,pw=1;
	if(t%2==1&&t>1)
		for(i=1;i<=c[t];i++) pw=(pw*2)%mo;
	for(i=0;i*2<=c[t];i++){
		sum=(sum+C(c[t],2*i)*pw%mo*f[i]%mo)%mo,pw=1LL*pw*t%mo;
		if((t&1)&&t>1) pw=1LL*pw*I2%mo*I2%mo;
	  }
	ans=1LL*ans*sum%mo;
}
int main()
{
	int i;
	scanf("%d",&n),fc[0]=xf[0]=f[0]=1;
	for(i=1;i<=n;i++){
		fc[i]=1LL*fc[i-1]*i%mo;
		xf[i]=fpm(fc[i],mo-2);
		f[i]=f[i-1]*(2LL*i-1)%mo;
	  }
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		G[a[i]].push_back(i);
		G[i].push_back(a[i]);
		E[a[i]].push_back(i);
		d[i]++,d[a[i]]++;
	  }
	for(i=1;i<=n;i++)
		if(d[i]>=4){ printf("0"); return 0;}
	for(i=1;i<=n;i++){
		if(vis[i]) continue;
		solve(i);
	  }
	for(i=1;i<=n;i++) dp(i);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 19328
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 100000000;
const int N = 16;

class State{
public:
  int pos, light, cost;
};

int n, m;
bool r[N][N];
bool G[N][N];
int l;
vector<pair<int, int> > path;
int memo[N][(1<<N)];
pair<int, int> p[N][(1<<N)];

int solve(){
  fill(memo[0], memo[N], INF);
  memo[0][l] = 0;
  State u, v;
  u.light = l;
  u.pos = 0;
  u.cost = 0;
  fill(p[0], p[N], make_pair(-1, -1));
  queue<State> Q;
  Q.push(u);
  while(!Q.empty()){
    u = Q.front(); Q.pop();
    for(int i=0;i<n;i++){
      if(!G[u.pos][i]) continue;
      v.pos = i;
      v.light = u.light;
      v.cost = u.cost + 1;
      if(!(1<<v.pos & v.light)) continue;
      if(memo[v.pos][v.light] <= v.cost) continue;
      memo[v.pos][v.light] = v.cost;
      p[v.pos][v.light] = make_pair(0, u.pos);
      Q.push(v);
    }
    for(int i=0;i<n;i++){
      if(!r[u.pos][i]) continue;
      v.pos = u.pos;
      v.cost = u.cost + 1;
      int f;
      if(1<<i & u.light && i != u.pos){
	v.light = u.light & ~(1<<i);
	f = 2;
      }else{
	v.light = u.light | 1<<i;
	f = 1;
      }
      if(memo[v.pos][v.light] <= v.cost) continue;
      memo[v.pos][v.light] = v.cost;
      p[v.pos][v.light] = make_pair(f, i);
      Q.push(v);
    }
  }
  if(memo[n-1][1<<(n-1)] == 0) return 0;
  if(memo[n-1][1<<(n-1)] < INF){
    path.clear();
    int pos = n-1, light = 1<<(n-1);
    while(1){
      pair<int, int> tmp = p[pos][light];
      if(tmp.first <= -1 && tmp.second <= -1){
	break;
      }
      if(tmp.first == 0){
	path.push_back(make_pair(0, pos));
	pos = tmp.second;
      }else if(tmp.first == 1){
	path.push_back(tmp);
	light = light & ~(1<<tmp.second);
      }else if(tmp.first == 2){
	path.push_back(tmp);
	light = light | 1<<tmp.second;
      }
    }
    reverse(path.begin(), path.end());
    return memo[n-1][1<<(n-1)];
  }
  for(int i=0;i<(1<<n);i++){
    if(memo[n-1][i] != INF) return -1;
  }
  return -2;
}

main(){
  while(cin >> n >> m){
    if(n<1) break;
    if(m<1) break;
    if(n>15) break;
    if(m>30) break;
    fill(r[0], r[N], false);
    fill(G[0], G[N], false);
    for(int i=0;i<m;i++){
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      G[a][b] = G[b][a] = true;
    }
    l = 0;
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      if(!a) continue;
      l |= (1<<i);
    }
    for(int i=0;i<n;i++){
      int k;
      cin >> k;
      for(int j=0;j<k;j++){
	int a;
	cin >> a;
	--a;
	r[i][a] = true;
      }
    }
    int ans = solve();
    if(ans == -2){
      cout << "Help me!" << endl;
    }else if(ans == -1){
      cout << "You can not switch off all lights." << endl;
    }else if(ans == 0){
      cout << "You can go home in " << ans << " steps." << endl;
    }else{
      cout << "You can go home in " << ans << " steps." << endl;
      for(int i=0;i<path.size();i++){
	switch(path[i].first){
	case 0:
	  cout << "Move to ";
	  break;
	case 1:
	  cout << "Switch on ";
	  break;
	case 2:
	  cout << "Switch off ";
	  break;
	}
	cout << "room " << path[i].second+1 << "." << endl;
      }
    }
  }
  return 0;
}

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

using namespace std;

#define ll long long
#define pii pair<int, int>

#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char dir[] = {'R', 'L', 'D', 'U'};
const int MOD = 1e9 + 7;

void solve()
{
    int h, w; cin >> h >> w;
    bool grid[h][w];
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            char x; cin >> x;
            if(x == '.') grid[i][j] = false;
            else grid[i][j] = true;
        }
    }
    ll dp[h][w];
    dp[0][0] = 1;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            if(i == 0 && j == 0) continue;
            if(grid[i][j]) 
            {
                dp[i][j] = 0;
                continue;
            }
            ll x = 0;
            if(i - 1 >= 0)
            {
                if(grid[i - 1][j] == 0) x += dp[i - 1][j];
                x%= MOD;
            }
            if(j - 1 >= 0)
            {
                if(grid[i][j - 1] == 0) x += dp[i][j - 1];
                x %= MOD;
            }
            dp[i][j] = x % MOD;
        }
    }
    cout << dp[h - 1][w - 1];
    
}

int main()
{
    fastio

    //ifstream fin(".in");
    //ofstream fout(".out");


    int t = 1;
    //cin >> t;

    while(t-- > 0) solve();
}


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

    int main(){
        char a , b;
        cin >> a >> b;
        if(a == b){
            cout << "=" << endl;
        }else if(a < b){
            cout << "<" << endl;
        }else{
            cout << ">" << endl;
        }
        
        return 0;
    }

Measured memory_bytes: 256
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int v,sum;
char s[N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(register int i=1;i<=len;i++)
	{
		if(s[i]=='S')v++;
		if(s[i]=='T'){if(v)v--;else sum++;}
	}
	cout<<sum+v<<endl;
	return 0;
}


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

using namespace std;

int main() {
	string str;
	while (getline(cin, str)) {
		for (int i = 0; i < 26; ++i) {
			for (int j = 0; j < (int)str.size(); ++j) {
				if (str[j] >= 'a' && str[j] <= 'z') {
					str[j] = (str[j] - 'a' + 1) % 26 + 'a';
				}
			}
			if (str.find("the") != string::npos || str.find("this") != string::npos || str.find("that") != string::npos) break;
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 1176
import std.stdio;
import std.string;
import std.conv;

int main()
{
    string[] str = readln().chomp().split();
    double a = str[0].to!double;
    double b = str[1].to!double;
    const double s = 3.305785;
    double ans = a * b / s;
    writefln("%.6f", ans);

    return 0;
}

Measured memory_bytes: 1136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int h,w,n;
  cin >> h >> w >> n;
  int a=0,b=0,ans1=0,ans2=0;
  rep(i,h){
    a+=w;
    ans1++;
    if(a>=n) break;
  }
  rep(i,w){
    b+=h;
    ans2++;
    if(b>=n) break;
  }
  cout << min(ans1,ans2) << endl;
  return 0;
}


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

int main(){
  priority_queue< int, vector<int>, greater<int> > que;
  for(int i = 0;i < 3;i++){
    int a;
    cin >> a;
    que.push(a);
  }

  for(int i = 0;i < 2;i++){
    cout << que.top() << " ";
    que.pop();
  }
  cout << que.top() << "\n";
  que.pop();
  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int nleft=0;
  int nright=0;
  for(int i=0; i<N; i++){
    if(S[i]=='(') nright++;
    else if(S[i]==')'){
      if(nright==0) nleft++;
      else nright--;
    }
  }
   for(int i=0; i<nleft; i++){
     cout<<'(';
   }
   cout<<S;
   for(int i=0; i<nright; i++){
     cout<<')';
   }
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split(' ')))

H = H[::-1]

for i in range(N-1):
	if H[i] < H[i+1]:
		if H[i+1] - H[i] > 1:
			print('No')
			exit()
		else:
			H[i+1] -= 1

print('Yes')



Measured memory_bytes: 14396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");

		long ans = 0;
		long count = 0;

		for (int i = 0; i < str.length; i++) {
			if (str[i].equals("W")) {
				ans += count;
			} else {
				count++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 40084
#include<iostream>
#include<string>
#include<cmath>

using namespace std;


int main(){
	int R, G, B, N;
	int cnt = 0;
	int b=0;

	cin >> R >> G >> B >> N;
	

	for (int r = 0; r*R <= N; r++){
		for (int g = 0; g*G <= N - r*R; g++){

			if ((N - (r*R + g*G)) % B == 0){
				b = (N - (r*R + g*G)) / B;
			}

				if (r*R + g*G +b*B == N){
					cnt++;
			}
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- conding: utf-8 -*-

raw = raw_input()
a = int(raw.split()[0])
b = int(raw.split()[1])
c = int(raw.split()[2])

if (b - a) - (c - b) == 0:
    print 'YES'
else:
    print 'NO'


Measured memory_bytes: 2568
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	string s; CI s;
	int w; CI w;
	REP(i, s.length()) {
		if(i%w==0||i%w==w)CO s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int k;
	cin >> k;
	int x = 7 % k;
	set<int> s;
	int i = 1;
	while (s.count(x) == 0)
	{
		if (x == 0)
		{
			cout << i << endl;
			return;
		}
		s.insert(x);
		x = (x * 10 + 7) % k;
		i++;
	}
	cout << -1 << endl;
}

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

	solve();
}


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

typedef long long ll;

int main()
{
    ll n,i;
    cin >> n;
    ll k = sqrt(n);
    for(i = k;i >= 1;--i){
        if(n%i == 0){
            ll m = n/i;
            ll ans = 0;
            while(m){
                m /= 10;
                ++ans;
            }
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

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

        using namespace std;

        typedef long long ll;
        const ll N = 5e5+5;
        const ll MOD = 1000000007;
        #define all(x) x.begin(),x.end()
        #define pii pair<ll,ll>
        #define pis pair<ll,string>
        #define F first
        #define S second
        #define LCM(a,b) ((a*b)/__gcd(a,b))
        #define inf 1e15
        #define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
        #define PI 3.14159265
        #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
        const double EPS = 1E-9;
        typedef vector< vector<double> > matrix;
        typedef vector<int> vi;




int main(){

    fast;
    int n;

    cin >> n;

    cout << (n ^ 1) << "\n";
    return 0;
}


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

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

	sum = 0;
	for (int num = n; num != 0; num /= 10)
		sum += num % 10;

	if (n % sum == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
// AOJ 0623: Zombie Island
// 2017.11.18 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 200000
typedef struct { int node; long long t; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
//	return 1;
}

void enq(int n, long long t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define MAX 100000
typedef struct { int len, to[20]; } TBL;
TBL tbl[MAX+1];
int len[MAX+1];
int zombie[MAX+1];
char visited[MAX+1];
int N, S, P, Q;

void dijkstra1()
{
	int i, s, e, d;

	while (qsize) {
		s = que[0].node, d = (int)que[0].t, deq();
		if (visited[s]) continue;
		visited[s] = 1;
		zombie[s] = d;
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i];
			if (visited[e]) continue;
			enq(e, d+1);
		}
	}
}

long long fee[MAX+1];
long long dijkstra2(int start, int goal)
{
	int i, s, e;
	long long d = 0;

	qsize = 0;
	for (i = 0; i < N; i++) visited[i] = (zombie[i] == 0);
	enq(start, 0);
	while (qsize) {
		s = que[0].node, d = que[0].t, deq();
		if (s == goal) break;
		if (visited[s]) continue;
		visited[s] = 1;
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i];
			if (visited[e]) continue;
			if (e == goal) enq(e, d);
			else if (zombie[e] <= S) enq(e, d+Q);
			else enq(e, d+P);
		}
	}
	return d;
}

char buf[40], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int M, K, i, a, b, c;

	fgets(p=buf, 40, stdin);
	N = getint(), p++, M = getint(), p++, K = getint(), p++, S = getint();
	fgets(p=buf, 40, stdin);
	P = getint(), p++, Q = getint();
	qsize = 0;
	for (i = 0; i < K; i++) {
		fgets(p=buf, 40, stdin);
		c = getint()-1, enq(c, 0);
	}
	for (i = 0; i < M; i++) {
		fgets(p=buf, 40, stdin);
		a = getint()-1, p++, b = getint()-1;
		tbl[a].to[len[a]++] = b;
		tbl[b].to[len[b]++] = a;
	}
	dijkstra1();
	printf("%lld\n", dijkstra2(0, N-1));
	return 0;
}

Measured memory_bytes: 11204
#include <stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  int count=0;
  int prime[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
  int count_prime[25]={};
  int i,temp,j,k,l;
  int count_2=0, count_4=0, count_14=0, count_24=0, count_74=0;

  //N!を素因数分解する．
  //iはN!の1~N　jはprime[]のindex．
  //tempはiの作業用変数．
  for(i=1;i<=N;i++){
    temp=i;
    j=0;
    while(temp!=1){
      if(temp%prime[j]==0){
        temp=temp/prime[j];
        count_prime[j]++;
      }else{
        j++;
      }
    }
  }

  /*for(j=0;j<25;j++){
    printf("count_prime[%2d] = number of %2d = %2d\n",j,prime[j],count_prime[j]);
  }*/

  //75数の個数を調べる
  //count_2・・・count_74を埋める．
  for(j=0;j<25;j++){
    if(2<=count_prime[j]) count_2++;
    if(4<=count_prime[j]) count_4++;
    if(14<=count_prime[j]) count_14++;
    if(24<=count_prime[j]) count_24++;
    if(74<=count_prime[j]) count_74++;
  }
  /*printf("count_2=%d\n",count_2);
  printf("count_4=%d\n",count_4);
  printf("count_14=%d\n",count_14);
  printf("count_24=%d\n",count_24);
  printf("count_74=%d\n",count_74);*/

  //count_2・・・から75数を求める．
  //case1 74
  count+=count_74;
  //case2 24,4
  count+=count_24*(count_2-1);
  //case3 14,4
  count+=count_14*(count_4-1);
  //case4 4,4,2
  count+=(count_4*(count_4-1)/2)*(count_2-2);

  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

void call(int n){
  int i = 1;
  
  do {
    int x = i;
    if ( x % 3 == 0 ){ 
      printf(" %d", i);
      continue;
    }
    
    else do{
	if ( x % 10 == 3 ){
	  printf(" %d", i);
	  break;
	}
	else 
	  x /= 10;
      }while( x );
	
  }while( ++i <= n );
	    
  printf("\n");
}

int main (void){
  int n;
  
  scanf("%d", &n);
  call(n);
  return 0;
}
  

Measured memory_bytes: 600
#include<stdio.h>
#define mod 1000000007

int main(void){
  long long n,a,t=0,r=1,i;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    t++;
    if(a<(2*t-1)){
      r*=t;
      r%=mod;
      t--;
    }
  }
  while(t>0){
    r*=t;
    r%=mod;
    t--;
  }
  printf("%lld\n",r);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <map>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
#include <bitset>
using namespace std;

#define ll long long
#define N 300005
#define EDGE 200005

int in[N];
ll sum(ll x) {
  if(x<=0) return 0;
  return (x*(x+1))/2;
}
ll getSum(ll x,ll y) {
  return sum(y)- sum(x-1);
}

ll getLineLength(vector<pair<ll,ll> > &line,ll d) {
  sort(line.begin(),line.end());
  ll ret = 0;
  int numLine = 0;
  long long prev = -8e18;
  d = abs(d);
  ll mini = line[0].first;
  for(int i=0;i<line.size();++i) {
    line[i].first = (line[i].first-mini);
    if(d!=0) {
      line[i].first /= d;
      assert(line[i].first%2==0);
      line[i].first/=2;
    }
  }
  sort(line.begin(),line.end());
  for(int i=0;i<line.size();++i) {
    if(line[i].second==1) {
      ++line[i].first;
    }
  }
  sort(line.begin(),line.end());
  for(int i=0;i<line.size();++i) {
    if(numLine>0) {
      ret += line[i].first - prev;
    }
    assert(numLine>=0);
    if(line[i].second==0) {
      ++numLine;
    } else {
      --numLine;
    }
    prev = line[i].first;
  }
  return ret;
}
void solve() {
  ll n,x,d;scanf("%lld %lld %lld\n", &n,&x,&d);
  if(d==0) {
    if(x==0) {
      printf("1\n");
    } else {
      printf("%d\n", n+1);
    }
    return;
  }
  map<int,vector<pair<ll,ll> > > Hash;
  for(int k=0;k<=n;++k) {
    long long xval = (n - k*2)*x;
    long long mini = xval + (sum(n) - sum(k)*2)*d;
    long long maxi = xval + (sum(n) - getSum(n-k+1,n)*2)*d;
    mini -= (n-k*2)*d;
    maxi -= (n-k*2)*d;

    long long x = abs(d)*2;
    int a = (mini%x + x)%x;
    int b = (maxi%x + x)%x;
    if(mini>maxi) {
      swap(mini,maxi);
    }
    Hash[a].push_back(make_pair(mini,0));
    Hash[a].push_back(make_pair(maxi,1));
  }
  ll ret = 0;
  for(map<int,vector<pair<ll,ll> > >::iterator it = Hash.begin();it!=Hash.end();++it) {
    ret += getLineLength( (*it).second,d);
  }
  printf("%lld\n", ret);
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

int main(){
  int a[][10] = {
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
                  };
  int b[][10] = {
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
                  };
  int c[][10] = {
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
                  };
  int d[][10] = {
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
                  };
  // for (int i = 0; i < 3; i++){
  //   for (int w = 0; w < 10; w++){
  //     cout << " " << b[i][w];
  //   }
  //   cout << endl;
  // }
  
  int x;
  cin >> x;

  int e, f, g, h;
  for (int i = 0; i < x; i++){
    cin >> e >> f >> g >> h;
    if(e == 1){
      a[f - 1][g - 1] += h;
    }else if(e == 2){
      b[f - 1][g - 1] += h;
    }else if(e == 3){
      c[f - 1][g - 1] += h;
    }else{
      d[f - 1][g - 1] += h;
    }
  }

  for (int i = 0; i < 3; i++){
    for (int w = 0; w < 10; w++){
      cout  << " " << a[i][w];
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 0; i < 3; i++){
    for (int w = 0; w < 10; w++){
      cout << " " << b[i][w];
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 0; i < 3; i++){
    for (int w = 0; w < 10; w++){
      cout << " " << c[i][w];
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (int i = 0; i < 3; i++){
    for (int w = 0; w < 10; w++){
      cout << " " << d[i][w];
    }
    cout << endl;
  }
}


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

int main(int argc, const char * argv[]) {
    int i,j=0;
    
    double n;
    double s[1000];
    double ans[1000];
    
    
    int sum=0;
    double m=0,a=0,b=0;
    
    while(1){
        scanf("%lf",&n);
        if(n==0){
            break;
        }
        
        for(i=0;i<n;i++){
            scanf("%lf",&s[i]);
        }
        
        for(i=0;i<n;i++){
            sum+=s[i];
        }
        
        m=sum/n;//mは平均
        
        for(i=0;i<n;i++){
            a+=pow(m-s[i],2);
        }
        
        b=a/n;
        
        ans[j]=sqrt(b);
        
        j++;
        sum=0;
        m=0;
        a=0;
    }
    
    for(i=0;i<j;i++){
        printf("%f\n",ans[i]);
    }
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    if (b / a >= c)
        cout << c << endl;
    else
        cout << b / a << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define mx 1000000
using namespace std;

int main() {
  ios
  int t = 1;
  // cin>>t;
  while(t--) {
    int x,n;
    cin>>x>>n;
    unordered_map<int,int> p;
    int a;
    for(int i = 0;i < n;i++) cin>>a,p[a]++;
    int i = 0;
    int ans;
    while(1) {
      if(p[x-i]==0) {
        ans = x-i;
        break;
      }
      if(p[x+i]==0) {
        ans = x+i;
        break;
      }
      i++;
    }
    cout<<ans;
    cout<<'\n';
  }
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

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

  string s;
  cin >> s;

  const auto a = s.find_first_of('A');
  const auto z = s.find_last_of('Z');
  cout << z - a + 1 << endl;

  return 0;
}


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

main()
{
	int k;
	char s[101] ;
	int i,m;
	
	scanf("%d",&k);
	
	scanf("%s",s);

	m=strlen(s);
	
	if(k<m)
	{
		for(i=0;i<k;i++)
		{
			printf("%c",s[i]);
		}
		printf("...");
		
	}
	else
	{
		printf("%s",s);
	}
	
}


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

typedef long long ll;

const int N = 1e5 + 20;
ll a[N], dp[N];

int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		ll t = 0;
		int f = 1;
		for (int j = i - k; j < i; j++)
		{
			if (j < 0) continue;
			if (f)
			{
				t = dp[j] + abs(a[i] - a[j]);
				f = 0;
				continue;
			}
			t = min(t, dp[j] + abs(a[i] - a[j]));
		}
		dp[i] = t;
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll N, S;

bool check(ll b){
    ll cpy = N;
    ll tmp = 0;
    while(cpy){
        tmp += cpy % b;
        cpy /= b;
    }
    return S == tmp;
}

ll solve(){
    for(ll b = 2; b <= sqrt(N) + 1; b++) if(check(b)) return b;
    ll ret = N + 1;
    for(ll p = 1; p <= sqrt(N) + 1; p++){
        ll q = S - p;
        ll b = (N - q) / p;
        if(b >= 2 && check(b)) ret = min(ret, b);
    }
    if(ret != N + 1) return ret;
    if(N == S) return N + 1;
    return -1;
}

int main(){
    cin >> N >> S;
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N,ans=0;
    cin>>N;
    vector<long long int> a(N,0);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<N;i++){
        int cnt = 0;
        int value=i;
        for(int j=value;a[i]==a[j];j++){
            cnt++;
            value = j;
        }
        i = value;
        ans += cnt%2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,m,l,r,x,f[5000010],s,a[500010],ans;
int main(){
	cin>>n;
	FOR(i,1,n-1) getint(a[i]);
	s=0;
	l=5000000,r=5000000;
	f[l]=0;
	FOR(i,3,n-1){
	//	0..s -> a[i]..s+a[i]
		FORD(j,l-1,l-a[i])
			if (l-j<=s) f[j]=f[l+l-j];
			else f[j]=l-j-s;
		s+=a[i];
		l-=a[i];
	}
	cin>>m;
	while (m--){
		getint(x);
		if (x<=s) ans=f[l+x]+a[1]-a[2];
		else ans=x-s+a[1]-a[2];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 8064
N, M , X, Y = [int(i) for i in input().split(' ')]
xs = [int(i) for i in input().split(' ')]
ys = [int(i) for i in input().split(' ')]
mx = max(xs+[X])
my = min(ys+[Y])
if my > mx:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//

//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	string s; cin >> s;
	int n = s.size();
	int sum = 0;
	rep(i, n)
	{
		if (s[i] == 'g') sum++;
	}

	Print((-n + 2 * sum) / 2);


	//
	// your code finished

	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/28  Problem: ABC 108 D / Link: http://abc108.contest.atcoder.jp/tasks/abc108_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

	LL N; cin >> N;
	LL Mxidx = 1;
	int idxcnt = 0;
	while (Mxidx * 2 <= N)Mxidx *= 2, idxcnt++;
	DD(de(N, Mxidx, idxcnt));
	N--;
	// idxcnt分はつくる
	int ansN = idxcnt + 1;
	using tp = tuple<int, int, int>;
	vector<tp>ans;
	{
		FOR(i, 0, idxcnt) {
			ans.push_back(tp(i + 1, i + 2, 1 << i));
			ans.push_back(tp(i + 1, i + 2, 0));
		}
	}
	LL sum = 0;
	FOR(i, 0, idxcnt) {
		sum += 1 << i;
	}
	DD(de(sum, N));
	FOR(i, sum + 1, N + 1) {
		DD(de(i));
		int cur = i;
		int addsum = 0;
		FOR(j, 0, idxcnt) {
			int add = 1 << j;
			if (cur + add <= N) {
				cur += add;
				addsum += add;
			}
			else {

				ans.push_back(tp(j + 1, idxcnt + 1, i));
				i += addsum;
				break;
			}
		}
	}



	cout << ansN << " " << SZ(ans) << endl;
	for (auto it : ans) {
		int a, b, c; tie(a, b, c) = it;
		cout << a << " " << b << " " << c << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
G=[[] for i in range(n)]
for i in range(n):
    s=input().rstrip()
    for j in range(i,n):
        if s[j]=='1':
            G[i].append(j)
            G[j].append(i)
Ans=-1
for i in range(n):
    ans=1
    que=[i]
    cs=set(que)
    check=[False]*n
    check[i]=True
    nex=[]
    M=False
    while True:
        while len(que)>0:
            now=que.pop()
            for j in G[now]:
                if j in cs:
                    M=True
                elif check[j]:
                    pass
                else:
                    check[j]=True
                    nex.append(j)
        que=nex
        if que==[]:
            break
        cs=set(que)
        nex=[]
        ans+=1
    if M:
        ans=-1
    Ans=max(ans,Ans)
print(Ans)
    
        
        


Measured memory_bytes: 41964
#include<bits/stdc++.h>
long long pow_mod(long long base,long long exp,long long mod){
    long long res = 1;
    while(exp>0){
        if(exp & 1)res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}
long long comb_mod(long long n,long long r,long long mod){
    long long nf=1;
    long long mf = 1;
    for(int i=1;i<=n;i++){nf*=i;nf%=mod;}
    for(int i=1;i<=n-r;i++){mf*=i;mf%=mod;}
    for(int i=1;i<=r;i++){mf*=i;mf%=mod;}
    mf = pow_mod(mf,mod-2,mod);
    return mf*nf%mod;
}
const int mod = 1e9+7;
int main()
{
    long long x,y;
    std::cin>>x>>y;
    bool res1 = true;
    int cnt;
    //座標の合計が3の倍数なら調べる価値がある
    if((x+y)%3!=0)res1 = false;
    cnt = (x+y)/3;
    //移動するかどうかで見ることができるようにする
    x -= cnt;
    y -= cnt;
    if(x<0||y<0)res1 = false;
    std::cout<<(res1?comb_mod(x+y,x,mod):0)<<std::endl;
 
 
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main () {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (c % __gcd(a, b) == 0) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}

Measured memory_bytes: 128
#ifdef local_mode
    #include <cstdio>
    #include <cassert>
#endif
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
#ifdef local_mode
    //#define FILENAME "test" ← defined via command line
    assert(freopen(FILENAME ".in", "r", stdin));
    assert(freopen(FILENAME ".out", "w", stdout));
#endif
    ios_base::sync_with_stdio(0), cin.tie(0);

    char a,b,c,d,e,f,g,h,i,j,k;
    cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
    cout << a << e << i;

    return 0;
}







































Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

void solve(){
  string s, t; cin >> s >> t;
  int sum = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == t[i]) sum++;
  }
  cout << sum << endl;
  return;
}

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


Measured memory_bytes: 256
N,K=map(int,input().split())

con = 0
ans = list(int() for _ in range(10001))
pre = 0


for _ in range(K):

    D = int(input())
    arr = list(map(int,input().split()))

    for j in range(D):

        ans[pre+j]=arr[j]

    pre += D

        
fin = (N+1) - len(set(ans))

print(fin)

Measured memory_bytes: 67880
import itertools
ans=[]
while 1:
    ct=0
    a,b=map(int,input().split())
    c=list(range(1,a+1))
    if (a==0)and(b==0):
        break
    list1=list(itertools.combinations(c,3))
    for i in range(len(list1)):
        if sum(list1[i])==b:
            ct+=1
    ans+=[ct]
for i in ans:
    print(i)


Measured memory_bytes: 31428
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5])
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}

    return 0;
}

Measured memory_bytes: 3708
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, pre = -1 ; 
    cin >> n ; 
    vector <int>  dp(200005,0), c(200005,-1) ; 
    dp[0] = 1 ; 
    for (int i=1,x ;i<=n; i++) { 
        cin >> x ; 
        dp[i] = dp[i-1];
        if ( c[x] != -1 and pre != x ) dp[i] = dp[c[x]] + dp[i-1] ; 
        c[x] = i ; 
        pre = x ; 
        dp[i] %= 1000000007;
    } 
    cout << dp[n] << endl ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 char[] O = sc.next().toCharArray();
		 char[] E = sc.next().toCharArray();

		StringBuilder sb = new StringBuilder();
		int ocnt = 0;
		int ecnt = 0;
		for(int i = 0;i < O.length+E.length;i++){
			if(i%2==0) {
				sb.append(O[ocnt]);
				ocnt++;
			}else {
				sb.append(E[ecnt]);
				ecnt++;
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 21716