akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int f[1000000];

signed main(){
    fill_n(f,1000000,1);
    f[0]=f[1]=0;
    for(int i=2;i<1000000;i++){
        if(!f[i])continue;
        for(int j=i+i;j<1000000;j+=i)f[j]=0;
    }
    for(int i=1;i<1000000;i++)f[i]+=f[i-1];

    int n;
    while(cin>>n)cout<<f[n]<<endl;
    return 0;
}

Measured memory_bytes: 8968
#include <iostream>
//#include <string>

using namespace 	std;
int main(void){
  int num,a,b;
  
  cin >> num;
  
  a=int(num/500);
  b=int((num-500*a)/5);
  
  cout << 1000*a+5*b << endl;

  return 0;  
}



Measured memory_bytes: 256
// AOJ ALDS1_3_B Queue
// 2018.4.30 bal4u

#include <stdio.h>

#define MAX_N 100002

typedef struct { char *p; int tm; } Q;
Q que[(MAX_N<<1)+2]; int top, end;
char name[MAX_N][20];

char buf[20], *p;
int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int  n, q, tm, i;
	Q  t;

	fgets(p=buf, 20, stdin);
	n = in(), q = in();
	for (i = 0; i < n; i++) {
		fgets(p=name[i], 20, stdin);
		while (*p > ' ') p++; *p++ = 0;
		que[i].p = name[i], que[i].tm = in();
	}

	tm = 0, top = 0, end = n;
	while (top != end) {
		t = que[top]; if (++top == MAX_N) top = 0;
		if (t.tm <= q) {
			printf("%s %d\n", t.p, tm+t.tm);
			tm += t.tm;
		} else {
			t.tm -= q;
			que[end] = t; if (++end == MAX_N) end = 0;
			tm += q;
		}
	}
	return 0;
}



Measured memory_bytes: 4204
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, counter2 = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

bool relation[1000][1000];
int twod[1001][1001];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2,input3;
char rev[100001];


int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int N, M;//はんい
int bfs() {
	queue<pair<int, int>> que;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			twod[i][j] = INF;
		}
	}
	que.push(pair<int, int>(sx, sy));
	twod[sx][sy] = 1;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		if (p.first == gy && p.second == gx) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (1 <= nx && nx <= N && 1 <= ny && ny <= M && maze[nx][ny] != '#'&&twod[nx][ny] == INF) {
				que.push(pair<int, int>(nx, ny));
				twod[nx][ny] = twod[p.first][p.second] + 1;
			}
		}
	}
	return twod[gy][gx];
}
vector <int> g[100100];
int main()
{
	cin >> input;
	rep(i, input.size()) {
		if (i % 2 == 0) { input2 += '0'; input3 += '1'; }
		else { input2 += '1'; input3 += '0';}
	}
	rep(i, input.size()) {
		if (input[i] != input2[i]) { counter++;}
		if (input[i] != input3[i]) { counter2++;}
	}
	cout << std::min(counter, counter2) << endl;


}

Measured memory_bytes: 6912
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

