akhauriyash/Code-Regression huggingface dataset:
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

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

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nok(a, b):
    m = a * b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m // (a + b)    


def main():
    a, x = rinput()
    if x > a:
        print(0)
    else:
        print(10)
    
    
    
main()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
const int INF = 1e9;

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

	ll N, A, B;
	ll ans = 0;

	cin >> N >> A >> B;

	if (N * A < B) {
		ans = N * A;
	}
	else {
		ans = B;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void) {
	int a, b;
	cin >> a >> b;
	if (a + b == 15)cout << "+" << endl;
	else if (a * b == 15)cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,c=0;
  int a[20];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(int i=1;i<n-1;i++){
    if((a[i-1]<=a[i]&&a[i]<=a[i+1])||(a[i-1]>=a[i]&&a[i]>=a[i+1])){
      c++;
    }
  }
  printf("%d",c);
  return 0;
}

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

int main() {

 int s,s1,s2,s3;
 cin >> s ;
 s1 = s/100;
 s2 = (s%100)/10;
 s3 = (s%10);
 cout << s1+s2+s3 <<endl;
 
 
    
    
}


Measured memory_bytes: 256
// ABC127 F - Absolute Minima.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()

class MiddlePoint {
public:
	MiddlePoint() : N(0), sumQ2(0), sumQ1(0) {}
	void push(lolo a) {
		if (min(Q2.size(), Q1.size()) == 0) {
			if (Q2.empty()) {
				Q2.push(a);
				sumQ2 += a;
			}
			else {
				if (Q2.top() > a) { // Q1に入れる。
					auto pv = Q2.top(); Q2.pop();
					Q2.push(a);
					Q1.push(pv);
					sumQ2 += a - pv;
					sumQ1 += pv;
					
				}
				else {
					Q1.push(a);
					sumQ1 += a;
				}
			}
			N += 1;
			return ;
		} /////////////////

		if (Q2.size() == Q1.size()) {
			// 下側のキューに値を入れたい
			// Q1.top()よりもaが大きいと、まずい
			if (Q1.top() < a) {
				auto pv = Q1.top();	Q1.pop();
				Q1.push(a);
				Q2.push(pv);
				sumQ1 += a - pv;
				sumQ2 += pv;
			}
			else {
				Q2.push(a);
				sumQ2 += a;
			}
		}
		else {
			// 上側のQ1に値を入れたい
			// Q2.topよりも値が小さいと、まずい
			if (Q2.top() > a) {
				auto pv = Q2.top(); Q2.pop();
				Q2.push(a);
				Q1.push(pv);
				sumQ2 += a - pv;
				sumQ1 += pv;
			}
			else {
				Q1.push(a);
				sumQ1 += a;
			}
		}
		N += 1;
	}
	lolo getMiddle() const { return Q2.top(); }
	lolo getSumQ1() const { return sumQ1;  }
	lolo getSumQ2() const { return sumQ2;  }
	lolo getSize() const { return N; }
	lolo getQ1Size() const { return Q1.size(); }
	lolo getQ2Size() const { return Q2.size(); }
	priority_queue<lolo, vector<lolo>, greater<lolo>> Q1; // 小さい方から抜けてく。上側のキュー
	priority_queue<lolo> Q2;														  // 大きい方から抜けてく。 下側のキュー
	lolo N;
	//lolo data;
	lolo sumQ2;
	lolo sumQ1;
};


int main()
{
	lolo Q;
	cin >> Q;

	MiddlePoint	gm;

	lolo sumB = 0;
	FOR(i, Q) {
		lolo c, A, B; // |X-A| + B
		cin >> c;
		if (c == 1) {
			cin >> A >> B;
			gm.push(A);
			sumB += B;
		}
		else {
			// 下側midlepointの座標を 全体サイズは gm.getSize()
			//auto Sum = gm.GetMiddle() * ( Q2の個数 - Q1の個数) + sumB - Q2の合計 + Q1の合計
			lolo idx = -1;
			auto size = gm.getSize();
			if (size % 2 == 0) {
				idx = size / 2 - 1;
			}
			else {
				idx = size / 2;
			}
			
			lolo Sum = gm.getMiddle() * (gm.getQ2Size() - gm.getQ1Size()) + sumB - gm.getSumQ2() + gm.getSumQ1();
			cout << gm.getMiddle() << " " << Sum << endl;
		}
	}
}


Measured memory_bytes: 3828
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
int ptr = 1;

vector<int> prefix_function(string & input)
{
	int n = input.size();
	vector<int> pi(n, 0);
	for(int i = 1; i < n; i++)
	{
		int j = pi[i - 1];
		while(j > 0 and input[i] != input[j])
		{
			j = pi[j - 1];
		}
		if(input[i] == input[j])
		{
			i++;
		}
		pi[i] = j;
	}
	return pi;
}

void solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b and c != a)
	{
		cout << "Yes" << endl;
	}
	else if(a == c and a != b)
	{
		cout << "Yes"  << endl;
	}
	else if(b == c and a != b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

int32_t main() 
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    	solve();
    return 0;
}

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

