akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int k,s;
  cin>>k>>s;
  int z;
  int ans = 0;
  FOR(i, 0, k + 1) {
    FOR(j,0, k + 1) {
      z = s - i - j;
      if(z >= 0 && z <= k) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = "", ans = "";
		
		s = sc.nextLine();
		sc.close();
		
		ans = s.replace(",", " ");
		System.out.println(ans);
	}

}


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

ll h, w;
vector<string> s;
ll dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

ll bfs(ll x, ll y) {
    queue<pair<ll, ll>> q;
    vector<vector<ll>> dist(h, vector<ll>(w, INF));
    q.emplace(x, y);
    dist[x][y] = 0;
    while(!q.empty()) {
        pair<ll, ll> p = q.front();
        q.pop();
        rep(i, 0, 4) {
            ll nx = p.first + dx[i], ny = p.second + dy[i];
            if(0 <= nx && nx < h && 0 <= ny && ny < w) {
                if(s[nx][ny] == '.' && dist[nx][ny] == INF) {
                    dist[nx][ny] = dist[p.first][p.second] + 1;
                    q.emplace(nx, ny);
                }
            }
        }
    }
    ll ans = 0;
    rep(i, 0, h) rep(j, 0, w) if(dist[i][j] != INF) chmax(ans, dist[i][j]);
    return ans;
}

int main() {
    cin >> h >> w;
    s.resize(h);
    rep(i, 0, h) cin >> s[i];
    ll ans = 0;
    rep(i, 0, h) rep(j, 0, w) if(s[i][j] == '.') chmax(ans, bfs(i, j));
    cout << ans << endl;
}


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

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

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

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

LL sm,N;
stack<int> st;
vii cnt;
vector<string> s;
int f(int idx,array<LL,3> a){
    //cerr<<idx<<" "<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    if(idx==N){
        return 1;
    }
    FOR(jj,0,2){
        int i=s[idx][jj]-'A';
        int j=s[idx][1-jj]-'A';
        if(a[j]!=0){
            if(cnt[idx][i]<=a[i]&&cnt[idx][j]<=a[j]&&jj==1)continue;
            array<LL,3> b(a);
            b[i]++;b[j]--;
            int fl=f(idx+1,b);
            if(fl){
                st.push(i);
                return 1;
            }
        }
    }
    return 0;
}

int main(){
	LL n,a,b,c;
    cin>>n>>a>>b>>c;
    sm=a+b+c;
    N=n;
    s=vector<string>(n);
    cnt=vii(n+1,vi(3,0));
    FOR(i,0,n){
        cin>>s[i];
    }
    FORD(i,n,0){
        FOR(j,0,3){
            cnt[i][j]=cnt[i+1][j];
        }
        FOR(j,0,2){
            cnt[i][s[i][j]-'A']++;
        }
    }

    if(f(0,{a,b,c})==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        FOR(i,0,n){
            int t=st.top();
            st.pop();
            cout<<(char)('A'+t)<<endl;
        }
    }

    

}