char s[100001];
int main(void){
	int a=0, b=0, c=0;
	int n=read(0, s, sizeof(s));
	for(int i=0; i<n-1; i++){
		if(s[i]=='a') a++;
		else if(s[i]=='b') b++;
		else c++;
	}
	puts(dif2(a,b)<=1&&dif2(b,c)<=1&&dif2(c,a)<=1?"YES":"NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[4][4],i,j,n,b;
bool x[4][4];
int main(){
	for(i=1;i<=3;i++)
		for(j=1;j<=3;j++)
			cin>>a[i][j];
	cin>>n;
	for(int s=1;s<=n;s++){
		cin>>b;
		for(i=1;i<=3;i++)
			for(j=1;j<=3;j++){
				if(a[i][j]==b) x[i][j]=true;
			}
	}
	for(i=1;i<=3;i++){
		if(x[i][1]==true && x[i][2]==true && x[i][3]==true)
		{
			cout<<"Yes";
			return 0;
		}
		if(x[1][i]==true && x[2][i]==true && x[3][i]==true){
			cout<<"Yes";
			return 0; 
		}
	}
	if(x[1][1]==true && x[2][2]==true && x[3][3]==true){
		cout<<"Yes";
		return 0;
	}
	if(x[3][1]==true && x[2][2]==true && x[1][3]==true){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
money = 1000
kabu = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        kabu = money//a[i] * a[i+1] #持ち株数×時価
        money = (money % a[i]) + kabu
print(money)
        
   





Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=5e5+10;
const int maxm=90e5+10;
char s[maxn],t[maxn];
int ns,nt,n;
int bl,br;
string all;
int z[maxm];
void Z_function()
{
	z[0]=n;
	bl=br=0;
	for(int i=1;i<n;i++)
	{
		z[i]=0;
		if(i<=br)
		{
			int p=i-bl;
			if(i+z[p]-1<br)
			{
				z[i]=z[p];
			}
			else
			{
				z[i]=min(z[p],br-i+1);
				while(i+z[i]<n&&all[i+z[i]]==all[z[i]])z[i]++;
				bl=i;
				br=i+z[i]-1;
			}
		}
		else
		{
			while(i+z[i]<n&&all[i+z[i]]==all[z[i]])z[i]++;
			bl=i;
			br=i+z[i]-1;
		}
	}
}
int nxt[61][maxn];
int main()
{
	scanf("%s",s);ns=strlen(s);
	scanf("%s",t);nt=strlen(t);
	string SS=s,TT=t;
	while(SS.length()<1e6)SS+=s;
	while(TT.length()<1e6)TT+=t;
	all=TT+"_"+SS;
	n=all.length();
	Z_function();
	int ans1=0;
	for(int i=TT.length()+1;i<n;i++)
	{
		ans1=max(ans1,z[i]/nt);
	}
	while(SS.length()<4e6)SS+=s;
	while(TT.length()<4e6)TT+=t;
	all=TT+"_"+SS;
	n=all.length();
	Z_function();
	int ans2=0;
	for(int i=TT.length()+1;i<n;i++)
	{
		ans2=max(ans2,z[i]/nt);
	}
	if(ans1==ans2)printf("%d\n",ans1);
	else printf("-1");
	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int w, h;
    cin >> w >> h;
    priority_queue<Int, vector<Int>, greater<Int>> q1, q2;
    for (Int i = 0; i < w; i++) {
        Int x;
        cin >> x;
        q1.push(x);
    }
    for (Int i = 0; i < h; i++) {
        Int x;
        cin >> x;
        q2.push(x);
    }
    h++;
    w++;
    Int res = 0;
    while (not (q1.empty() and q2.empty())) {
        if (q1.empty()) {
            res += q2.top() * w;
            q2.pop();
            h--;
        }
        else if (q2.empty()) {
            res += q1.top() * h;
            q1.pop();
            w--;
        }
        else {
            if (q1.top() <= q2.top()) {
                res += q1.top() * h;
                q1.pop();
                w--;
            }
            else {
                res += q2.top() * w;
                q2.pop();
                h--;
            }
        }
         //cout << "h = " << h <<" w = " << w << " res = " << res << endl;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
#define MOD 1000000007
#define pb push_back
#define int long long int

using namespace std;

int32_t main(void) {
    fast;
    int h, n, maxb=0, maxa=0, ans=1e9; cin>>h>>n;
    vector<array<int, 2> > a(n);
    for(int i=0; i<n; i++) {
        cin>>a[i][1]>>a[i][0];
        maxb = max(maxb, a[i][1]);
        maxa = max(maxa, a[i][0]);
    }
    vector<int> dp(h+maxb+2);
    for(int i=1; i<h+maxb+1; i++) {
        dp[i] = 1e9;
        for(int j=0; j<n; j++) {
            if(i - a[j][1] <0)
                dp[i] = min(dp[i], a[j][0]);
            else
                dp[i] = min(dp[i], dp[i - a[j][1]]+a[j][0]);
        }
    }
    //for(auto it : dp) cerr<<it<<" "; cerr<<endl;
    for(int i=h; i<h+maxb+1; i++) ans = min(ans, dp[i]);
    cout<<ans;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int count =0;
   int quo1=l/d;
   int quo2=r/d;
 	int rem=l%d;
 	if(rem==0)
 	{
    count=quo2-quo1+1;
 }
 else
 {
     count=quo2-quo1;
  } 
  cout<<count<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	string s; cin>>s;
	int a=-1,b=-1;
	rep(i,s.size()){
		if(a==-1&&s[i]=='A') a=i;
		if(s[i]=='Z') b=i;
	}
	cout<<b-a+1<<endl;
	return 0;
}


Measured memory_bytes: 720
import java.util.*;

class HowManyDivisors {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final int a = sc.nextInt();
        final int b = sc.nextInt();
        final int c = sc.nextInt();
        int cnt = 0;
        for (int i = a; i <= b; i++) {
            if (c % i == 0)
                cnt++;
        }
        System.out.println(cnt);
    }
}
public class Main {
    public static void main(String... args) {
        HowManyDivisors.main();
    }
}

Measured memory_bytes: 17364
from collections import deque

def bfs(s):
    stack=deque([s])
    check = [-1]*n
    check[s] = 0
    while len(stack)>0:
        v = stack.popleft()
        for i in root[v]:
            if check[i] == -1:
                check[i]=check[v]+1
                stack.append(i)
    return check

n,u,v = map(int,input().split())

root = [[] for i in range(n)]
for _ in range(n-1):
    a, b = (int(x) for x in input().split())
    root[b-1].append(a-1)
    root[a-1].append(b-1)

takahashi_root = bfs(u-1)
aoki_root = bfs(v-1)

ans = 0

for i in range(n):
    if takahashi_root[i] < aoki_root[i]:
        ans = max(ans,aoki_root[i]-1)
print(ans)


Measured memory_bytes: 91644
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;

int main(){
  int n;
  cin>>n;
  queue<int> q;
  vector<vector<pii> > g=vector<vector<pii> > (n+1,vector<pii>(0));
  vector<int> used(n+1,-1);
  FOR(i,1,n){
    int v,u,w;
    cin>>v>>u>>w;
    g[v].PB(MP(u,w));
    g[u].PB(MP(v,w));
  }
  q.push(1);
  used[1]=0;
  while(!q.empty()){
    int nw=q.front();
    q.pop();
    int l=g[nw].size();
    FOR(i,0,l){
      int to=g[nw][i].ST;
      int val=g[nw][i].ND;
      val=val&1;
      if(used[to]==-1){
        q.push(to);
        used[to]=used[nw]^val;
      }
    }
  }

  FORQ(i,1,n){
    cout<<used[i]<<endl;
  }

  return 0;
}


Measured memory_bytes: 6784
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		if(X < A) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}
	}
}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    int a, b;

    cin >> a >> b;

    for(int i = 1; i <= 3; i++) {
        if(i != a && i != b) {
            return cout << i, 0;
        }
    }

}








Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 100000000;

vector<string> text;
string buffer;

void setcursor(P &p, char com){
	switch(com){
	case 'a':
		p.X = 1;
		break;
	case 'e':
		p.X = text[p.Y].size();
		break;
	case 'p':
		setcursor(p, 'a');
		if(p.Y > 0) p.Y--;
		break;
	case 'n':
		setcursor(p, 'a');
		if(p.Y < text.size()-1) p.Y++;
		break;
	case 'f':
		if(p.X < text[p.Y].size()) p.X++;
		else{
			if(p.Y < text.size()-1){
				p.Y++;
				setcursor(p, 'a');
			}
		}
		break;
	case 'b':
		if(p.X > 1) p.X--;
		else{
			if(p.Y > 0){ 
				p.Y-- ;
				setcursor(p, 'e');
			}
		}
		break;
	case 'd':
		if(p.X < text[p.Y].size()){
			text[p.Y].erase(p.X-1, 1);
		}
		else if(p.X == text[p.Y].size()){
			if(p.Y < text.size()-1){
				text[p.Y].erase(p.X-1, 1);
				text[p.Y] += text[p.Y+1];
				text.erase(text.begin()+p.Y+1);
			}
		}
		break;
	case 'k':
		if(p.X == text[p.Y].size()){
			if(p.Y < text.size()-1){
				text[p.Y].erase(p.X-1, 1);
				text[p.Y] += text[p.Y+1];
				text.erase(text.begin()+p.Y+1);

				buffer = "\n";
			}
		}else{
			buffer = text[p.Y].substr(p.X-1);
			buffer.erase(buffer.size()-1);
			text[p.Y].erase(p.X-1);
			text[p.Y] += '\0';
		}
		break;
	case 'y':
		if(buffer == "")break;
		if(buffer != "\n"){
			text[p.Y].insert( p.X-1, buffer);
			p.X += buffer.size();
		}
		else{
			string tmp = text[p.Y].substr(p.X-1);
			text[p.Y].erase(p.X-1);
			text[p.Y] += '\0';
			p.Y++;
			text.insert(text.begin()+p.Y, tmp);
			setcursor(p, 'a');
		}
	}
}

void pp(P p){
	char tmp = '*';
	swap(tmp, text[p.Y][p.X-1]);
	rep(i, text.size()){
		cout << text[i] << endl;
	}
	swap(tmp, text[p.Y][p.X-1]);	
}


int main(){

	//freopen("test.txt", "r", stdin);

	string s;
	while(getline(cin, s), s != "END_OF_TEXT"){
		text.push_back(s+'\0');
	}

	//freopen("CON", "r", stdin);

	P cursor(MP(1, 0)); // y行x文字目

//pp(cursor);

	char com;
	while(cin >> com, com != '-'){
		setcursor(cursor, com);

		//pp(cursor);
		//printf("%d-%d\n", cursor.Y, cursor.X);
	}

	rep(i, text.size()){
		text[i].erase(text[i].size()-1, 1);
		cout << text[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n, m = read_int_list()
    if n > m:
      res = 'No'
    else:
      res = 'Yes'
    print(res)


main()


Measured memory_bytes: 3700
import java.util.*;
class Main{

    public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0; i<n; i++) 
    arr[i] = sc.nextInt();
    long res =0;
    for(int i=1; i<n; i++) {
     if(arr[i-1]>arr[i]){
     res += arr[i-1]-arr[i];
     arr[i] = arr[i-1];
     }
     }
    System.out.println(res);
     //   System.out.println("Hello World");
    }
}


Measured memory_bytes: 60108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] a) throws NumberFormatException, IOException{

		int arr[] = new int [10];
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		for( int i=0; i<10; i++){

		 arr[i] = Integer.parseInt(read.readLine());

		}

		 Arrays.sort(arr);

		 for(int i = 9; i>6; i--){

			 System.out.println(arr[i]);

	}

}
}

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