int main(){
  int n,x;
  int L,M,S;
  int cnt;

 
  while(1){
  cnt = 0;
  cin >> n >> x;
  if(n==0 && x==0){
    break;  
    }
  
  for(int L=3; L<=n; L++){
    for(int M=2; M<n; M++){
      for(int S=1; S<n-1; S++){
        if(L<=M || M<=S || S>=L){
          continue;
        }else if(L+M+S==x){
          cnt += 1;
        }else{continue;}
      }   
    }
  }
   
   cout << cnt << endl;


  
  }
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int s = 0;
  rep(i,n) s ^= a[i];
  rep(i,n) cout << (s^a[i]) << " "; cout << endl;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N = 1e5 + 10;  
typedef pair<int, int> pii; 
#define V second
#define W first
int num[N*3];
ll L[N], R[N];
int main()  
{  
  //  freopen("in.txt", "r", stdin);
   	int x, y;
   	while (~scanf("%d%d", &x, &y))
   	{
   		int num[] = {4, 6, 9, 11};
   		int s1 = 0, s2 = 0;
   		for (int i = 0; i < 4; i++)
   		{
	   		if (num[i] == x)
   			{
   				s1 |= 1<<i;
   			}
   			if (num[i] == y)
   			{
   				s2 |= 1<<i;
   			}
   		}
   		if (s1 && s2)
   		{
   			puts("Yes");
   		}else if (s1 || s2)
   		{
   			puts("No");
   		}else if (x != 2 && y != 2)
   			puts("Yes");
   		else 
   			puts("No");
   		
   	}

   return 0;  
}  

Measured memory_bytes: 256
import sys
import bisect
import math
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from operator import itemgetter

def calc(n,p,q,r,s,t,u):
    dp=[-1]*(n+1)
    for i in range(n+1):
        dp[i]=i
    dp[0]=0
    for i in range(1,n+1):
        if i>=p and dp[i-p]>=0:
            if dp[i]<dp[i-p]+s:
                dp[i]=dp[i-p]+s
        if i>=q and dp[i-q]>=0:
            if dp[i]<dp[i-q]+t:
                dp[i]=dp[i-q]+t
        if i>=r and dp[i-r]>=0:
            if dp[i]<dp[i-r]+u:
                dp[i]=dp[i-r]+u
    
    return max(dp)

n=int(input())
p,q,r=map(int,readline().split())
s,t,u=map(int,readline().split())

res=calc(n,p,q,r,s,t,u)
ans=calc(res,s,t,u,p,q,r)
print(ans)

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

using namespace std;

int A, B, N, M, S, T, d[15][15];
int adj[102][102];
int dist[204];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("output.txt","w",stdout);
	cin >> A >> B;
	for (int i = 1; i <= A; ++i){
		for (int j = 1; j <= B; ++j){
			cin >> d[i][j];
		}
	}
	S = 1;
	T = 202;
	for (int i = 0; i <= 100; ++i){
		for (int j = 0; j <= 100; ++j){
			int maxi = 0;
			for (int k = 1; k <= A; ++k){
				for (int l = 1; l <= B; ++l){
					maxi = max(maxi,d[k][l]-k*i-j*l);
				}
			}
			adj[i][j] = maxi;
			if (maxi > 100){
				cout << "Impossible\n";
				return 0;
			}
		}
	}
	for (int k = 1; k <= A; ++k){
		for (int l = 1; l <= B; ++l){
			dist[1] = 0;
			for (int i = 1; i <= 100; ++i){
				dist[i+1] = dist[i] + k;
			}
			for (int i = 0; i <= 100; ++i){
				int mini = 1e9;
				for (int j = 0; j <= 100; ++j){
					mini = min(mini,adj[j][100-i]+dist[j+1]);
				}
				if (i > 0){
					mini = min(mini,dist[102+i-1]+l);
				}
				dist[102+i] = mini;
			}
			//cout << dist[202] << ' ';
			if (dist[202] != d[k][l]){
				cout << "Impossible\n";
				return 0;
			}
		}
		//cout << '\n';
	}
	N = 202;
	M = 100+100+(101*101);
	cout << "Possible\n";
	cout << N << ' ' << M << '\n';
	for (int i = 1; i <= 100; ++i){
		cout << i << ' ' << i+1 << ' ' << 'X' << '\n';
	}
	for (int i = 102; i <= 201; ++i){
		cout << i << ' ' << i+1 << ' ' << 'Y' << '\n';
	}
	for (int i = 0; i <= 100; ++i){
		for (int j = 0; j <= 100; ++j){
			cout << i+1 << ' ' << j+102 << ' ' << adj[i][100-j] << '\n';
		}
	}
	cout << S << ' ' << T << '\n';
	cout << flush;
	//for (int i = 1; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include <vector>
#include <algorithm> 
#include <list>
 
using namespace std;
 
int main(){
 string s,front="", back="";;
  int n,q,f;
  cin >> s;
  cin >> n;
  bool hanten = false;
  char c;
  for(int i = 0;i<n;i++){
    cin >>q;
    if(q == 1){
      hanten = !hanten;
    }
    else{
      cin >>f>>c;
      if(hanten) f = (f+1)%2;
      if(f == 1){front = c+front;}
      else{back = back+c;}
    }
  }
  s = front + s + back;
  if(hanten){
   reverse(s.begin(), s.end());
  }
  cout<<s<<endl;
}

Measured memory_bytes: 1512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;

using namespace std;
int main(){
  int r,D,X;
  cin >> r >> D >> X;
  rep(i,10){
    X = r*X - D;
    cout << X << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define vsort(vec) sort(vec.begin(),vec.end())
#define vreverse(vec) reverse(vec.begin(),vec.end())
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int n, m, x[100010], y[100010], ta, mu;

signed main() {
	cin >> n >> m;
	rep(i, n)cin >> x[i];
	rep(i, m)cin >> y[i];
	for (int i = 1; i < n; i++) {
		ta += (x[i] - x[i - 1])*i*(n - i);
		ta %= mod;
	}
	for (int i = 1; i < m; i++) {
		mu += (y[i] - y[i - 1])*i*(m - i);
		mu %= mod;
	}
	cout << (ta*mu) % mod << endl;
	ggr
}

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

int main(){
    int N;
    vector<long long> bubun;
    cin>>N;

    //部分和
    long long temp;
    cin>>temp;
    bubun.push_back(temp);
    for(int i=1;i<N;i++){
        cin>>temp;
        bubun.push_back(bubun[i-1]+temp);
    }
    //O(NlogN)
    stable_sort(bubun.begin(),bubun.end());
    
    //部分和のカウントO(N)
    vector<int> count;
    int count_0=0;
    long long temp2=bubun[0];
    if(bubun[0]==0){count_0++; count.push_back(0);}
    else{count.push_back(1);}
    
    for(int i=1;i<N;i++){
        if(bubun[i]==0){
            count_0++;
        }
        else if(bubun[i]==temp2){
            count[count.size()-1]++;
        }
        else{
            temp2=bubun[i];
            count.push_back(1);
        }
    }    

    //ans
    long long ans=0;
    ans+=(long long)(count_0+1)*count_0/2;
    for(int i=0;i<count.size();i++){
        ans+=(long long)count[i]*(count[i]-1)/2;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
int n,A[50];

int solve(int i,int m){
if(m==0)return 1;
if(i>=n)return 0;
int res = solve(i+1,m)||solve(i+1,m-A[i]);
return res;
}

int main(){
int q,m,i;

scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&A[i]);
scanf("%d",&q);
for(i=0;i<q;i++){
scanf("%d",&m);
if(solve(0,m))printf("yes\n");
else printf("no\n");
}
return 0;
}

Measured memory_bytes: 1804
import sys
readline = sys.stdin.readline

def solve():
    H, W, K = map(int, readline().split())
    C = [[1 if c == '#' else 0 for c in readline().rstrip()] for i in range(H)]

    def f(v, h):
        brd = [list(C[i]) for i in range(H)]
        i = 0
        while v > 0:
            if v & 1:
                for j in range(W):
                    brd[i][j] = 0
            v >>= 1
            i += 1
        
        j = 0
        while h > 0:
            if h & 1:
                for i in range(H):
                    brd[i][j] = 0
            h >>= 1
            j += 1
        
        ret = sum(sum(row) for row in brd)
        return ret

    ans = 0
    for v in range(2 ** H):
        for h in range(2 ** W):
            if f(v, h) == K:
                ans += 1
    
    print(ans)


solve()

Measured memory_bytes: 69176
# ARC090E

def hoge():
    M = 10**9 + 7
    import sys
    input = lambda : sys.stdin.readline().rstrip()

    n, m = map(int, input().split())
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    from collections import defaultdict
    ns = defaultdict(set)
    for i in range(m):
        u, v, d = map(int, input().split())
        ns[u-1].add((v-1, d))
        ns[v-1].add((u-1, d))
    
    def _dijkstra(N, s, Edge):
        import heapq
        geta = 10**15
        inf = geta
        dist = [inf] * N
        dist[s] = 0
        Q = [(0, s)]
        dp = [0]*N
        dp[s] = 1
        while Q:
            dn, vn = heapq.heappop(Q)
            if dn > dist[vn]:
                continue
            for vf, df in Edge[vn]:
                if dist[vn] + df < dist[vf]:
                    dist[vf] = dist[vn] + df
                    dp[vf] = dp[vn]
                    heapq.heappush(Q, (dn + df,vf))
                elif dist[vn] + df == dist[vf]:
                    dp[vf] = (dp[vf] + dp[vn]) % M
        return dist, dp

    def dijkstra(start):
        import heapq
        vals = [None] * n
        nums = [None] * n
        nums[start] = 1
        h = [(0, start)] # (距離, ノード番号)
        vals[start] = 0
        while h:
            val, u = heapq.heappop(h)
            for v, d in ns[u]:
                if vals[v] is None or vals[v]>val+d:
                    vals[v] = val+d
                    nums[v] = nums[u]
                    heapq.heappush(h, (vals[v], v))
                elif vals[v] is not None and vals[v]==val+d:
                    nums[v] = (nums[v] + nums[u]) % M
        return vals, nums
    
    vals1, nums1 = dijkstra(s)
    vals2, nums2 = dijkstra(t)
    
    T = vals1[t]

    c1 = 0 # 頂点で衝突するペアの数
    c2 = 0 # エッジ(端点除く)で衝突するペアの数
    
    for u in range(n):
        if 2*vals1[u]==T and 2*vals2[u]==T:
            c1 = (c1 + pow((nums1[u] * nums2[u]), 2, M)) % M
        for v,d in ns[u]:
            if (vals1[u]+d+vals2[v]==T) and (2*vals1[u] < T < 2*(vals1[u] + d)):
                c2 = (c2 + (nums1[u] * nums2[v])**2) % M
    print((nums1[t]*nums2[s] - (c1+c2)) % M)
hoge()

Measured memory_bytes: 122712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

int main() {
	int h, w, n, a[100000], c[100][100];
	cin >> h >> w;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int x = 0, y = 0, vec = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < a[i]; j++) {
			c[x][y] = i;
			if (x != w - 1 && vec == 1) {
				x += 1;
			}
			else if (x != 0 && vec == -1) {
				x -= 1;
			}
			else {
				y += 1;
				vec *= -1;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << c[j][i] + 1 << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
vector<int> G[maxn];

int main(){
	int n,m,u,v;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);	
	}	
	for(int i = 1; i <= n; i++){
		printf("%d\n", (int)G[i].size());
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
template<typename tn> void print(tn a){
    if(a<0) putchar('-'),a=-a;
    if(a>9) print(a/10);
    putchar(a%10+'0');
}
int n;
int x;
long double a;
long double ans;
int main(){
	read(n);
	for(int i=1;i<=n;i++){
		read(x);
		a=1.0/x;
		ans+=a;
	}
	ans=1/ans;
	printf("%Lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

int main(void){
	int K,T,a,b;
	priority_queue<int> Q;
	scanf("%d%d",&K,&T);
	rep(i,T){
		scanf("%d",&a);
		Q.push(a);
	}
	b = Q.top();
	Q.pop();
	while(!Q.empty()){
		int c = Q.top();
		Q.pop();
		if(b>1)Q.push(b-1);
		b=c;
	}
	printf("%d\n",b-1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,b,aa[100],c=0,d=1000;
signed main(){
	cin>>a>>b;
	rep(i,a){
		cin>>aa[i];
		b-=aa[i];
		if(d>aa[i]){
			d=aa[i];
		}
	}
	c=a;
	c+=b/d;
	cout<<c;
}

Measured memory_bytes: 256
n = int(input())
mod = pow(10, 9) + 7
ans1 = 1
ans2 = 1
ans3 = 1
for i in range(n):
    ans1*=10
    ans1%=mod
    ans2*=9
    ans2%=mod
    ans3*=8
    ans3%=mod
ans4 = ans2*2
ans4%=mod
ans4 = (ans4+mod)-ans3
ans4%=mod
ans = (ans1-ans4+mod)%mod
print(ans)

Measured memory_bytes: 63364
#include <stdio.h>
int main(){
    int data[10000],i,j;
    i=0;
    do{
        scanf("%d",&data[i]);
    }while(data[i++] != 0);
    for(j=0;j<i-1;j++){
        printf("Case %d: %d\n",j+1,data[j]);
    }
    return 0;
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  long long ans = 0;
  int n = s.size();
  vector<long long> suf(n);
  suf[n - 1] = s[n - 1] == 'W';
  for (int i = n - 2; i >= 0; --i) {
    suf[i] = suf[i + 1] + (s[i] == 'W');
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') {
      ans += suf[i];
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
int a[505][505],n,m,x[505*505],y[505*505],x2[505*505],y2[505*505],tot1,tot2;
void read()
{
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=n;i++)
	    for(register int j=1;j<=m;j++)
	    {
	    	scanf("%d",&a[i][j]);
	    	a[i][j]%=2;
		}
}
void work()
{
	for(register int i=1;i<=m;i++)
	    for(register int j=n;j>1;j--)
    	    if(a[j][i]==1)
		    {
	        	a[j-1][i]^=1;
	        	a[j][i]=0;
                x[++tot1]=j;
                x2[++tot2]=j-1;
                y[tot1]=i;
                y2[tot2]=i;
		    }
    for(register int i=1;i<m;i++)
        if(a[1][i]==1)
        {
        	a[1][i+1]^=1;
			a[1][i]=0;
			x[++tot1]=1;
			x2[++tot2]=1;
			y[tot1]=i;
			y2[tot2]=i+1;
		}
	printf("%d\n",tot1);
	for(register int i=1;i<=tot1;i++)
	    printf("%d %d %d %d\n",x[i],y[i],x2[i],y2[i]);
}  
int main()
{
	read();
	work();
	return 0;
}

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

#define ll long long
int main()
{
    int A, B, C, X, cnt = 0;
    cin >> A >> B >> C >> X;
    for (int i = 0; i <= A; i++)
    {
        for (int j = 0; j <= B; j++)
        {
            if (X - (500 * i + 100 * j) >= 0 && X - (500 * i + 100 * j) <= 50 * C)
                cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
const int maxn=710;
const int mv=705;
int n,m,cnt[maxn][3],u,v,tot;
bool maz[maxn][maxn];
vector<int>Q[maxn];
int vis[maxn];
bool flag;
bool dp[maxn<<1],f[maxn<<1];
void dfs(int t,int cor){
    if (vis[t]){
        if (vis[t]!=cor) flag=false;
        return;
    }
    vis[t]=cor;cnt[tot][cor]++;
    for (int i=0,sz=Q[t].size();i<sz;i++){
        int v=Q[t][i];
        dfs(v,3-cor);
    }
}
int main(){
    while (~scanf("%d%d",&n,&m)){
        memset(maz,false,sizeof(maz));
        for (int i=1;i<=m;i++){
            scanf("%d%d",&u,&v);
            maz[u][v]=maz[v][u]=true;
        }
        for (int i=1;i<=n;i++){
            Q[i].clear();
            for (int j=1;j<=n;j++) if (i!=j&&!maz[i][j]) Q[i].push_back(j);
        }
        flag=true;
        tot=0;
        for (int i=1;i<=n;i++) vis[i]=0;
        for (int i=1;i<=n;i++) if (!vis[i]&&Q[i].size()>0){
            tot++;
            cnt[tot][1]=cnt[tot][2]=0;
            dfs(i,1);
            if (!flag) break;
        }
        if (!flag) printf("-1\n");
        else {
            memset(dp,false,sizeof(dp));dp[mv]=true;
            for (int i=1;i<=tot;i++){
                memset(f,false,sizeof(f));
                for (int j=0;j<maxn*2;j++) if (dp[j]){
                    f[j+cnt[i][1]-cnt[i][2]]=true;
                    f[j+cnt[i][2]-cnt[i][1]]=true;
                }
                for (int j=0;j<maxn*2;j++) dp[j]=f[j];
            }
            int ans=-1;
            for (int i=0;i<=n;i++) if (dp[mv-i]||dp[mv+i]) {ans=i;break;}
            int all=0;
            for (int i=1;i<=tot;i++) all+=cnt[i][1]+cnt[i][2];

            int cnt1=(all-ans)/2,cnt2=(all+ans)/2;
            if (n-all>=cnt2-cnt1){
                cnt1=n/2;
                cnt2=n-n/2;
            }else cnt1+=(n-all);
            printf("%d\n",cnt1*(cnt1-1)/2+cnt2*(cnt2-1)/2);
        }
    }
    return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

struct node {
    int p = -1;
    int r;
    int l;
    int s = -1;
};

int N;
vector<int> D, H;
vector<node> G;
void rec(int s, int depth) {
    D[s] = depth;
    if (G[s].r != -1)
        rec(G[s].r, depth + 1);
    if (G[s].l != -1)
        rec(G[s].l, depth + 1);
}

int rrec(int s) {
    if (G[s].r == -1 && G[s].l == -1) {
        H[s] = 0;
    } else if (G[s].r == -1) {
        H[s] = rrec(G[s].l) + 1;
    } else if (G[s].l == -1) {
        H[s] = rrec(G[s].r) + 1;
    }
    else {
        H[s] = max(rrec(G[s].r), rrec(G[s].l)) + 1;
    }

    return H[s];
}

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

    cin >> N;
    G.resize(N);
    D.resize(N, 0), H.resize(N, 0);
    rep(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a].l = b, G[a].r = c;
        if (b != -1)
            G[b].p = a, G[b].s = c;
        if (c != -1)
            G[c].p = a, G[c].s = b;
    }

    int s;
    rep(i, N) {
        if (G[i].p == -1) {
            s = i;
            break;
        }
    }

    rec(s, 0);
    rrec(s);

    rep(i, N) {
        cout << "node " << i << ": ";
        cout << "parent = " << G[i].p << ", ";
        cout << "sibling = " << G[i].s << ", ";
        cout << "degree = ";
        if (G[i].r == -1 && G[i].l == -1) {
            cout << 0;
        } else if (G[i].r != -1 && G[i].l != -1) {
            cout << 2;
        } else {
            cout << 1;
        }
        cout << ", ";
        cout << "depth = " << D[i] << ", ";
        cout << "height = " << H[i] << ", ";
        if (G[i].p == -1) {
            cout << "root";
        } else if (G[i].l == -1 && G[i].r == -1) {
            cout << "leaf";
        } else {
            cout << "internal node";
        }
        cout << endl;
    }
}


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

int main(int argc, char const *argv[])
{
	int n,a,b;
	cin>>n>>a>>b;
	int ans=0;
	for (int i = 1; i <= n; ++i)
	{
		int now=i,s=0;
		while (now>0)
		{
			s+=now%10;
			now/=10;
		}
		if (a<=s&&s<=b)
		{
			ans+=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    long long N, K, R, S, P;
    string T, taka = "";
    cin >> N >> K >> R >> S >> P >> T;
    for (auto c : T) {
        if (c == 'r') taka += 'p';
        if (c == 'p') taka += 's';
        if (c == 's') taka += 'r';
    }
    map<char, long long> cnt;
    vector<bool> use(N, true);
    cnt['p'] = P; cnt['r'] = R; cnt['s'] = S;
    long long ans = 0;
    for (int i = 0; i < K; i++) ans += cnt[taka[i]];
    for (int i = K; i < N; i++) {
        if (taka[i-K] == taka[i] && use[i-K]) use[i] = false;
        else ans += cnt[taka[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n, m, l = map(int, input().split())
a = [[int(i) for i in input().split()] for j in range(n)]
b = [[int(j) for j in input().split()] for k in range(m)]

for i in range(n):
    for j in range(l):
        sum = 0
        for k in range(m):
            sum += a[i][k]*b[k][j]
        print(sum, end="")
        if j != l - 1:
            print(' ', end="")
    print()



Measured memory_bytes: 6552
a,b,k = map(int,input().split())
cnt=0
while cnt < k:
    if cnt%2==0:
        if a%2==0:
            b+=a//2
            a=a//2
            cnt+=1
        else:
            a-=1
            cnt+=1
            b+=a//2
            a=a//2
    else:
        if b%2==0:
            a+=b//2
            b=b//2
            cnt+=1
        else:
            b-=1
            cnt+=1
            a+=b//2
            b=b//2
print(a,b)



Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		boolean result = true;

		for (int i=0; i < S.length(); i++){
			char c = S.charAt(i);
			if (i+1 <= A || i+1 >= A+2){
				if (c < '0' || c > '9'){
					result = false;
					break;
				}
			} else {
				if (c != '-'){
					result = false;
					break;
				}
			}
		}
		if (result){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

void cal(vector<vector<int>> a, vector<int> b) {
	for (auto itr = a.begin(); itr != a.end(); ++itr) {
		int sum = 0;
		for (unsigned int i = 0; i < itr->size(); i++) {
			sum += (*itr)[i] * b[i];
		}
		cout << sum << endl;
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> A;
	vector<int> B;
	for (int i = 0; i < n; i++) {
		vector<int> v_tmp;
		for (int j = 0; j < m; j++) {
			int tmp;
			cin >> tmp;
			v_tmp.push_back(tmp);
		}
		A.push_back(v_tmp);
	}
	for (int i = 0; i < m; i++) {
		int tmp;
		cin >> tmp;
		B.push_back(tmp);
	}
	cal(A, B);
	return 0;
}



Measured memory_bytes: 3208
#include <stdio.h>
#define X 1000

int main(){
  int i, j, k, m, n, u;
  int Ad[X][X];

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&m);
      Ad[u-1][m-1] = 1;
    }
  }
  for(i = 0 ; i < n ; i++){
    for (j = 0 ; j < n-1 ; j++){
      printf("%d ", Ad[i][j]);
    }
    printf("%d\n", Ad[i][j]);
  }
  return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S[303],T[303];

struct RollingHash {
	static const ll mo0=1000000007,mo1=1000000009;
	static ll mul0,mul1;
	static const ll add0=1000010007, add1=1003333331;
	static vector<ll> pmo[2];
	string s; int l; vector<ll> hash_[2];
	void init(string s) {
		this->s=s; l=s.size(); int i,j;
		hash_[0]=hash_[1]=vector<ll>(1,0);
		if(!mul0) mul0=10009+(((ll)&mul0)>>5)%259,mul1=10007+(((ll)&mul1)>>5)%257;
		if(pmo[0].empty()) pmo[0].push_back(1),pmo[1].push_back(1);
		FOR(i,l) hash_[0].push_back((hash_[0].back()*mul0+add0+s[i])%mo0);
		FOR(i,l) hash_[1].push_back((hash_[1].back()*mul1+add1+s[i])%mo1);
	}
	pair<ll,ll> hash(int l,int r) { // s[l..r]
		if(l>r) return make_pair(0,0);
		while(pmo[0].size()<r+2)
			pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
		return make_pair((hash_[0][r+1]+(mo0-hash_[0][l]*pmo[0][r+1-l]%mo0))%mo0,
			             (hash_[1][r+1]+(mo1-hash_[1][l]*pmo[1][r+1-l]%mo1))%mo1);
	}
	pair<ll,ll> hash(string s) { init(s); return hash(0,s.size()-1); }
	static pair<ll,ll> concat(pair<ll,ll> L,pair<ll,ll> R,int RL) { // hash(L+R) RL=len-of-R
		while(pmo[0].size()<RL+2) pmo[0].push_back(pmo[0].back()*mul0%mo0), pmo[1].push_back(pmo[1].back()*mul1%mo1);
		return make_pair((R.first + L.first*pmo[0][RL])%mo0,(R.second + L.second*pmo[1][RL])%mo1);
	}
};
vector<ll> RollingHash::pmo[2]; ll RollingHash::mul0,RollingHash::mul1;
RollingHash RS[303],RT[303];
pair<ll,ll> RS2[303][303];
pair<ll,ll> RT2[303][303];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(y,N) {
		cin>>S[y];
		FOR(x,N) T[x]+=S[y][x];
	}
	
	FOR(i,N) {
		S[i]+=S[i];
		T[i]+=T[i];
		RS[i].init(S[i]);
		RT[i].init(T[i]);
		FOR(j,N) RS2[i][j]=RS[i].hash(j,j+N);
		FOR(j,N) RT2[i][j]=RT[i].hash(j,j+N);
	}
	
	int ret=0;
	FOR(y,N) FOR(x,N) {
		int ok=1;
		FOR(i,N) if(RS2[(y+i)%N][x]!=RT2[(x+i)%N][y]) ok=0;
		ret+=ok;
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }
 
 
int main(){
    ll n; cin >> n;
    vector<ll> x(n), y(n), sum(n), sub(n);
    rep(i, n){
        cin >> x[i] >> y[i];
        sum[i] = x[i] + y[i];
        sub[i] = x[i] - y[i];
    }
    sort(sum.begin(), sum.end());
    sort(sub.begin(), sub.end());
    ll res = sum[n - 1] - sum[0];
    chmax(res, sub[n - 1] - sub[0]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9584
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

int n;
ll p(ll n, int i){
	ll res = 1;
	for(int j = 0; j < i; j++){
		res *= n;
	}
	return res;
}


int main(){
	ll n;
	while(cin >> n && n){
		ll res = 0;
		for(int i = 0; n != 0; i++){
			int j = 0;
			if(i % 2 == 0){
				while((n - j) % 10 != 0) j++;
				n -= j;
			}else{
				while((n + j) % 10 != 0) j++;
				n += j;
			}
			res +=  (ll)j * p(10, i);
			n /= 10;
		}
		cout << res << endl;
	}
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int a;
	if (S == "MON") a = 1;
	else if (S == "TUE") a = 2;
	else if (S == "WED") a = 3;
	else if (S == "THU") a = 4;
	else if (S == "FRI") a = 5;
	else if (S == "SAT") a = 6;
	else if (S == "SUN") a = 0;

	cout << 7 - a << endl;
	return 0;
}

Measured memory_bytes: 256
// D - 3N Numbers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main(){
	int N; cin>>N;
	vector<ll> A(3*N);
	rp(i, 3*N) cin>>A[i];

	vector<ll> F(3*N);
	F[0] = A[0];
	priority_queue<int> fque;
	fque.push(-A[0]);
	for(int i=1; i<3*N; ++i){
		fque.push(-A[i]);
		ll minA = 0;
		if(fque.size() > N){
			minA = -fque.top();
			fque.pop();
		}
		F[i] += F[i-1] + A[i] - minA;
	}

	reverse(all(A));

	vector<ll> B(3*N);
	B[0] = A[0];
	priority_queue<int> bque;
	bque.push(A[0]);
	for(int i=1; i<3*N; ++i){
		bque.push(A[i]);
		ll minA = 0;
		if(bque.size() > N){
			minA = bque.top();
			bque.pop();
		}
		B[i] += B[i-1] + A[i] - minA;
	}

	reverse(all(B));

	ll maxfb = LLONG_MIN;
	rp(i, N+1){
		int f = N - 1 + i;
		int b = f + 1;
		maxfb = max(maxfb, F[f]-B[b]);
	}
	cout<< maxfb <<endl;

}

Measured memory_bytes: 8440
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a * b + " " + 2 * (a + b));
	}
}

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

int main()
{
    int64_t X;
    cin >> X;

    for (int64_t a = -1000; a <= 1000; a++)
    {
        for (int64_t b = -1000; b <= 1000; b++)
        {
            if (a * a * a * a * a - b * b * b * b * b == X)
            {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
n,m = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]
AB.sort()

cost = 0
for i in range(n):
  if m <= AB[i][1]:
    cost += m * AB[i][0]
    print(cost)
    exit()
  else:
    m = m - AB[i][1]
    cost += AB[i][1] * AB[i][0]
    
print(cost)

Measured memory_bytes: 27760
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int dp[100005][2];

int main(){
    string s;
    cin>>s;
    int n=s.size();
    dp[0][0]=1;
    rep(i,s.size()){
        if(s[i]=='0'){//a+bのi桁目が0
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=dp[i][1];
        }
        else{
            dp[i+1][1]=(dp[i][0]+dp[i][1])%MOD;
        }

        if(s[i]=='0'){//a+bのi桁目が1
            dp[i+1][1]+=dp[i][1]*2%MOD;
            dp[i+1][1]%=MOD;
        }
        else{
            dp[i+1][0]+=dp[i][0]*2%MOD;
            dp[i+1][0]%=MOD;
            dp[i+1][1]+=dp[i][1]*2%MOD;
            dp[i+1][1]%=MOD;
        }
    }
    int ans=(dp[n][0]+dp[n][1])%MOD;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int l=sc.nextInt();
        int[][] nm=new int[n][m];
        int[][] ml=new int[m][l];
        Long[][] nl=new Long[n][l];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                nm[i][j]=sc.nextInt();
            }
        }
        for(int k=0;k<m;k++){
            for(int p=0;p<l;p++){
                ml[k][p]=sc.nextInt();
            }
        }for(int a=0;a<n;a++){
            for(int b=0;b<l;b++){
                Long sum=0L;
                for(int c=0;c<m;c++){
                    sum+=nm[a][c]*ml[c][b];
                }
                nl[a][b]=sum;
            }
        }
        for(int d=0;d<n;d++){
            for(int e=0;e<=l-1;e++){
                System.out.print(nl[d][e]);
                if(e!=l-1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 68088
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
const double EPS=1e-6;
 
double cross(P a, P b){ return imag(conj(a)*b); }
P crossPoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}
 
int main(){
  int n;
  cin>>n;
  vector<P> G(n);
  for(int i=0;i<n;i++){
    double x,y;
    cin>>x>>y;
    G[i]=P(x,y);
  }
  if(n%2){cout<<"NA"<<endl;return 0;}  
  double len=abs(G[0]-G[1]);
  for(int i=0;i<n/2;i++){
    double a=abs(G[i]-G[(i+1)]);
    double b=abs(G[i+n/2]-G[(i+n/2+1)%n]);
    if(abs(a-b)>EPS){cout<<"NA"<<endl;return 0;}
  }
  P ans=crossPoint(L(G[0],G[n/2]),L(G[1],G[n/2+1]));
  printf("%lf %lf\n",real(ans),imag(ans));
  return 0;
}

Measured memory_bytes: 3352
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  int w[101];
  w[0]=0;
  rep(i,n){
    int x;
    cin>>x;
    w[i+1]=x+w[i];
  }

  int ans=inf;
  rep(i,n){
    int left=w[i+1],right=w[n]-left;
    if(abs(right-left)<ans) ans=abs(right-left);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n,L;
int a[N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),L=read();
	for(register int i=1;i<=n;i++)a[i]=read();
	int pos=0;
	for(register int i=1;i<n;i++)
	{
		if(a[i]+a[i+1]>=L){pos=i;break;}
	}
	if(!pos){printf("Impossible\n");return 0;}
	printf("Possible\n");
	for(register int i=1;i<pos;i++)printf("%d\n",i);
	for(register int i=n-1
	;i>pos;i--)printf("%d\n",i);
	printf("%d\n",pos);
	return 0;
}


Measured memory_bytes: 4080
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]
sum = 0
ac = 0

for i in range(n):
  for j in range(m):
    sum += a[i][j] * b[j]
  if sum + c > 0:
    ac += 1
  sum = 0

print(ac)

Measured memory_bytes: 3064
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  ll n,m,l,t;
  cin >> n;
  ll ans;
  ans = n*(n+1)/2;
  m = (ll) n/3;
  l = (ll) n/5;
  t = (ll) n/15;
  ans -= 3*m*(m+1)/2 + 5*l*(l+1)/2;
  ans += 15*t*(t+1)/2;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3748
import Control.Monad
import Data.Char
import qualified Data.Sequence as S

main = do
    [n, k] <- map read <$> words <$> getLine
    s      <- getLine
    putStrLn $ show $ solve n k s

solve :: Int -> Int -> String -> Int
solve n k s = doit 0 (S.fromList $ replicate k 0) 0 s
  where
    doit :: Int -> (S.Seq Int) -> Int -> String -> Int
    doit d start pos []        = n - S.index start 0
    doit 0 start pos ('1' : t) =      doit 1 (start S.|> pos) (pos + 1) t
    doit 1 start pos ('0' : t) = max (doit 0 (S.drop 1 start) (pos + 1) t) $ pos - S.index start 0
    doit d start pos ( _  : t) =      doit d  start           (pos + 1) t

Measured memory_bytes: 15740
import math

n = int(input())

'''
(26**(m+1) - 26) / 25 <= n
26**(m+1) <= 25n + 26
m <= log(25n+26, 26) - 1
'''

m = int(math.log(25*n+26, 26) - 1)

d = n - (26**(m+1) - 26) // 25

alphabetTable = ['z']
alphabetTable.extend(chr(i) for i in range(97,123))


if d == 0:
  print('z' * m)

else:
  dd = []
  cnt = 0
  for i in range(1, m+2):
    cnt += 1
    amari = d % 26
    d = d//26 + 1
    if amari == 0:
      d -= 1
    dd.append(amari)
    if d <= 0:
      break
  


  alpha = [alphabetTable[dd[i]] for i in range(cnt)]
  alpha.extend(['a' * (m+1-cnt)])
  alpha.reverse()
  print(''.join(alpha))


Measured memory_bytes: 9232
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
#define PRM 1000000007
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

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

    ll total;

    vector<ll> res(n+1,0); 



    FOR(i,2,n+1){
        if(IsPrime(i)){
            FOR(j,1,n+1){
                int hold = j;
                //cout << i << endl;
                while(hold%i==0){
                    hold/=i;
                    res[i]++;
            }
            }
        }
    }

    ll ans=1;

    FOR(i,1,n+1){
        if(res[i]!=0){
            ll res2 = (1+res[i])%PRM;
            ans *= res2;
            ans = ans % PRM;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	double l;
	cin>>l;
	cout<<setprecision(12)<<l*l*l/27<<endl;
	return 0;
}

Measured memory_bytes: 384