akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=1e3+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=1e9;
const double ep=1e-7;
using namespace std;
inline bool isPrime(ll num){
	if(num==1)return 0;
	if(num==2||num==3) return 1;
	if(num%6!=1&&num%6!=5)
	return 0;
 	ll tmp=sqrt(num);
	for(ll i=5;i<=tmp;i+=6)
	if(num%i==0||num%(i+2)==0)
  	return 0;
  	return 1;
}
int main()
{
	ll x;
	scanf("%lld",&x);
	while(1)
	{
		if(isPrime(x))
		{
			printf("%lld\n",x);return 0;
		}
		x++;
	}
}

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

typedef long long int ll; 

int main(void)
{
	ll n;
	cin >> n;
	ll r = n%10;
	if(r==2 || r==4 || r==5 || r==7 || r==9)
		cout << "hon\n";
	else if(r==0 || r==1 || r==6 || r==8)
		cout << "pon\n";
	else
		cout << "bon\n";



	return 0;
}

Measured memory_bytes: 3632
from itertools import accumulate
import sys

N = int(input())
A = list(map(int, input().split()))

revA = reversed(A)
ans = 0

l = list(accumulate(revA))
l.reverse()

for i in range(N+1):
    l[i] = min(l[i], 2**i)

for i in range(N+1):
    if i == N:
        if l[i] < A[i]:
            print(-1)
            sys.exit()
    else:
        l[i+1] = min(l[i+1], (l[i]-A[i])*2)

for v in l:
    if v > 0:
        ans += v
    else:
        ans = -1
        break


print(ans)

Measured memory_bytes: 668316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[50]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	cout<<t[n-1]<<endl;
}

Measured memory_bytes: 256
import sys

# sys.stdin = open('d1.in')

n, m = map(int, input().split())
edges = []
for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges.append((a, b, c))

score = [-10 ** 50] * n
score[0] = 0
for i in range(n):
    for a, b, c in edges:
        if score[b] < score[a] + c:
            score[b] = score[a] + c
res = score[n - 1]

for i in range(n):
    for a, b, c in edges:
        if score[b] < score[a] + c:
            score[b] = score[a] + c
if res < score[n - 1]:
    res = 'inf'
print(res)