using namespace std;

set<int> g[222222];
int r[222222];
int main() {
	int n, m;
	string s;
	cin >> n >> m >> s;
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].insert(b);
		g[b].insert(a);
	}
	queue<int> q;
	for (int i = 0; i < n; i++)
		q.push(i + 1);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		if (r[v]) continue;
		int a = 0, b = 0;
		for (auto w : g[v]) {
			if (a&b) break;
			if (s[w - 1] == 'A')
				a = 1;
			else b = 1;
		}
		if (a&b) continue;
		r[v] = 1;
		n--;
		for (auto w : g[v]) {
			if (w == v) continue;
			g[w].erase(v);
			q.push(w);
		}
	}
	cout << (n ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 30340
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s; cin >> s;
    bool flag = false;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D') flag = true;
        }else{
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D') flag = true;
        }
    }
    if(flag) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> pq;
    rep(i, 0, n) {
        ll a;
        cin >> a;
        pq.push(a);
    }
    rep(i, 0, m) {
        ll tmp = pq.top();
        pq.pop();
        tmp /= 2;
        pq.push(tmp);
    }
    ll ans = 0;
    rep(i, 0, n) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int samecount(string S){
    int A = 0;
    for(int i = 0;i < S.size();i++){
        int QA = 1;
        for(int j = i ;j < S.size() - 1;j++){
           if(S.at(j) == S.at(j + 1)){
               QA++ ;
           }
           if(S.at(j) != S.at(j + 1)){
               break;
           }
           
        }
        A = max(QA,A);
    }
    return A;
}