Measured memory_bytes: 26208
#include<iostream>
using namespace std;
int main(){
    int a,b,c=0;
    cin >> a >> b;
    if(a>b)
        c+=a--;
    else
        c+=b--;
    if(a>b)
        c+=a;
    else
        c+=b;
    cout << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for(int i=0;i<n;i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n;
	int a[100];
	cin >> n;
	loop(n)
		cin >> a[i];
	sort(a, a + n);
	cout << a[n - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli inf = 1e9;

lli solve(lli a, lli b, lli p){
    vector<lli> dp(b-a+2, 0);
    lli res = 0;
    for(lli i=0; i<b-a+1; i++){
        dp[i+1] = (dp[i+1]+dp[i])%p;
        dp[i] = (dp[i]+1)%p;
        res = (res+dp[i])%p;
        lli low=1, up=10;
        for(; low<=inf; low*=10, up*=10){
            if(a+i >= up) continue;
            if(a+i >= low){
                dp[i+1] = (dp[i+1] +dp[i])%p;
                if(up <= b) dp[up-a] = (dp[up-a] -dp[i] +p)%p;
            }else{
                lli lim = a+i;
                while(lim < low) lim*=10;
                if(lim <= b) dp[lim-a] = (dp[lim-a] +dp[i])%p;
                if(up <= b) dp[up-a] = (dp[up-a] -dp[i] +p)%p;
            }
        }
        
    }
    return res;
}

int main(){
    while(1){
        int a,b,p;
        cin >> a >> b >> p;
        if(a==0) break;
        cout << solve(a,b,p) << endl;
    }
    return 0;
}



Measured memory_bytes: 3904
N,M=input().split()
N,M=[int(N),int(M)]
 
a = list(map(int,input().strip().split()))[:N]
  
number=0
total=0
for i in range(N):
  v=a[i]
  total=total+v
for i in range(N):
  v=a[i]
  if v < (1/(4*M))*total:
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<utility>
#include<climits>
#include<set>
using namespace std;
#define ll long long

ll mod=1000000007;

ll dp[2005];
ll ans(int n)
{
	if(n==1 or n==2)
		return 0LL;
	else if(n==0)
		return 1LL;
	else if(dp[n]!=-1)
		return dp[n];
	else if(n==3 or n==4 or n==5)
		return 1LL;
	else
	{
		ll total=0;
		for(int i=3;i<=n;i++)
		{

			total+=(ans(n-i)%mod);
		}
		return dp[n]=total;
	}
}
int main(){ 
	ios_base::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	    
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif

	    memset(dp,-1,sizeof(dp));
	    dp[0]=0;
	    int n;cin>>n;
	    cout<<ans(n)%mod;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define MAX 100005
#define EPS 1e-8
using namespace std;

typedef long long ll;
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int factor[105];

void factorize(int n)
{
    int idx = 0, pf = primes[idx];
    while(pf * pf <= n){
        if(n % pf == 0){
            while(n % pf == 0){
                factor[pf]++;
                n /= pf;
            }
        }
        pf = primes[++idx];
    }
    if(n != 1)
        factor[n]++;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int n;

    cin>>n;

    for(int i = 2; i <= n; i++){
        factorize(i);
    }
    
    int cnt = 0;
    for(int i = 0; i < 25; i++){
        if(factor[i] >= 74)
            cnt++;
        for(int j = i + 1; j < 25; j++){
            if(factor[primes[i]] >= 2 && factor[primes[j]] >= 24)
                cnt++;
            if(factor[primes[i]] >= 24 && factor[primes[j]] >= 2)
                cnt++;
            if(factor[primes[i]] >= 4 && factor[primes[j]] >= 14)
                cnt++;
            if(factor[primes[i]] >= 14 && factor[primes[j]] >= 4)
                cnt++;
            for(int k = j + 1; k < 25; k++){
                if(factor[primes[i]] >= 4 && factor[primes[j]] >= 4 && factor[primes[k]] >= 2)
                    cnt++;
                if(factor[primes[i]] >= 4 && factor[primes[j]] >= 2 && factor[primes[k]] >= 4)
                    cnt++;
                if(factor[primes[i]] >= 2 && factor[primes[j]] >= 4 && factor[primes[k]] >= 4)
                    cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    

    return 0;
}

Measured memory_bytes: 256
# 解説放送
# 写経

def main():
    inf = 18 * (10 ** 6 + 1)

    s = input()
    s = '0' + s
    *s, = map(int, s)  # 先に一括でintにした

    n = len(s)

    dp = [[inf] * 2 for _ in range(n + 1)]
    dp[0][0] = 0

    for i, c in enumerate(s[::-1]):
        for j in range(2):
            x = c + j
            if x < 10:
                dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + x)  # a=x,b=0
            if x > 0:
                dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + (10 - x))  # a=0,bに繰り下がり

    print(dp[n][0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 154112
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int convex_hull(vector<pdd> a)
{
	vector<pdd> u, d;
	sort(all(a));
	for (int i = 0; i < a.size(); i++)
	{
		for (int l = u.size() - 1; l >= 1; l--)
		{
			double v1, v2;
			v1 = atan2(u[l].first - u[l - 1].first, u[l].second - u[l - 1].second);
			v2 = atan2(a[i].first - u[l - 1].first, a[i].second - u[l - 1].second);
			if (v2 < v1)u.pop_back();
		}
		u.push_back(a[i]);
	}

	for (int i = 0; i < a.size(); i++)
	{
		for (int l = d.size() - 1; l >= 1; l--)
		{
			double v1, v2;
			v1 = atan2(d[l].first - d[l - 1].first, d[l].second - d[l - 1].second);
			v2 = atan2(a[i].first - d[l - 1].first, a[i].second - d[l - 1].second);
			if (v2 > v1)d.pop_back();
		}
		d.push_back(a[i]);
	}

	for (int i = 0; i < u.size(); i++)
	{
		//cout << u[i].first << " " << u[i].second << endl;
	}
	return u.size()+d.size()-2;
}


int main()
{
	int n;
	while (cin >> n&&n)
	{
		vector<pdd> v;
		for (int i = 0; i < n; i++)
		{
			double x, y;
			scanf("%lf,%lf", &x, &y);
			v.push_back(pdd(x, y));
		}
		cout << n - convex_hull(v) << endl;
	}
}

Measured memory_bytes: 1356
#include <iostream>
#include <string>
#include <cmath>
#include <stdio.h>
using namespace std;

string S;
int main(){
	cin >> S;
	int ans = 1e9;
	for(int i=0;i<S.size()-2;i++){
		string s = S.substr(i,3);
		int n = atoi(s.c_str());
		ans = min(ans,abs(n-753));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a_num in range(A+1):
    for b_num in range(B+1):
        for c_num in range(C+1):
            price = 500*a_num+100*b_num+50*c_num
            if price == X:
                count += 1
print(count)

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

using namespace std;
typedef long long ll;

struct edge {
    ll v, a, b; // v - vertex, a - edge cost, b - time
};

struct entry {
    ll b, v, c; // b - time, v - vertex, c - coins
};

bool operator>(const entry &l, const entry &r) {
    return l.b > r.b;
}

const ll N = 52, A = 2510;
vector<edge> g[N];
pair<ll, ll> cd[N];
ll dp[N][A + 1];

int main() {
    ll n, m, s;
    cin >> n >> m >> s;
    for (ll i = 1; i <= m; i++) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        g[u].push_back({v, a, b});
        g[v].push_back({u, a, b});
    }
    for (ll i = 1; i <= n; i++) cin >> cd[i].first >> cd[i].second;
    priority_queue<entry, vector<entry>, greater<entry>> q;
    q.push({0, 1, min(s, A)});
    while (!q.empty()) {
        auto entry = q.top();
        q.pop();
        if (dp[entry.v][entry.c]) continue;
        dp[entry.v][entry.c] = entry.b;
        for (auto edge : g[entry.v]) {
            if (entry.c - edge.a >= 0) {
                q.push({entry.b + edge.b, edge.v, min(entry.c - edge.a, A)});
            }
        }
        q.push({entry.b + cd[entry.v].second, entry.v, min(entry.c + cd[entry.v].first, A)});
    }
    for (int i = 2; i <= n; i++) {
        ll ans = 1e16;
        for (int j = 0; j <= A; j++) if (dp[i][j]) ans = min(ans, dp[i][j]);
        cout << ans << "\n";
    }
}


Measured memory_bytes: 16592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, max;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            max = a + b;
            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long LL;
int n,a[20];
LL sol(int l,int r,int L,int R){
	if(l+1==r)return 0;
	LL res=1e18;
	rep(i,l+1,r-1){
		res=min(res,sol(l,i,L,L+R)+sol(i,r,L+R,R)+1LL*a[i]*(L+R));
	}
	return res;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",a+i);
	printf("%lld\n",sol(1,n,1,1)+a[1]+a[n]);
	return 0;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int a,b,c,x;

int main(){
	cin>>a>>b>>c>>x;
	int res=0;
	for(int i=0;i<=a;i++) for(int j=0;j<=b;j++) for(int k=0;k<=c;k++) if(i*500+j*100+k*50==x) res++;
	cout<<res<<endl;
}

Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
//97->a 122->z
//65-A
int main()
{
	//freopen("testcase.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int n,m;
		cin>>n>>m;
		int n1;
		cin>>n1;
		int a[n1+1];
		for(i=1;i<=n1;i++)
			cin>>a[i];
		vector<int>answer;
		for(i=1;i<=n1;i++)
		{
			for(j=0;j<a[i];j++)
				answer.push_back(i);
		}
		i=0;
		j=0;
		int k=0;
		vector<int>answer1[101];
		int count1=0;
		while(1)
		{
			answer1[count1].push_back(answer[k]);
			//cout<<answer[k]<<" ";
			k++;
			i++;
			if(k==answer.size())
				break;
			if(i==m)
			{
				count1++;
				i=0;
				//cout<<endl;
			}
		}
		for(i=0;i<=count1;i++)
		{
			if(i%2==1)
				reverse(answer1[i].begin(),answer1[i].end());
			for(j=0;j<answer1[i].size();j++)
				cout<<answer1[i][j]<<" ";
			cout<<endl;
		}
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
#num= list(map(int, input().split()))
#s = input()
n = int(input())
v= list(map(int, input().split()))
v.sort()
for i in range(n-1):
  v[i+1] = (v[i]+v[i+1])/2
print(v[n-1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

    vector<ll> l(n);
    rep (i, n)
        cin >> l[i];

    int ans = 0;
    rep (i, n)
        rep (j, n)
            rep (k, n)
                if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i] && abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j])
                    ans++;

    cout << ans / 6 << endl;
    return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

def insertionsort(a, n, g):
    global c
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j + g] = a[j]
            j = j - g
            c += 1
        a[j + g] = v

c = 0
g = [1]
while g[-1] * 3 + 1 < n:
    g.append(g[-1] * 3 + 1)
g.reverse()
for i in range(len(g)):
    insertionsort(a, n, g[i])
print(len(g))
print(" ".join(map(str, g)))
print(c)
for i in range(n):
    print(a[i])



Measured memory_bytes: 45520
import math

[N, D] = map(int, input().split())
Xs = [list(map(int, input().split())) for _ in range(N)]

def dist(y, z):
    return math.sqrt(sum([(y[i] - z[i]) * (y[i] - z[i]) for i in range(D)]))

count = 0
for i in range(N):
    for j in range(i+1, N):
        d = dist(Xs[i], Xs[j])
        if int(d) == d:
            count += 1

print(count)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        sc.close();

        System.out.println(CombineString(N, S, T));
    }
    public static String CombineString(int N, String S, String T) {
        if (S.length() < 1 || T.length() < 1) {
            return "";
        }
        return S.substring(0, 1) + T.substring(0, 1) + CombineString(N-1, S.substring(1), T.substring(1));
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//入力
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();

		//1度目の往復 正方形を描くように移動する
		for (int i = 0; i < tx - sx; i++) {
			System.out.print("R");
		}
		for (int i = 0; i < ty - sy; i++) {
			System.out.print("U");
		}
		for (int i = 0; i < tx - sx; i++) {
			System.out.print("L");
		}
		for (int i = 0; i < ty - sy; i++) {
			System.out.print("D");
		}

		//2度目の往復 一度外側に移動して、1度目の正方形を囲むように移動する
			System.out.print("D");

		for (int i = 0; i < tx - sx + 1; i++) {
			System.out.print("R");
		}
		for (int i = 0; i < ty - sy + 1; i++) {
			System.out.print("U");
		}

			System.out.print("L");
			System.out.print("U");

		for (int i = 0; i < tx - sx + 1; i++) {
			System.out.print("L");
		}
		for (int i = 0; i < ty - sy + 1; i++) {
			System.out.print("D");
		}

			System.out.print("R");
	}
}

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

int main(void){
             ll N, M; 
          cin>> N >> M;
          vector<ll> A(N);
          priority_queue<ll> que; 
          
          for(ll i=0; i<N; i++){
            cin >> A.at(i);
            que.push(A.at(i)); 
          }
          
          for(ll i=0; i<M; i++){
            ll a = que.top(); 
            que.pop(); 
            a = a/2; 
            que.push(a);
          }
          
          ll S=0; 
          
          while(que.size()>0){
            ll x;
            x=que.top(); 
            S+= x; 
            que.pop();
          }
          cout<< S << endl;  
    
}


Measured memory_bytes: 2168
#include<iostream>
#include <iomanip>
#include <map>
#include <string>
int main() {
    int n;
    std::cin >> n;
    std::map<std::string, int> hm;
    for (int i = 0; i < n; ++i) {
        std::string s;
        std::cin >> s;
        hm[s]++;
    }
    int counter = 0;
    for (auto x : hm)
        counter++;
    std::cout << counter;
}

Measured memory_bytes: 19260
#include<bits/stdc++.h>
#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,K;
    cin >> N >> K;
    int ans = 0;
    while(N > 0){
        N /= K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] W = new string[N];
            for(int i = 0; i < N; i++)
            {
                W[i] = Console.ReadLine();
            }

            bool judge = true;
            for(int i = 1; i < N; i++)
            {
                if(W[i - 1][W[i - 1].Length - 1] != W[i][0]) judge = false;
            }
            for(int i = 0; i < N; i++)
            {
                for(int j = i + 1; j < N; j++)
                {
                    if (W[i] == W[j]) judge = false;
                }
            }

            Console.WriteLine(judge ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>

using namespace std;

int n, m;
char ch[102];

void funcA()
{
  for(int i = 1; i <= n; ++i)
    if(ch[i] == '#'){
      ch[i] = 'A';
      break;
    }

  return ;
}

void funcB()
{
  for(int i = n; i > 0; --i)
    if(ch[i] == '#' && ch[i-1] != 'A' && ch[i+1] != 'A'){
      ch[i] = 'B';
      return ;
    }

  for(int i = 1; i <= n; ++i)
    if(ch[i] == '#'){
      ch[i] = 'B';
      break;
    }

  return ;
}

void funcC()
{
  bool f = true;
  for(int i = 1; i <= n && f; ++i)
    if(ch[i] != '#') f = false;

  if(f){
    int t = (n%2 == 0)? (n/2+1): ((n+1)/2);
    ch[t] = 'C';
    return ;
  }

  for(int i = 1; i <= n; ++i)
    if(ch[i] != '#'){
      if(i+1 <= n && ch[i+1] == '#'){
	ch[i+1] = 'C';
	break;
      }
      if(i-1 > 0 && ch[i-1] == '#'){
	ch[i-1] = 'C';
	break;
      }
    }

  return ;
}

void funcD()
{
  int a[102], p, s, t;
  fill(a, a+102, 0);

  for(int i = 1; i <= n; ++i){
    if(ch[i] == '#'){
      s = t = 0;
      p = i-1;
      while(0 < p && ch[p] == '#'){
	++s;
	--p;
      }
      if(p == 0) s = 100;

      p = i+1;
      while(p <= n && ch[p] == '#'){
	++t;
	++p;
      }
      if(p > n) t = 100;
      a[i] = min(s, t);
    } else {
      a[i] = -1;
    }
  }

  p = 1;
  for(int i = 2; i <= n; ++i)
    if(a[i] > a[p]) p = i;
  ch[p] = 'D';

  return ;
}

int main()
{
  char p;

  while(cin>>n>>m && (n+m)){
    fill(ch, ch+102, '#');
    while(m--){
      cin >> p;
      if(p == 'A') funcA();
      if(p == 'B') funcB();
      if(p == 'C') funcC();
      if(p == 'D') funcD();
    }

    for(int i = 1; i <= n; ++i) cout << ch[i];
    cout << endl;
  }

  return 0;
}

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

typedef long long ll;

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n = 0;
    cin >> n;
    vector<int> v(n, 0);
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }
    int m = 0;
    cin >> m;
    while(m --) {
        int a = 0, b = 0;
        cin >> a >> b;

        cout << sum - v[a - 1] + b << endl;;
    }



    
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  ll H,N;
  cin >> H >> N;
  vector<ll> A(N);
  ll res = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    res += A[i];
  }
  if(res >= H){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n;
        String str[];
        StringBuilder sb = new StringBuilder();
        while((n = Integer.parseInt(br.readLine()))!=0){
            str = br.readLine().split(" ");
            int score[] = new int[n];
            double m = 0,alpha = 0;
            for(int i=0;i<n;i++){
                score[i] = Integer.parseInt(str[i]);
                m += score[i];
            }
            m = m / n;
            for(int i=0;i<n;i++){
                alpha += Math.pow(score[i]-m, 2);
            }
            alpha = alpha / n;
            sb.append(String.format("%.8f", Math.sqrt(alpha))).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25260
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N;
ll A[5050];
vector<int> g[5050];

ll dp[5050][5050][2];
ll memo[5050][2];
int num[5050];
const ll INF=1e18;

void dfs(int now,int par){
  for(int next:g[now]){
    if(next==par) continue;
    dfs(next,now);
  }

  int sum=1;
  if(A[now]<0) dp[now][0][1]=A[now];
  else dp[now][0][0]=A[now];

  for(int next:g[now]){
    if(next==par) continue;
    for(int i=0;i<sum;i++){
      for(int j=0;j<num[next];j++){
        for(int k=0;k<2;k++){
          for(int l=0;l<2;l++){
            memo[i+j][k|l]=min(memo[i+j][k|l],dp[now][i][k]+dp[next][j][l]);

            if(dp[next][j][l]<0||(l==0&&dp[next][j][l]<INF)){
              memo[i+j+1][k]=min(memo[i+j+1][k],dp[now][i][k]);
            }
          }
        }
      }
    }

    sum+=num[next];
    for(int i=0;i<sum;i++){
      for(int k=0;k<2;k++){
        dp[now][i][k]=memo[i][k];
        memo[i][k]=INF;
      }
    }
  }
  num[now]=sum;
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  for(int i=1;i<N;i++){
    int u,v;
    cin>>u>>v;
    u--;v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  for(int i=0;i<=N;i++){
    for(int k=0;k<2;k++){
      for(int j=0;j<=N;j++){
        dp[i][j][k]=INF;
      }
      memo[i][k]=INF;
    }
  }

  dfs(0,-1);

  int ans=N-1;
  for(int i=0;i<N;i++){
    if(dp[0][i][0]<INF) ans=min(ans,i);
    if(dp[0][i][1]<0) ans=min(ans,i);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 396416
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	std::string a, b;
	std::cin >> a >> b;
	if (b.length() - a.length() == 0) {
		rep(i, a.length()) {
			std::cout << a[i] << b[i];
		}
		std::cout << std::endl;
		return 0;
	}
	else {
		rep(i, b.length()) {
			std::cout << a[i] << b[i];
		}
		std::cout <<a[a.length()-1] << std::endl;
		return 0;


	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<string,int>c;
    int n,i;
    string s;
    cin>>n;

   for(i=0;i<n;i++){
   cin>>s;
   c[s]++;
   }
    cout<<c.size()<<endl;
    return 0;
}


Measured memory_bytes: 19180
#!/usr/bin/env python3
#ABC71 C

from collections import Counter

n = int(input())
a = list(map(int,input().split()))

a = Counter(a)
a = list(a.items())

b = []

for i,j in a:
    if j >= 2:
        b.append(i)
        if j >= 4:
            b.append(i)
b.sort()
if len(b) < 2:
    print(0)
else:
    x = b[-1]
    y = b[-2]
    print(x*y)


Measured memory_bytes: 69912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();
		String[] string1 = line1.split(" ");
		int n = Integer.parseInt(string1[0]);
		int m = Integer.parseInt(string1[1]);
		int l = Integer.parseInt(string1[2]);

		String[][] gyouA = new String[n][m];
		int[][] A = new int[n][m];
		for (int i = 0; i < n; i++) {
			String line2 = sc.nextLine();
			for (int j = 0; j < m; j++) {
				String[] string = line2.split(" ");
				gyouA[i][j] = string[j];
				A[i][j] = Integer.parseInt(gyouA[i][j]);
			}

		}

		String[][] gyouB = new String[m][l];
		int[][] B = new int[m][l];
		for (int i = 0; i < m; i++) {
			String line3 = sc.nextLine();
			for (int j = 0; j < l; j++) {
				String[] string = line3.split(" ");
				gyouB[i][j] = string[j];
				B[i][j] = Integer.parseInt(gyouB[i][j]);
			}

		}

		long AB = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				long C = 0;
				for (int k = 0; k < m; k++) {
					AB = A[i][k] * B[k][j];
					C += AB;
				}
				if (j == l - 1) {
					System.out.print(C);

				} else {
					System.out.print(C + " ");

				}
			}
			System.out.println();
		}
	}
}

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

int main(){
    int h,w,i;
    string ans="",temp1="#",temp2="";
    while(1){
      cin>>h>>w;
      if (h==0&&w==0)break;
      else{
        for (i=0;i<w-2;i++)temp1+=".";
        temp1+="#\n";
        for (i=0;i<w;i++)temp2+="#";
        temp2+="\n";
        ans+=temp2;
        for (i=0;i<h-2;i++)ans+=temp1;
        ans+=temp2;
        cout<<ans<<endl;
        ans="";temp1="#";temp2="";
      }
    }
    return 0;
}




Measured memory_bytes: 3136
bingo = []
for _ in range(3):
    x,y,z = map(int,input().split())
    bingo.append((x,y,z))
n=int(input())
appear=[[False]*3 for i in range(3)]
b=[]
for _ in range(n):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        for k in range(len(b)):
            if bingo[i][j] == b[k]:
                appear[i][j] = True
ans = "No"
for i in range(3):
    if appear[i][0] and appear[i][1] and appear[i][2]:
        ans = "Yes"
for i in range(3):
    if appear[0][i] and appear[1][i] and appear[2][i]:
        ans = "Yes"
isdia = True
for i in range(3):
    if not appear[i][i]:
        isdia = False
if isdia:
    ans = "Yes"
isdia = True
j = 2
for i in range(3):
    if not appear[i][j-i]:
        isdia = False
if isdia:
    ans = "Yes"
print(ans)

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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<=n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define pii pair<int,int>
#define sz(v) ((int)(v).size())
#define get(a,st,en)  fl(i,st,en)       cin>>a[i]
#define pr(a,st,en)     fl(i,st,en)     cout<<a[i]<<" \n"[i==en]

const int MOD = 1e9+7;
void solve()    {
        int n;  cin>>n;
        map<int, int> mp;
        vector<int> arr(n);
        for(int i=0; i<n; i++)  {
                cin>>arr[i];
                mp[arr[i]]++;
        }
        int ans = n;
        for(int i=0; i<n; i++)  {
                for(int j=1; j*j<=arr[i]; j++)  {
                        if(arr[i]%j == 0)       {
                                if((mp[j]-(j==arr[i])) > 0)     {
                                        ans--;  break;
                                }
                                if((mp[arr[i]/j]-(arr[i]/j==arr[i])) > 0)       {
                                        ans--;  break;
                                }
                        }
                }
        }
        cout<<ans;
        
}
int main()  {
    fast;
    //test()
        solve();
}
// credits @Benq
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/



Measured memory_bytes: 32972
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int x;
    cin >> x;
    if(x == 25) puts("Christmas");
    else if(x == 24) puts("Christmas Eve");
    else if(x == 23) puts("Christmas Eve Eve");
    else if(x == 22) puts("Christmas Eve Eve Eve");
    
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   string s,t;
   cin>>s>>t;
   ll m=s.size();
   ll n=t.size();
   ll dp[m+1][n+1]={0};
   string s1;
   for(ll i=0;i<=m;i++)
   {
       for(ll j=0;j<=n;j++)
       {
           if(i==0||j==0)
            dp[i][j]=0;
           else if(s[i-1]==t[j-1])
           {
            dp[i][j]=1+dp[i-1][j-1];
           }
           else
           {
               dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
           }
       }
   }
  ll i=m;
  ll j=n;

  while(i>0&&j>0)
  {
      if(s[i-1]==t[j-1])
      {
          s1.push_back(s[i-1]);
          i--;
          j--;
      }
      else if(dp[i-1][j]>dp[i][j-1])
        i--;
      else
        j--;
  }
  reverse(s1.begin(),s1.end());
  cout<<s1;

}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    rep(i,s.size()) {
        if (!(i&1)) cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
      int a,b,c,d;cin>>a>>b>>c>>d;
      if((a+b)>(c+d))
       {
           cout<<"Left";
       }
       else if((a+b)<(c+d))
       {
           cout<<"Right";
       }
       else
       {
           cout<<"Balanced";
       }
       return 0;
}

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

struct Solver {
	void solve() {
		string S, T;
		cin >> S >> T;
		cout << (T.substr( 0, S.size() ) == S ? "Yes" : "No") << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3648
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
dp = []
for i in range(h):
    s = ns()
    c = 0
    lst = []
    for j in s:
        if j == '.':
            c += 1
        else:
            for k in range(c):
                lst.append(c)
            lst.append(0)
            c = 0
    for k in range(c):
        lst.append(c)
    dp.append(lst)

ans = 0
for i in range(w):
    a = 0
    c = 0
    for j in range(h):
        t = dp[j][i]
        if t == 0:
            a = max(t,a)
            ans = max(ans,a+c)
            a = 0
            c = 0
        else:
            a = max(t,a)
            c += 1
    ans = max(ans,a+c)

print(ans-1)

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

int main() {
	int N, v;
	cin >> N;
	vector<int> house(N);
	for (int i = 0; i < N; i++) {
		cin >> v;
		house[i] = v;
	}
	sort(house.begin(), house.end());
	cout << house.back() - house.at(0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> d(N,0);
    int sum=0;
    for(int i=0;i<N;i++){
        cin>>d[i];
        sum+=d[i];
    }
    int res=0;
    for(int i=0;i<N-1;i++){
        sum=sum-d[i];
        res+=(d[i]*sum);
    }
    cout<<res<<endl;
    return 0;
    
    
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include<iomanip>
#include <numeric>
#include <array>

using namespace std;

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

typedef long long ll;

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

int result[110][110];

void Main()
{
	int H, W, N; cin >> H >> W >> N;
	int a[10010];
	rep(i,N) cin >> a[i];
	vector<int> indices(N);
    iota(indices.begin(), indices.end(), 0);
	sort(indices.begin(), indices.end(), [&a](int i1, int i2) {
		return a[i1] > a[i2];
    });
	int current_y = 0; int current_x = 0;
	int direction = 1;
	rep(i,N) {
		rep(j,a[indices[i]]) {
			result[current_y][current_x] = indices[i] + 1;
			if ((direction == 1 && current_x + 1 == W) || (direction == -1 && current_x == 0)) {
				direction *= -1;
				++current_y; 
			} else {
				current_x += direction;
			}
		}
	}
	rep(i,H) {
		rep(j, W) {
			cout << result[i][j];
			if (j + 1 != W) cout << " ";
		}
		cout << endl;
	}
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;
constexpr intl mod = 1000000007;

intl modpow(intl a, intl n, intl p){
  intl res = 1;
  while (n > 0){
    if (n&1){res = (res * a) % p;}
	a = (a * a) % p;
    n >>= 1;
  }
  return res;
}

intl modinv(intl a, intl p){
  if (a == 0){
    cout << "/0 at modinv"<<endl;
    exit(0);
  }
  if (a < 0){
    cout << "/- at modinv" <<endl;
    exit(0);
  }
  if (a==1){return 1;}
  if (a > p){return modinv(a%p, p);}

  return p - ( modinv(p%a,p) * (p/a) ) % p;
}

intl modcomb(intl n, intl k, intl p){
  if (k > n || k < 0 || n < 0){
    cout << "error at modcomb"<<endl;
    exit(0);
  }
  if (2*k > n){ k = n-k;}
  if (k ==0){return 1;}
  intl c=1;
  for (intl i = 0; i < k; i++){
    c =( c * ( (n-i) % p ) % p ) * modinv(i+1,p) % p;
  }
  return c;
}

int main(){
  intl N;
  cin >>N;
  intl A,B,gcd;
  pi AB,_BA;
  map<pi,intl> sardine;
  intl zerocnt =0;
  Rep(i,N){
    cin >> A>>B;
    gcd = __gcd(A,B);
    if(B>0){ A /= gcd; B /= gcd;}
    else if( A>0 && B < 0){ A /= gcd; B /= gcd;}
    else if( A<0 && B < 0){ A /= gcd; B /= gcd;}
    else if(A==0 && B==0){zerocnt ++; continue;}
    else if(A==0)B=1;
    else if(B==0)A=1;
    
    AB = make_pair(A,B);
    if(sardine.count(AB)){sardine.at(AB) ++;}
    else{sardine[AB] =1;}
  }
  N -= zerocnt;
  
  //for(auto s: sardine){
  //  cout <<"{"<<s.fi.fi<<","<<s.fi.se<<"}"<<s.se<<endl;
  //}
  vpi discordpair;
  for(auto s: sardine){
    if(s.fi.fi <= 0){continue;}
    AB = s.fi;
    _BA = make_pair(-s.fi.se,s.fi.fi);
    if(sardine.count(_BA)){
      /*cout <<"{"<<AB.fi<<","<<AB.se<<"}"<<s.se<<endl;
      cout <<"{"<<_BA.fi<<","<<_BA.se<<"}"<<sardine.at(_BA)<<endl;*/
      discordpair.pub(make_pair(s.se,sardine.at(_BA)));
      N -= s.se;
      N -= sardine.at(_BA);
    }else{continue;}
  }
  intl ans=modpow(2,N,mod);
  for(auto d : discordpair){
    //cout <<"{"<<d.fi<<","<<d.se<<"}"<<endl;
    ans =ans*( ( modpow(2,d.fi,mod)-1 + modpow(2,d.se,mod)-1 +1  )%mod) %mod;
  }
  ans += zerocnt-1; 
  ans %= mod;
  if(ans < 0)ans += mod;
  cout <<ans;
}

Measured memory_bytes: 16044
#include <bits/stdc++.h>
using namespace std;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const long long &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
int s_len, t_len, dp[3000][3000];
char s[3001], t[3001];
int calc(int i, int j) {
	if(i >= s_len || j >= t_len) return 0;
	if(dp[i][j] != -1) return dp[i][j];
	int res = 0;
	res = max(res, calc(i + 1, j));
	res = max(res, calc(i, j + 1));
	if(s[i] == t[j]) res = max(res, calc(i + 1, j + 1) + 1);
	return dp[i][j] = res;
}
void trace(int i, int j) {
	if(i >= s_len || j >= t_len) {
		puts("");
		return;
	}
	if(calc(i, j) == calc(i + 1, j)) {
		trace(i + 1, j);
	} else if(calc(i, j) == calc(i, j + 1)) {
		trace(i, j + 1);
	} else if(s[i] == t[j] && calc(i, j) == calc(i + 1, j + 1) + 1) {
		printf("%c", s[i]);
		trace(i + 1, j + 1);
	} else {
		assert(0);
	}
}
int main() {
	R(s, t);
	s_len = strlen(s);
	t_len = strlen(t);
	memset(dp, -1, sizeof(dp));
	trace(0, 0);
	return 0;
}

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

#define FOR(i, a, b) for(int i=a; i<b; i++)
typedef long long ll;
typedef vector<ll> vl; 

vl *dp;
int n;
int *pairs[2];

ll get(int i, int capacity){
    if(capacity==0)
        return 0;
    if(i==n)
        return 0;
    if(dp[i][capacity]>=0){
        return dp[i][capacity];
    }
    
    ll x1=0;
    if(capacity>=pairs[0][i]){
        x1=pairs[1][i]+get(i+1, capacity-pairs[0][i]);
    }
    
    ll x2=get(i+1, capacity);
    if(x2>x1)
        x1=x2;
    dp[i][capacity]=x1;
    return x1;
}

int main(){
    ios_base::sync_with_stdio(false);
    int w;
    cin>>n>>w;
    // dp=new ll*[n];
    dp = new vl[n];
    FOR(i, 0, n){
        dp[i].resize(w+1, -1);
    }
    // memset(dp, -1, sizeof(ll)*n*(w+1));
    pairs[0]=new int[n];
    pairs[1]=new int[n];
    FOR(i, 0, n){
        cin>>pairs[0][i]>>pairs[1][i];
    }
    // FOR(i, 0, n){
    //     cout<<pairs[0][i]<<" "<<pairs[1][i]<<endl;
    // }
    
    cout<<get(0, w);
    return 0;
}

Measured memory_bytes: 78720
#include <stdio.h>

int a,b ;

int main(void){

    scanf ("%d%d",&a,&b) ;
    
    if ( a+b<10 ){
        printf ("%d\n",a+b) ;
        
    } else {
        printf ("error\n") ;
        
    }

    return 0 ;
    
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e5+17;
const int MOD = 1e9+7;
int dp[MAXN],nxt[MAXN][26+3],ocr[26+3];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif	
	string str;
	cin>>str;
	int n = str.length();
	for (int i = 0; i < 26; ++i)
	{
		ocr[i] = n;
	}
	for (int i = n-1; i > -1; --i)
	{
		ocr[str[i]-'a'] = i;
		for (int j = 0; j < 26; ++j)
		{
			nxt[i][j] = ocr[j];
		}
		dp[i] = MOD;
	}
	dp[n] = 1;
	for (int i = n-1; i > -1; --i)
		for (int j = 0; j < 26; ++j)
			dp[i] = min(dp[i],dp[nxt[i][j]+1]+1);
	for (int i = 0; dp[0]; --dp[0])
	{
		for (int j = 0; j < 26; ++j)
		{
			if(dp[i]==dp[nxt[i][j]+1]+1)
			{
				printf("%c",j+'a');
				i = nxt[i][j]+1;
				break;
			}
		}
	}
	return 0;	
}

Measured memory_bytes: 24068
from queue import Queue
n,q = map(int,input().split())
que = Queue()
for i in range(n):
    name,time = input().split()
    que.put((name,int(time)))
total = 0

while que.qsize() > 0:
    name,time = que.get()
    total += min(q,time)
    if q < time :
        que.put((name,time-q))
    else:
        print(name,total)

Measured memory_bytes: 15360
import bisect

from collections import deque

n,m,k = map(int,input().split())
        
a = list(map(int,input().split()))

b = list(map(int,input().split()))

aa = [0]*(n+1)

bb = [0]*(m+1)

for i in range(1,n+1):
    aa[i] += aa[i-1]+a[i-1]

for i in range(1,m+1):
    bb[i] += bb[i-1]+b[i-1]

count = 0

for i in range(n+1):
    if k < aa[i]:
        break
    serch = k-aa[i]
    index = bisect.bisect_right(bb, serch)
    index -= 1
    count = max(index+i,count)
print(count)

Measured memory_bytes: 121656
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main() {
  int s;
  cin>>s;
  
  
  cout<<s+s*s+s*s*s<<endl;
}




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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
   int h, w;
   int c[10][10];
   cin >> h >> w;
   for (int i = 0; i < 10; i++) 
      for (int j = 0; j < 10; j++) 
         cin >> c[i][j];

   for (int k = 0; k < 10; k++)
      for (int i = 0; i < 10; i++)
         for (int j = 0; j < 10; j++)
            c[i][j] = min(c[i][j], c[i][k] + c[k][j]);

   int ans = 0;
   for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
         int x;
         cin >> x;
         if (x == -1) continue;
         ans += c[x][1];
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
path = list([False] * n for _ in range(n))
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  path[a][b] = True
  path[b][a] = True
ans = 0
import itertools
for i in itertools.permutations(range(n),n):
  if i[0] == 0:
    for j in range(n):
      if j == n-1:
        ans += 1
        break
      if not path[i[j]][i[j+1]]:
        break
print(ans)
    
  
  

Measured memory_bytes: 3064