Measured memory_bytes: 3316
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<ll> H(100010), R(100010);
    cin >> N;
    for (int i=0;i<N;i++) cin >> H[i];

    R[N-1] = H[N-1];
    for (int i=N-2;i>=0;i--) {
        R[i] = min(R[i+1],H[i]);
        if (H[i]-R[i]>1) {
            cout << "No" << endl;
            return 0;
        } else if (H[i]-R[i]==1) H[i]--;
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_Node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 998244353
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int  main()
{
    fastIO;
    ll n,k;
    cin>>n>>k;
    pair<ll,ll>p[k];
    for(int i=0;i<k;i++)
    {
        cin>>p[i].fi>>p[i].se;
    }
    ll x,y;
    vector<ll>dp(n);
    dp[0]=1;
    dp[1]=-1;
    for(int i=0;i<n;i++)
    {
        if(i-1>=0)
        {
            dp[i]=(dp[i]+dp[i-1])%mod;
        }
        for(int j=0;j<k;j++)
        {
            x=i+p[j].fi,y=i+p[j].se+1;
            if(x<n)
            {
                dp[x]=(dp[x]+dp[i])%mod;
            } 
            if(y<n)
            {
                dp[y]=(dp[y]-dp[i]+mod)%mod;
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4764
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

int main(void)
{
    int H, N;
    int A, B;
    int i, j;
    int answer = MOD;

    vector<int> dp(20000, MOD);
    dp[0] = 0;

    cin >> H >> N;

    for (i = 1; i <= N; i++)
    {
        cin >> A >> B;
        for (j = 1; j <= H; j++)
        {
            dp[j] = min(dp[j], dp[max(0, j - A)] + B);
        }
    }

    for (i = H; i <= H; i++)
    {
        if (answer > dp[i])
        {
            answer = dp[i];
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 384
// AOJ 2547: Carpet
// 2017.12.1 bal4u@uu

#include <stdio.h>

int stack[200002], *top = stack;
char buf[2200002], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, a, ans;

	fgets(p=buf, 10, stdin), n = getint();
	ans = 0;
	fgets(p=buf, sizeof(buf), stdin);
	*++top = getint(), p++;
	while (--n) {
		a = getint(), p++;
		if (a > *top) *++top = a;
		else if (a < *top) {
			while (*top > a) ans++, top--;
			if (*top != a) *++top = a;
		}
	}
	while (*top--) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3928
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			double en[][]=new double[n][3];
			for(int i=0;i<n;i++)
				for(int j=0;j<3;j++)
					en[i][j]=in.nextDouble();
			int m=in.nextInt();
			for(int i=0;i<m;i++)
			{
				double tx=in.nextDouble(),ty=in.nextDouble();//たろう
				double sx=in.nextDouble(),sy=in.nextDouble();//鬼
				boolean judge=false;
				
				for(int j=0;j<n;j++)
				{
					double r=en[j][2];
					double dit=Math.hypot(tx-en[j][0],ty-en[j][1]);
					double dis=Math.hypot(sx-en[j][0],sy-en[j][1]);
					double d=line_distance(en[j][0],en[j][1],tx,ty,sx,sy);
					if((dit>r||dis>r) && d<=r)
						judge=true;
				}
				System.out.println(judge ? "Safe":"Danger");
			}
		}
	}
	
	static double line_distance(double px,double py,double x1,double y1,double x2,double y2)
	{
		double dx=x2-x1;
		double dy=y2-y1;
		double a=dx*dx+dy*dy;
		double b=dx*(x1-px)+dy*(y1-py);
		double t=-b/a;
		if(t<0) t=0;
		if(t>1) t=1;
		double tx=x1+dx*t;
		double ty=y1+dy*t;
		return Math.hypot(px-tx, py-ty);
	}
}

Measured memory_bytes: 35204
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
using namespace std;

stack<char> st;

char str[514];
int slen;

int main() {
	int i;
	while( gets(str) ) {
		if ( str[0] == '.' && str[1] == '\0' )
			break;
		slen = strlen(str);
		for( i = 0; i < slen; i++ ) {
			if ( str[i] == '(' || str[i] == '[' )
				st.push(str[i]);
			if ( str[i] == ')' ) {
				if ( st.empty() || st.top() != '(' )
					break;
				st.pop();
			}
			if ( str[i] == ']' ) {
				if ( st.empty() || st.top() != '[' )
					break;
				st.pop();
			}
		}
		if ( i == slen && st.empty() )
			cout << "yes" << endl;
		else
			cout << "no" << endl;
		while(!st.empty())
			st.pop();
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

int solve(vector<int> a) {
    reverse(a.begin(), a.end());
    int cnt0 = 0;
    int ans = 0;
    for (auto t : a) {
        if (t == 0) cnt0++;
        else ans += cnt0;
    }
    return ans;
}

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

    string s;
    cin >> s;
    int n = (int)s.size();
    vector<vector<int>> sub;
    sub.push_back(vector<int>());
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A') {
            sub.back().push_back(1);
        } else if (i + 1 < n && s[i] == 'B' && s[i + 1] == 'C') {
            sub.back().push_back(0);
            i++;
        } else {
            if (!sub.back().empty()) sub.push_back(vector<int>());
        }
    }
    int ans = 0;
    for (auto t : sub) {
        ans += solve(t);
    }
    cout << ans << endl;
}   


Measured memory_bytes: 5256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextInt();
        String[] inputs=new String[n];
        for(int i=0;i<n;i++){
            inputs[i]=sc.next();
        }
        String tmp;
        for(int i=0;i<n;i++){
            for(int j=0;j<n-1;j++){
                if(inputs[j].compareTo(inputs[j+1])>0){
                    tmp=inputs[j];
                    inputs[j]=inputs[j+1];
                    inputs[j+1]=tmp;
                }
            }
        }
        for(String a:inputs){
            System.out.print(a);
        }
        System.out.println();
    }
    
 
}

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

using namespace std;

typedef long long ll;
#define mem(a) (memset(a,0,sizeof(a)))
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define MAX(a, b) ((a)>(b)?(a):(b))
#define MIN(a, b) ((a)<(b)?(a):(b))

const int maxn = static_cast<const int>(1e5 + 5);
const int mod = static_cast<const int>(1e9);

char a[maxn];

int main() {
    scanf("%s", a);
    int ans = 0;
    int len = strlen(a);
    for (int i = 1; i < len / 2 + 1; i++)
        if (a[i - 1] != a[i + 1])ans++;
    if (ans == 0) {
        printf("Second\n");
        return 0;
    }
    if (a[0] != a[len - 1])printf("%s\n", len % 2 ? "First" : "Second");
    else printf("%s\n", len % 2 ? "Second" : "First");

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define endl \n

using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    int round = 360;
    while(round%X != 0)
        round+=360;
    cout << round/X;
    return 0;
}

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

using namespace std;

const int WHITE = 0, GREY = 1, BLACK = 2;

struct DFS {
    int n;
    vector<vector<int>> g;
    vector<int> color;
    vector<int> dt;
    vector<int> ft;
    int ct = 1;
 
    DFS(int n) : n(n) {
        g.assign(n, vector<int>());
        color.assign(n, WHITE);
        dt.assign(n, -1);
        ft.assign(n, -1);
    }
    
    void solve() {
        for (int i = 0; i < n; i++) {
            if (color[i] == WHITE) {
                dfs(i);
            }
        }
    }
    
    void dfs(int u) {
        //cout << "visit " << u << endl;
        color[u] = GREY;
        dt[u] = ct++; 
        for (int v : g[u]) {
            if (color[v] == WHITE) {
                dfs(v);
            }
        }
        ft[u] = ct++;
        color[u] = BLACK;
    }
    
    void addEdge(int u, int v) {
        g[u].push_back(v);
    }
    
    void printGraph() {
        for (int i = 0; i < n; i++) {
            cout << i << ": ";
            for (int v : g[i]) {
                cout << v << " ";
            }
            cout << endl;
        }
    }
        
};


int main() {   
    int n;
    cin >> n;
    DFS dfs(n);
   
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            v--;
            dfs.addEdge(u, v);
        }  
    }
    
    //dfs.printGraph();
    
    dfs.solve();
    
    for (int i = 0; i < n; i++) {
        cout << (i + 1) << " " << dfs.dt[i] << " " << dfs.ft[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3172
#include <fstream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <bitset>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <set>
#include <complex>

using namespace std;

const int SIZE = 1 << 10;

int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0;
    char ch = Advance();
    while (!isdigit(ch))
        ch = Advance();
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer;
}

const int MAXN = 100000;

vector<int> g[1 + MAXN];
int p[1 + MAXN];
bool seen[1 + MAXN];
vector<int> x, y;

void DFS(int node) {
    seen[node] = true;
    x.push_back(node);
    y.push_back(p[node]);
    for (auto &it : g[node])
        if (!seen[it])
            DFS(it);
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%d", &p[i]);
    for (int i = 1; i <= m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int answer = 0;
    for (int i = 1; i <= n; i++)
        if (!seen[i]) {
            x.clear();
            y.clear();
            DFS(i);
            sort(x.begin(), x.end());
            sort(y.begin(), y.end());
            for (int j = 0, k = 0; j < x.size(); j++) {
                while (k < y.size() && y[k] < x[j])
                    k++;
                if (k == y.size())
                    break;
                if (y[k] == x[j])
                    answer++;
            }
        }
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 10156
s = int(input())
x1 = 0
y1 = 0
x2 = 10 ** 9
y2 = 1
x3 = - s % (10 ** 9)
y3 = (s-1) // (10 ** 9) + 1
print(x1, y1, x2, y2, x3, y3)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define REP(i,a,n) for(ll i=a;i<(n);i++)
#define RE return
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    set<string>items;
    string it;
    ll n;
    cin>>n;
    REP(i,0,n){
    	cin>>it;
    	items.insert(it);
	}
	cout<<items.size();
    RE 0;
}


Measured memory_bytes: 19276
n=int(input())
a=sorted(list(map(int,input().split())))
ans=1
cnt=[0]*(10**5+2)#a[i]+2
for i in range(n):
    cnt[a[i]]+=1
for i in range(n):
    tmp=cnt[a[i]]+cnt[a[i]+1]+cnt[a[i]+2]
    ans=max(tmp,ans)
print(ans)

Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
int n, m, q;
int a[51], b[51], c[51], d[51];
int v[11];
 
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> l(M);
    vector<int> r(M);
    rep(i, 0, M){
        cin >> l[i] >> r[i];
    }
    int Max = 1;
    int Min = N;
    rep(i, 0, M){
        Max = max(Max, l[i]);
        Min = min(Min, r[i]);
    }
    
    int ans = max((Min-Max)+1, 0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  double r;
  double pi = 3.14159265358979323846264338327950288;
  cin>>r;

  cout<<2*r*pi<<endl;

  return 0;
}

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

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

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

const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    string S,T;
    cin >> S >> T;

    //vector<int> d(26,-1);
    map<int,int> d_s,d_t;

    string ans = "Yes";
    rep(i,S.size()) {
        int idx_s,idx_t;
        idx_s = S[i] - 'a';
        idx_t = T[i] - 'a';
        
        if (!d_s.count(idx_s)) {
            d_s[idx_s] = idx_t;
        }
        if (!d_t.count(idx_t)) {
            d_t[idx_t] = idx_s;
        }

        if (d_s[idx_s]==idx_t && d_t[idx_t]==idx_s) {
            continue;
        }
        else {
            ans = "No";

            break;
        }
    }
    cout << ans << endl;
}


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

int main(){
  int a, s;
  int npie = 0;
  scanf("%d %d", &a, &s);
  if(a+s > 0){
    if(s > 0){
      npie = -s;
    }
  }else{
    npie = -a-s+1;
  }
  //printf("%d ",npie);
  npie += (a * (a-1)) / 2;
  npie += a * s;
  printf("%d", npie);
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


public class Main {

    static int[] parent;

    static int find(int i) {
        // If i is the parent of itself
        if (parent[i] == i)
        {
            // Then i is the representative
            return i;
        }
        else
        {
            // Recursively find the representative.
            int result = find(parent[i]);

            // We cache the result by moving i’s node
            // directly under the representative of this
            // set
            parent[i] = result;

            // And then we return the result
            return result;
        }
    }


    static void union(int i, int j)
    {
        // Find the representatives
        // (or the root nodes) for the set
        // that includes i

        int irep = find(i);

        // And do the same for the set
        // that includes j
        int jrep = find(j);

        // Make the parent of i’s representative
        // be j’s  representative effectively
        // moving all of i’s set into j’s set)
        parent[irep] = jrep;
    }

    static void solve() {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int m = scan.nextInt();
        parent = new int[n];
        for(int i=0;i<n;i++) {
            parent[i] = i;
        }
        for(int i = 0; i < m; i++) {
            int f = scan.nextInt();
            int s = scan.nextInt();
            union(f-1, s-1);
        }
        int[] cnt = new int[n];
        int max = 0;
        for(int i=0;i < n;i++) {
            int p = find(i);
            cnt[p]++;
            max = Math.max(max, cnt[p]);
        }
        System.out.println(max);

//        int t = scan.nextInt();
//        for (int i = 0; i < t; i++) {
////            solveCase();
//        }


//        long t = scan.nextLong();

//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
////            scase(n);
//        }
    }


    static void solveCase(int zero1, int one1, int two1, int zero2, int one2, int two2) {

    }

    static void scase(int[] arr1, int[] arr2) {
    }


    public static void main(String[] args) {
//        Main m = new Main();
        solve();
    }


    static class LoggerNode {
        String message;
        int ts;
    }


    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int i;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    double ans = 0.0;
    for(i = 0; i < n; i++){
        ans += 1.0/a.at(i);
    }
    ans = 1.0/ans;
    cout << ans << endl;
    return 0;
}


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

int main()
{
  string s;
  int sum;

  for(;;) {
    cin >> s;
    if (s == "0") break;
    sum = 0;
    for(string::iterator ptr = s.begin(); ptr != s.end(); ptr++)
      sum += (char)*ptr-'0';
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
using namespace std;
#define ll long long
int main(){
	string S;
	cin >> S;
	size_t Ssize = S.size();
	string Sr;
	for(int i = 0; i < Ssize; i++){
		if(S[Ssize-i-1]=='b'){
			Sr +='d';
		}
		else if(S[Ssize-i-1] == 'd'){
			Sr += 'b';
		}
		else if(S[Ssize-i-1] == 'p'){
			Sr += 'q';
		}
		else{
			Sr += 'p';
		}
	}
	if(Sr.compare(S) == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include <stdio.h>
int main() {
  long long n,m,d;
  scanf("%lld%lld%lld",&n,&m,&d);
  if (d==0) {
    printf("%.10lf\n",(double)(m-1)/n);
  } else {
    printf("%.10lf\n",(double)(m-1)*2*(n-d)/(n*n));
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;

int main()
{
    IOS
    int a,b;
    cin >> a>>b;
    if(a>8 || b>8)
    {
        cout << ":(\n";
        return 0;
    }
    cout<<"Yay!\n";
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<P, P> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int main()
{
	int x, y;
	cin >> x >> y;
	if (x % y == 0) cout << -1 << endl;
	else cout << x << endl;
	return 0;
}

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

int main(void){
	char c11,c12,c13,c21,c22,c23;

	scanf("%c%c%c\n",&c11,&c12,&c13);
	scanf("%c%c%c",&c21,&c22,&c23);
	if(c11==c23){
		if(c12==c22){
			if(c13==c21){
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
/** 復習用 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		// 解くべき問題が間違っていた。
		// f(m) = 0となるようなmは、 mがすべてのaの倍数になるようなm
		// つまり m0 = a1 * a2 *...* aN と定めれば良い
		// このとき、m%aiの各項が最大になるようなmは、m0-1
		// なぜなら m mod ai のすべての項が ai-1になるから
		// よってf(m)の最大値は f(m0-1) = (a1 - 1) + (a2 - 1) +..+ (aN - 1)
		int fm_max = 0;
		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			fm_max += ai - 1;
		}
		System.out.println(fm_max);
	}
}


Measured memory_bytes: 26040
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1];
	if(A > 8 || B > 8) {
		writeln(":(");
	} else writeln("Yay!");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main(){
    int A1, A2, A3;
    int ans = 0;
    std::cin >> A1 >> A2 >> A3;
    ans = A1 + A2 + A3;

    if(ans > 21){
        std::cout << "bust";
    }else{
        std::cout << "win";
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 1 && a <= 9 && b >= 1 && b <= 9) {
        cout << a*b << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> ans;
    
        for(int i =  n - 1;i >= 0;i-=2) {
            ans.pb(a[i]);
        }
        for(int i = (n%2==0?0:1);i<= n-1;i+=2) {
            ans.pb(a[i]);
        }
    
    rep(i, n) cout << ans[i] <<  ' ';
    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
using namespace std;
int N;
string s;


int main()
{

    cin >> N;
    cin >> s;


    if (s.length() <= N)
        cout << s;
    else
    {
        for (int i = 0; i <= N-1; i ++)
        {
            cout << s[i];
        }
        cout << "...";
    }
    return 0;
}

Measured memory_bytes: 3632
blist = [int(2**i) for i in range(10)]
while(1):
    try:
        n = int(input())
        b_ = bin(n)
        b = list(b_)[-1:1:-1]
        for i in range(len(b)):
            if b[i] == "1":
                if i == len(b) - 1:
                    print(blist[i])
                else:
                    print(blist[i], end= " ")
    except EOFError:
        break
            
    



Measured memory_bytes: 5600
#include<stdio.h>

int main(void){
 	
  char line[4];
  
  scanf("%s",line);
  for(int i = 0;i < 3;i ++){
   	if(line[i] == '7'){
     	printf("Yes");
      	return 0;
    }
  }
  printf("No");
  
  return 0;
}


Measured memory_bytes: 1700
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)
function main()
    a,b = map(parseInt, split(readline()))
  if b%a == 0
    println(Int64(a+b))
  else
    println(Int64(b-a))
  end
end
main()

Measured memory_bytes: 112200
/**
 *    author:  FromDihPout
 *    created: 2020-08-09
**/

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

#define f first
#define s second

const long long INF = 6e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vector<pair<int,int>> a(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a[i] = {x, y};
    }
    
    long long area = INF;
    for (int p1 = 0; p1 < n; p1++) {
        for (int p2 = 0; p2 < n; p2++) {
            for (int p3 = 0; p3 < n; p3++) {
                for (int p4 = 0; p4 < n; p4++) {
                    long long x1 = min({a[p1].f, a[p2].f, a[p3].f, a[p4].f});
                    long long x2 = max({a[p1].f, a[p2].f, a[p3].f, a[p4].f});
                    long long y1 = min({a[p1].s, a[p2].s, a[p3].s, a[p4].s});
                    long long y2 = max({a[p1].s, a[p2].s, a[p3].s, a[p4].s});
                    
                    int cnt = 0;
                    for (int i = 0; i < n; i++) {
                        if (a[i].f >= x1 && a[i].f <= x2
                            && a[i].s >= y1 && a[i].s <= y2) {
                            cnt++;
                        }
                        if (cnt >= k) break;
                    }
                    if (cnt >= k) {
                        area = min(area, (x2 - x1) * (y2 - y1));
                    }
                }
            }
        }
    }
    
    cout << area << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long ll;
const ll mo = 1e9 + 7;

ll A, B, C, D;

struct info {
	ll x, y, z;
	bool operator<(const info &k) const {
		return x + y + z < k.x + k.y + k.z;
	}
};

ll calc() {
	std::vector<info> v;
	v.push_back({0, 0, 0});
	v.push_back({A - 1, B - 1, C - 1});
	for(ll x = 1; x <= std::min(D, A - 1); ++x)
		v.push_back({x, ll(x / (double)A * (double)B), ll(x / (double)A * (double)C)});
	for(ll x = std::max(A - D - 1, D + 1); x < A; ++x)
		v.push_back({x, ll(x / (double)A * (double)B), ll(x / (double)A * (double)C)});
	for(ll y = 1; y <= std::min(D, B - 1); ++y)
		v.push_back({ll(y / (double)B * (double)A), y, ll(y / (double)B * (double)C)});
	for(ll y = std::max(B - D - 1, D + 1); y < B; ++y)
		v.push_back({ll(y / (double)B * (double)A), y, ll(y / (double)B * (double)C)});
	for(ll z = 1; z <= std::min(D, C - 1); ++z)
		v.push_back({ll(z / (double)C * (double)A), ll(z / (double)C * (double)B), z});
	for(ll z = std::max(C - D - 1, D + 1); z < C; ++z)
		v.push_back({ll(z / (double)C * (double)A), ll(z / (double)C * (double)B), z});
	std::sort(v.begin(), v.end());

	ll ans = std::min(D + 1, C) % mo * std::min(D + 1, B) % mo * std::min(D + 1, A) % mo;
	ll dx, dy, dz;
	for(int i = 0; i + 1 < v.size(); ++i) {
		dx = (std::min(A, v[i].x + D + 1) - std::max(0ll, v[i].x - D)) % mo;
		dy = (std::min(B, v[i].y + D + 1) - std::max(0ll, v[i].y - D)) % mo;
		dz = (std::min(C, v[i].z + D + 1) - std::max(0ll, v[i].z - D)) % mo;
		if(v[i].x + D + 1 < A)
			ans = (ans + (v[i + 1].x - v[i].x) % mo * dy % mo * dz % mo) % mo;
		if(v[i].y + D + 1 < B)
			ans = (ans + (v[i + 1].y - v[i].y) % mo * dx % mo * dz % mo) % mo;
		if(v[i].z + D + 1 < C)
			ans = (ans + (v[i + 1].z - v[i].z) % mo * dx % mo * dy % mo) % mo;
	}
	return ans;
}

int main() {
	scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
	printf("%lld\n", calc());
	return 0;
}


Measured memory_bytes: 14700
#include <bits/stdc++.h>
int main() {
	using namespace std;
	char w;
	cin>>w;


	if (w== 'a'||w=='i'||w=='u'||w=='e'||w=='o') {

	cout<<"vowel"<<endl;

	}
	else{
	cout<<"consonant"<<endl;

	}
	


}



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

using namespace std;
const int N = 200100;

int n, len; 
char s[N];

int Ans[N], total, A, B, C;

int popcount(int x){
    int res = 0;
    while(x) {
        x -= x & -x;
        res++;
    }
    return res;
}

int Calc(int x) {
    if(Ans[x]) return Ans[x];
    if(!x) return 0;
    return Ans[x] = Calc(x % popcount(x)) + 1;
}

int Pow(int tmp) {
    int res = 0; if(tmp == 0) return 0;
    for(int i = 0;i < len; ++i) {
        if(s[i] == '0') res = res * 2 % tmp;
        if(s[i] == '1') res = (res * 2 + 1) % tmp;
    }
    return res;
}

long long PowMod(long long a,long long b,long long tmp) {
    long long res = 1 % tmp;
    while(b) {
        if(b & 1) res = res * a % tmp;
        b >>= 1;
        a = a * a % tmp;
    }
    return res;
}

int main() {
    cin >> n; scanf("%s", s); len = strlen(s);
    for(int i = 1;i < N; ++i)
        Ans[i] = Calc(i);
    // for(int i = 1;i <= 20; ++ i) 
    //     cout << "Ans[" << i << "] = " << Ans[i] << endl; 
    for(int i = 0;i < len; ++i)
        if(s[i] == '1')
            total++;
    A = Pow(total - 1); B = Pow(total); C = Pow(total + 1);
    for(int i = 0;i < len; ++i) {
        int tmp;
        if(s[i] == '0') {
            tmp = (C + PowMod(2, len - i - 1, total + 1)) % (total + 1);
            cout << Ans[tmp] + 1 << endl;
        } else {
            if(total == 1) cout << 0 << endl;
            else {
                tmp = (A - PowMod(2, len - i - 1, total - 1) + total - 1) % (total - 1);
                cout << Ans[tmp] + 1 << endl;
            }
        }
    }
    return 0;  
}

Measured memory_bytes: 4624
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);

using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
ll mod=1e9+7;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////
 vector <int> adj[200005];
    bool visited[200005];
const int N = 1e6+1;
ll greatestPF[N];
int cnt,nodes,edges;
  void dfs(int s) {
        visited[s] = true;
        cnt++;

        for(int i = 0;i < adj[s].size();++i)    {
         if(visited[adj[s][i]] == false)
         {
             dfs(adj[s][i]);
         }
        }
    }

int mem[100005][3],a[200005],b[105],n,m,k,frq[1000005];
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}
int sieve[N];
int main()
{
int T=1;
///T=D();
while(T-->0)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,d*b});

}

}


Measured memory_bytes: 8316
<?php
fscanf(STDIN, "%d %d %d", $n, $a, $b);

// 割る値
const div = 1000000007;

// 繰り返し二乗法
function modPow($a, $n, $p) {
	if($n == 1) {
		return($a % $p);
	}
	if($n % 2 == 1) {
		return(($a * modPow($a, $n - 1, $p)) % $p);
	}
	
	$t = modPow($a, $n / 2, $p);
	return(($t * $t) % $p);
}

// 選択
function choise($n, $a) {
	$x = 1;
	$y = 1;
	
	// 分母
	for($i = 0; $i < $a; $i++) {
		$x *= ($n - $i);
		$y *= ($i + 1);
		
		$x %= div;
		$y %= div;
	}
	
	return($x * modPow($y, div - 2, div) % div);
}

// 全体
$all = modPow(2, $n, div) - 1;

// マイナスなるのを防ぐ
$all += (div * 2);

// a本は除外
$all -= choise($n, $a);
// b本は除外
$all -= choise($n, $b);

$ans = $all % div;

echo "{$ans}\n";


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

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int>B(M); 
	for (int n = 0;n<M;++n) {
		cin >> B[n];
	}
	int ans = 0;	
	for (int n = 0;n<N;++n) {
		int memo = 0;
		for (int m = 0; m < M; ++m) {
			int num;
			cin >> num;
			memo += num * B[m];
		}
		if (memo+C>0) {
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3636
import sys
import random
from copy import copy
from math import floor, e

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def write_output(out):
    with open("my_sample3.out", mode="w") as f:
        for x in out:
            f.write(str(x + 1) + "\n")


def main():
    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]

    sat_cur = 0
    last = [1] * 26
    out = [-1] * d

    for day in range(d):
        estimate = [0.0] * 26
        for cid in range(26):
            if s[day][cid] > 16000:
                estimate[cid] = last[cid] * c[cid] + c[cid] ** 1
        cur = estimate.index(max(estimate))
        out[day] = cur
        sat_cur += s[day][cur]
        last[cur] = 1
        for cid in range(26):
            if cid != cur:
                sat_cur -= last[cid] * c[cid]
                last[cid] += 1

    # print("begin", sat_cur)
    out_best = copy(out)
    sat_best = sat_cur
    num_of_try = 10000
    for i in range(1, num_of_try + 1):
        change_num = 1
        out_temp = copy(out_best)
        for j in range(change_num):
            # c_day = int(random.triangular(0, 365 - 0.01, 50))
            swap = random.sample(range(d), k=2)
            out_temp[swap[0]], out_temp[swap[1]] = out_temp[swap[1]], out_temp[swap[0]]

        last = [1] * 26
        sat_temp = 0
        for day in range(d):
            cur = out_temp[day]
            sat_temp += s[day][cur]
            last[cur] = 1
            for cid in range(26):
                if cid != cur:
                    sat_temp -= last[cid] * c[cid]
                    last[cid] += 1
        if sat_temp > sat_best:
            # print(i, ":", sat_temp)
            out_best = out_temp
            sat_best = sat_temp

    for x in out_best:
        print(x + 1)

    #write_output(out_best)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82268
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int n,m,_,x,y,q,key;
string s,sb;
bool ok;

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

  cin>>n; map<int,int> o,e; e[0]=0; o[0]=0;
  rep(i,n){
    cin>>x;
    if(i%2)e[x]++;
    else o[x]++;
  }
  P e1(0,0),e2(0,0),o1(0,0),o2(0,0);
  for(auto i:e){
    if(e1.second<i.second)e1=i;
  }
  for(auto i:e){
    if(e1.first!=i.first&&e2.second<i.second)e2=i;
  }
  for(auto i:o){
    if(o1.second<i.second)o1=i;
  }
  for(auto i:o){
    if(o1.first!=i.first&&o2.second<i.second)o2=i;
  }
  //prip(o1); prip(o2); prip(e1); prip(e2);
  if(e1.first==o1.first)pri1(min(n-(e1.second+o2.second),n-(e2.second+o1.second)));
  else pri1(n-e1.second-o1.second);
}

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

int main() 
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,q;cin>>n>>q;
	string s;cin>>s;
	int t[n];t[0]=0;
	for (int i = 1; i < n; i++)
	{
		if(s[i-1]=='A' && s[i]=='C')t[i]=t[i-1]+1;
		else t[i]=t[i-1];
	}
	while(q--)
	{
		int l,r;cin>>l>>r;
		cout<< t[r-1]-t[l-1]<<"\n";
	}
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
typedef long double ld;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-10;
const ll inf = 1e18;
const int maxn = 200005;
inline ll read() { ll s = 0, w = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') w = -1; for (; isdigit(ch); ch = getchar())    s = (s << 1) + (s << 3) + (ch ^ 48); return s * w; }
inline void write(ll x) { if (!x) { putchar('0'); return; } char F[40]; ll tmp = x > 0 ? x : -x; if (x < 0)putchar('-');    int cnt = 0;    while (tmp > 0) { F[cnt++] = tmp % 10 + '0';        tmp /= 10; }    while (cnt > 0)putchar(F[--cnt]); }
inline ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll qpow(ll a, ll b) { ll ans = 1;    while (b) { if (b & 1)    ans *= a;        b >>= 1;        a *= a; }    return ans; }    ll qpow(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1)(ans *= a) %= mod; b >>= 1; (a *= a) %= mod; }return ans % mod; }
inline int lowbit(int x) { return x & (-x); }

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
	{
		cout << "Yes";
	}
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3604
# coding: utf-8

(N, M) = map(int, input().split(" "))

ids = list(range(1, N+1))

L_max = 0
R_min = 10000000000000000000
for _ in range(M):
    (L, R) = map(int, input().split(" "))
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R

ids = [i for i in ids if L_max <= i <= R_min]
print(len(ids))


Measured memory_bytes: 76760
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//最大公約数
long long gcd(long long a, long long b) {
	if (a < b) std::swap(a, b);
	long long r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

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

	ll n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;

	ll ans = 0;
	vector<bool> won(n, false);
	for (ll i = 0; i < k; i++) {
		if (t[i] == 'r') ans += p;
		else if (t[i] == 's') ans += r;
		else ans += s;
		won[i] = true;
	}
	for (ll i = k; i < n; i++) {
		if (t[i] == t[i - k] && won[i - k]) continue;
		if (t[i] == 'r') ans += p;
		else if (t[i] == 's') ans += r;
		else ans += s;
		won[i] = true;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

int n;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		int ans=0;
		while(n!=1){
			if(n%2) n=n*3+1;
			else n/=2;
			ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Abc169E
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            var left = new List<int>();
            var right = new List<int>();

            for (int i = 0; i < n; i++)
            {
                var ab = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
                left.Add(ab[0]);
                right.Add(ab[1]);
            }

            left.Sort();
            right.Sort();

            if (n % 2 == 1)
                Console.WriteLine(right[n / 2] - left[n / 2] + 1);
            else
                Console.WriteLine((right[n / 2 - 1] + right[n / 2]) - (left[n / 2 - 1] + left[n / 2]) + 1);
        }
    }
}


Measured memory_bytes: 44732
-- AtCoder My Practice
-- author: Leonardone @ NEETSDKASU
 
-- 解説読後
-- http://agc004.contest.atcoder.jp/data/agc/004/editorial.pdf

import qualified Data.ByteString.Char8 as C
import Data.Maybe

-- fromJustとかいうの初めて知った
 
main = print . solve . map (fst . fromJust . C.readInt) . C.words =<< C.getContents

solve (n:x:a) = ans where
    sm = sum a
    ans = f n sm a x
    f 1 r _  _  = r
    f c r ar xx = f (c - 1) r2 ar2 (xx + x) where
        ar2 = zipWith min a $ [last ar] ++ ar
        r2 = min r (xx + sum ar2)


Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int main() {
    int n;
    cin >> n;
    LL a, b;
    a = 2; b = 1;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    for (int i = 2; i <= n; i++) {
        LL tmp = b;
        b = a + b;
        a = tmp;
    }
    cout << b << endl;

    return 0;
}


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

class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        
        String str = sc.nextLine();
        
        String data[] = str.split(" ");
        
        int a = Integer.parseInt(data[0]);
        int b = Integer.parseInt(data[1]);
        
        System.out.println(a*b + " " + 2*(a+b));
        
        
    }
    
    
}


Measured memory_bytes: 26224