int64_t minn(int64_t a,int64_t b){
    if(a >= b) return b;
    else return a;
}
int main(){
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    if((b-a)+(d-c) - (max({a,b,c,d}) - min({a,b,c,d})) >= 0) cout << (b-a)+(d-c) - (max({a,b,c,d}) - min({a,b,c,d}))<< endl;
    else cout << 0 << endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       ll n,i,j=0,a,b,c,d;
       std::cin >>a>>b>>c>>d;
       cout<<max(a*c,max(a*d,max(b*c,b*d)))<<"\n";
   }
}

Measured memory_bytes: 3644
N = input()
A = [int(x) for x in input().split()]

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

def lcm(a, b):
	return a // gcd(a, b) * b

L = 1

for a in A:
	L = lcm(L, a)

print(sum(L // a for a in A) % (10 ** 9 + 7))


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,l,r,T=0;
    cin>>N;
    
    for(int i=0;i<N;i++){
        cin>>l>>r;
        T+=r-l+1;
    }
    
    cout<<T<<endl;
         
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<string> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    int cnt[3] = {0};
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(v[i][0] == 'B' && v[i][v[i].size() - 1] == 'A') {
            cnt[0]++;
        }
        else if(v[i][0] == 'B') {
            cnt[1]++;
        }
        else if(v[i][v[i].size() - 1] == 'A') {
            cnt[2]++;
        }
        
        for(int j = 0; j < v[i].size(); j++) {
            if(v[i][j] == 'A') {
                if(j < n - 1 && v[i][j + 1] == 'B') {
                    ans++;
                }
            }
        }
    }
    
    if(cnt[0] > 0) {
        ans += cnt[0] - 1;
        if(cnt[1] > 0) {
            ans++;
            cnt[1]--;
        }
        if(cnt[2] > 0) {
            ans++;
            cnt[2]--;
        }
    }
    
    ans += min(cnt[1], cnt[2]);
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(){
  char a;
  int i=0,c;

  while(1){
    scanf("%c",&a);
    if(a=='\n'){
      printf("\n");
      break;
    }
    if(a>=65 && a<=90){
      a+=32;
    }
    else if(a>=97 && a<=122){
      a-=32;
    }
    printf("%c",a);
  }
  return 0;
}

Measured memory_bytes: 932
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, ans = 0; cin >> n;
	vi p(n); rep(i, n) cin >> p[i];
	
	rep(i, n - 2){
		ans += (p[i] < p[i + 1]) != (p[i + 1] > p[i + 2]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}


int main(){
    int A,B,C;

    cin >> A >> B >>C;

    cout << A*B/2 <<endl;
  
    return 0;

    


}

Measured memory_bytes: 256
N = int(input())
A = sorted(map(int, input().split()))
if A[0] == 1:
    if N > 1 and A[1] == 1:
        print(0)
    else:
        print(1)
else:
    ans = 0
    MAX = 10 ** 6 + 3
    C = [False] * MAX
    for i in range(N):
        if not C[A[i]]:
            if i != N - 1 and A[i] != A[i + 1]:
                ans += 1
            elif i == N - 1:
                ans += 1
            cur = 1
            while cur * A[i] <= MAX:
                C[cur * A[i]] = True
                cur += 1
    print(ans)

Measured memory_bytes: 101412
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,a,b,c;
  cin>>n;
  
  rep(i,n){
    cin>>a>>b>>c;
    if(a*a==b*b+c*c || b*b==c*c+a*a || c*c==a*a+b*b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
    
  
  return 0;
}


Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll int
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define pll pair<ll,ll>
const ll maxn= 2e5+10;
const ll mod = 5000000  ;
const ll base= 1e7;
ll a[maxn];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*  if (fopen("D_tst.INP","r"))
      {
          freopen("D_tst.INP","r", stdin);
          freopen("D_tst_1.cpp", "w",stdout);
      }*/
       ll n, k;
      cin>>n>> k;
      for (int i=1;i<=n;i++)
      {
          cin>>a[i];
      }
      ll pre=1;
      for (int i=k+1;i<=n;i++)
      {
          if (a[pre]<a[i])
          {
              cout <<"Yes"<<endl;
          }
          else
          {
              cout <<"No"<<endl;
          }
          pre++;
      }


}
/*10 1
56 12 68 23 41 29 97 69 79 76
1 3 5
*/


Measured memory_bytes: 4424
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int x;
    cin >> x;

    int ans = 0;

    while (x >= 500) {
        x -= 500;
        ans += 1000;
    }
    while (x >= 5) {
        x -= 5;
        ans += 5;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n, a;
vector<int> x;
ll dp[51][51][3010];

void input(){
    cin >> n >> a;
    x.resize(n);
    for(int i=0;i<n;i++) cin >> x[i];
}

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

    dp[0][0][0] = 1;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<2500;k++){
                if(dp[i][j][k]){
                    dp[i+1][j][k] += dp[i][j][k];
                    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                }
            }
        }
    }

    ll ans = 0;
    for(int i=1;i<=n;i++) ans += dp[n][i][i*a];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 58240
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int need=0;
  vector<vector<int>>dp(n+5,vector<int>(5005));//dp[i][j]:=先頭からiまで見てjが作れるか
  vector<vector<int>>rdp(n+5,vector<int>(5005));//rdp[i][j]*:=末尾からiまで見てjが作れるか
  dp[0][1]=1;rdp[0][0]=1;
  rep(i,n){
    rep(j,5001){
      if(j-a[i]>=0)dp[i+1][j]=dp[i+1][j]|dp[i][j-a[i]];
      dp[i+1][j]=dp[i+1][j]|dp[i][j];
    }
  }
  rep(i,n){
    rep(j,5001){
      if(j-a[n-1-i]>=0)rdp[i+1][j]=rdp[i+1][j]|rdp[i][j-a[n-1-i]];
      rdp[i+1][j]=rdp[i+1][j]|rdp[i][j];
    }
  }
  //iにおいて0からjまででいくつ作ることができるかにdp[i][j]を変更(メモリが足りないので再利用)
  rep(i,n+1){
    rep(j,5000){
      dp[i][j+1]+=dp[i][j];
    }
  }
  rep(i,n){
    bool flag=false;
    rep(j,5001){
      if(rdp[n-1-i][j]){
        if(dp[i][max(0,k-j)]-dp[i][max(0,k-j-a[i])]>0)flag=true;
      }
    }
    if(flag)++need;
  }
  cout<<n-need;
}

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


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

int main(){
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i=0; i<n; ++i)
		cin >> arr[i];

	vector<int> s(n);
	s[0] = arr[0];
	for(int i=1; i<n; ++i)
		s[i] = min(arr[i], s[i-1]);

	int count = 0;
	for(int i=0; i<n;++i)
		if(arr[i] <= s[i])
			++count;
		
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int a[300000];

void solution() {
    int n, k;
    cin >> n >> k;
    int sum = 0;
    int best = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
        if (i >= k) {
            sum -= a[i - k];
        }
        best = max(best, sum);
    }
    printf("%.10f\n", (k + best) / 2.0);
}

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

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

    /*
    　　     　 　                            ∧_,,∧　　　
                        　              ♪　  (・ω・)　♪
                                     ＿＿＿＿○＿＿つヾ＿＿＿＿＿
                                     /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
                                     |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
                                     |　　　*/solution();/* 　　| |
                                     |　　　　　　　　　　　　　 |
                                     */

#ifdef Time
double P2HxQ = clock();
printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
const ll inf = 1e18+1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
//小文字=大文字+32
int main() {
	int n, h; 	cin >> h >> n;
	vector<ll>a(n), b(n); rep(i, n)cin >> a[i] >> b[i];
	vector<ll>dp(1e4*2+1,inf);//添え字は与えるダメージ
	dp[0] = 0;
	rep(i, n) {
		rep(j, 1e4 *2+1) {
			if (a[i] <= j) {
				chmin(dp[j], dp[j - a[i]]+b[i]);
			}
		}
	}
	ll ans=inf;
	for (int i = h; i < 1e4 * 2 + 1;i++) {
		chmin(ans,dp[i]);
	}
	cout << ans;
}


Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
  int n,r[100],c[100][100];
  int i,j,k,l,m;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r[i],&j);
  }
  r[n]=j;
  for(i=1;i<=n;i++){
    c[i][i]=0;
  }
     
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j =i+l-1;
      c[i][j]=1000000;
      for(k=i;k<=j-1;k++){
    m=c[i][k]+c[k+1][j]+(r[i-1]*r[k]*r[j]);
       
    if(c[i][j]>m){
      c[i][j]=m;
    }
      }
    }
  }
  printf("%d\n",c[1][n]);
   
  return 0;
}

Measured memory_bytes: 2768
#include<cstdio>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 40
#define LL long long
typedef pair<string,string> PSS;
map<PSS,int>con;
string s1,s2,tmp;
int n;
LL ans;
char s[MAXN];
void GetString(int a,int flag)
{
	int c=0;
	if(flag==1)
	{
		s1.clear(),s2.clear();
		for(int i=0;i<n;i++)
			if((a>>i)&1)
				s1.push_back(s[n-i-1]),c++;
			else s2.push_back(s[n-i-1]);
		for(int i=0;i<c/2;i++)
			swap(s1[i],s1[c-i-1]);
	}
	else
	{
		s1.clear(),s2.clear();
		for(int i=0;i<n;i++)
			if((a>>i)&1)
				s1.push_back(s[n+i]),c++;
			else s2.push_back(s[n+i]);
		for(int i=0;i<c/2;i++)
			swap(s1[i],s1[c-i-1]);
	}
}
void DFS(int a,int cnt,int flag)
{
	if(cnt==n)
	{
		GetString(a,flag);
		if(flag==1)
			con[PSS(s1,s2)]++;
		else ans+=con[PSS(s1,s2)];
		return;
	}
	DFS((a<<1)^1,cnt+flag,flag);
	DFS((a<<1),cnt+flag,flag);
}
int main()
{
	scanf("%d%s",&n,s);
	DFS(1,0,1);
	DFS(1,n*2,-1);
	printf("%lld\n",ans);
}

Measured memory_bytes: 87040
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n;cin>>n;
  cout<<n/2 + n%2<<endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll m,d;cin>>m>>d;
  ll count=0;
  for(ll i=1;i<=d;i++){
    ll k=i%10;
    ll j=i/10;
    if(k>=2&&j>=2&&k*j<=m)count++;
  }
  cout<<count<<endl;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  sort(h.begin(),h.end());
  int ans = h.at(n-1)-h.at(0);
  for(int i=0;i<n-k+1;i++){
    ans = min( ans,h.at(i+k-1)-h.at(i) );
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto &e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vector<vector<int>> bflag(n, vector<int>(20, 0));
  vector<vector<int>> bsum(n + 1, vector<int>(20, 0));
  REP(i, n) {
    ll x;
    cin >> x;
    REP(bit, 20) {
      if ((x >> bit) & 1LL) {
        bflag[i][bit] = 1;
      }
    }
  }
  REP(i, n) {
    // bsum[i][b] = sum_{j=[0,i)}bflag[j][b]
    REP(bit, 20) { bsum[i + 1][bit] = bsum[i][bit] + bflag[i][bit]; }
  }

  ll ans = 0;
  int l, r;
  l = 0;
  r = 0;
  while (l < n && r < n + 1) {
    while (l < n && r < n) {
      // check [l, r + 1) is ok
      bool ok = true;
      REP(bit, 20) {
        if (bsum[r + 1][bit] - bsum[l][bit] > 1) {
          ok = false;
          break;
        }
      }
      if (ok) {
        r++;
      } else {
        break;
      }
    }
    ans += r - l;
    l++;
    r = max(l, r);
  }
  cout << ans << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
int n,l,r;
int a[2];
char s[10];
int res()
{
    if(s[0]=='V')
        return 0;
    if(s[0]=='M')
        return 1;
    return 2;
}
int c()
{
    int x=res();
    if(x-1)
        return 1;
    return 2;
}
int query(int num)
{
    cout<<num<<endl<<flush;
    cin>>s;
    return res();
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    query(0);
    if(!res())
        return 0;
    a[0]=c();
    query(n-1);
    if(!res())
        return 0;
    a[1]=c();
    l=1,r=n-2;
    while(l<=r){
        int m=(l+r)/2;
        query(m);
        if(!res())
            return 0;
        if((m%2==l%2&&res()!=a[0])||(m%2!=l%2&&res()==a[0])){
            r=m-1;
            a[1]=c();
        }
        else{
            l=m+1;
            a[0]=c();
        }
    }
    return 0;
}

Measured memory_bytes: 852
n, m = list(map(int, input().split(' ')))
d = {}
ans_c = 0
ans_w = 0
for i in range(m):
    p, r = input().split(' ')
    if r == 'AC':
        if d.get(p) != 'finished':
            ans_c += 1
            ans_w += d.get(p, 0)
        d[p] = 'finished'
    elif d.get(p) != 'finished':
        d[p] = d.get(p, 0) + 1
print(ans_c, ans_w)
    

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

struct Node{
    int parent,left_child,right_brother;
};

int nil = -1;
Node node[100005];
int depth[100005];

void print_tree(int id){
    cout << "node " << id;
    cout <<": parent = " << node[id].parent;
    cout << ", depth = " << depth[id];
    cout << ", ";
    if(node[id].parent == nil)cout << "root";
    else if(node[id].left_child == nil)cout << "leaf";
    else cout << "internal node";
    cout << ", [";
    int child = node[id].left_child;
    while(child != nil){
        cout << child;
        child = node[child].right_brother;
        if(child != nil){
            cout << ", ";
        }
    }
    cout << "]" << endl;
}

void depth_check(int id,int p){
    depth[id] = p;
    if(node[id].right_brother!=nil) depth_check(node[id].right_brother,p);
    if(node[id].left_child!=nil) depth_check(node[id].left_child,p+1);
    return;
}

int main(){
    int N,M;
    int id,c;
    cin >> N;
    /*木の初期化*/
    for(int i=0;i<N;i++){
        node[i].parent = node[i].left_child = node[i].right_brother = nil;
    }

    int right,root;
    for(int i=0;i<N;i++){
        cin >> id >> M;
        for(int j=0;j<M;j++){
            cin >> c;
            if(j == 0)node[id].left_child = c;
            else node[right].right_brother = c;
            right = c;
            node[c].parent = id;
        }
    }

    for(int j=0;j<N;j++){
        if(node[j].parent == nil)root = j;
    }

    depth_check(root,0);

    for(int i=0;i<N;i++){
        print_tree(i);
    }

    return 0;
}


Measured memory_bytes: 7684
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int main() {
    int n;
    cin >> n;
    
    if(n > 999) 
        cout << "ABD" << endl;
    else
        cout << "ABC" << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256