akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	long long a,b,i=0,sum=0;
	cin>>a>>b;
	for (;a<=b&&a>0;i++,sum++) a*=2;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    /*public static StreamTokenizer in;
    static {
        try{
            in = new StreamTokenizer(new BufferedReader(new InputStreamReader(new BufferedInputStream(System.in))));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public static int nextInt() throws IOException{ in.nextToken(); return (int)in.nval; }*/
    public static void main(String[] args) throws IOException{
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=b/a*a;
        if(b%a!=0)
            d+=a;
        if(c>=d)
            System.out.println("OK");
        else System.out.println("NG");
    }
}


Measured memory_bytes: 35756
#include<stdio.h>
#include<stdlib.h>
#define N 300
#define INF 300000  

int min(int,int);

main(){
  int i,j,k,l,q,n,d;
  int A[N],m[N][N];
  
  scanf("%d",&n);
  
  for(i = 1; i < n; i++){
    scanf("%d%d",&A[i],&d);
  }
  scanf("%d%d",&A[i],&A[i+1]);
 
  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }
 
  for(l = 2; l <= n+1; l++){
    for(i = 1; i <= n-l+2; i++){
      j = i + l - 1;
      m[i][j] = INF;
      for(k =i ; k <= j-1; k++){
    q = m[i][k] + m[k+1][j] + A[i-1] * A[k] * A[j];
    m[i][j] = min(m[i][j],q);
      }
    }
  }
  printf("%d\n",m[i][j]);
  
  return 0;
}

int min(int m, int q){
  if(m >= q) return q;
  else return m;
}

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

int main() {
  int p,q,r;
  cin >> p >> q >> r;
  cout << min(min(p+q, r+q), r+p)  << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//解説AC
int main() {
  ll n,w;
  cin >> n >>w;
  vector<vector<ll>> item(n+1,vector<ll>(2,0));
  vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));

  for (size_t i = 1; i <= n; i++)   //[i][0]が重さ [i][1]が価値
  {cin >> item[i][0]>>item[i][1];}

  for (size_t i = 1; i <= n; i++)//1-indexed
  {
    //品物iを選んだとして、選んだ方が価値が大きくなるならdp[i][w]を更新
      for (size_t j = 0; j <= w; j++)
      { if(j>=item[i][0])
        {ll weight=item[i][0];
        ll value =item[i][1];
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight]+value);}
        else
        {
          dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
        
      }
     //今までと、そのアイテムの重さ
  }

    cout << dp[n][w]<<endl;
    /*
    rep(i,n+1)
    { cout<<"dp["<<i<<"] : ";
      rep(j,w+1)
      {
        cout << dp[i][j] <<" ";

      }
      cout<<endl;
    }*/
    return 0;
  }


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

ll mod = MOD;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int mainsolve(){

	ll n,k;
	cin >> n >> k;

	vector<mint> res(k+1), d(k+1);

	for(ll i = k; i >= 1; i--){
		if(i == k){
			res[k] = 1;
			d[k] = 1;
			continue;
		}

		d[i] = k/i;
		d[i] = d[i].pow(n);

		res[i] = d[i];
		for(ll j = 2*i; j <= k; j += i){
			res[i] -= res[j];
		}
	}

	mint ans = 0;
	rep(i,k) ans += res[i+1] * (i+1);
	cout << ans << endl;
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
long long a[100100],gs[100100],ks[100100],s[100100];
int main()
{
	int i,n,q;
	long long x,ans;
	scanf("%d%d",&n,&q);
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	for(i=0;i<n;i++)
	{
		gs[i+1]=gs[i];
		ks[i+1]=ks[i];
		s[i+1]=s[i]+a[i];
		if(i%2==0)
			gs[i+1]+=a[i];
		else
			ks[i+1]+=a[i];
	}
	for(i=0;i<q;i++)
	{
		scanf("%lld",&x);
		int l=0,r=n,mid,tmp;
		while(l<r)
		{
			mid=(l+r)/2;
			tmp=lower_bound(a,a+n,x*2-a[mid])-a;
			if(mid-tmp<n-mid-1)
				l=mid+1;
			else
				r=mid;
		}
		ans=s[n]-s[l];
		if(n%2==0)
			ans+=ks[l*2-n];
		else
			ans+=gs[l*2-n];
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 4864
n = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7

S = [0]
for i in range(n):
  S.append(A[i] + S[i])

ans = 0

for i in range(n):
  tmp = A[i]
  s = S[n] - S[i+1]
  ans = (ans + (tmp * s) % mod) % mod
print(ans)

Measured memory_bytes: 31608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
  int n;
  cin >> n;
  
  int zero = 0;
  map<pair<ll,ll>,pair<int,int>> m;
  REP(i,n){
    ll a,b;
    cin >> a >> b;
    if(0 == a && 0 == b){
      zero++;
      continue;
    }
    ll g = __gcd(a,b);
    ll x = a/g;
    ll y = b/g;
    
    if(0 > y)x=-x, y=-y;
    if(0 == y && 0 > x)x=-x, y=-y;
    bool rot90 = false;
    if(0 >= x) rot90 = true;
    if(rot90){
      ll tmp=x;
      x = y;
      y = -tmp;
    }
    if(rot90){
      m[{x,y}].first++;
    }else{
      m[{x,y}].second++;
    }
  }
  
  mint ans = 1;
  for(auto p : m){
    int s = p.second.first;
    int t = p.second.second;
    mint now = 1;
    now += mint(2).pow(s)-1;
    now += mint(2).pow(t)-1;
    ans *= now;
  }
  ans -= 1;
  ans += zero;
  cout << ans << endl;
}

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

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

Measured memory_bytes: 256
n, m = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(m)]
count = 0

for x in edges:
    l = list(range(n))
    for y in edges:
        if y != x:
            l = [l[y[0]-1] if l[i] == l[y[1]-1] else l[i] for i in range(n)]
    if len(set(l)) != 1:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <stdio.h>
int main() {
	int n;
	double a[100], tar[100], cost[2] = { 0,0 },min=0;
	scanf("%d", &n);
	for (int i = 0;i < n;i++) {
		scanf("%lf", &a[i]);
	}
	for (int i = -100;i < 101;i++) { 
		for (int ii = 0;ii < n;ii++) {
			cost[0] = cost[0] + (a[ii] - i)*(a[ii] - i);
		}
		if(i==-100) min = cost[0]; 
		if (min > cost[0]) min = cost[0]; //min の更新
		cost[0] = 0;
	}
	printf("%0.0f\n", min);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=c-a,y=d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  float k,res=0;
    for(int i=0;i<n;i++)
    {
      cin>>k;
      res+=(1/k);
    }
  res=(1/res);
  cout << fixed << setprecision(13) <<res<<"\n";
 }

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

const long long MOD = 1000000007LL;

int main() {
    string s; cin >> s;
    int n = s.size();
    long long dp[n+1][13] = {};
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        int c;
        if (s[i] == '?') c = -1;
        else c = s[i] - '0';

        for (int j = 0; j < 10; j++) {
            if (c != -1 && c != j) continue;
            for (int k = 0; k < 13; k++) {
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
            }
        }
        for (int j = 0; j < 13; j++) {
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 10624
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main(){
        string s = Console.ReadLine();
        string pattern = @"^(dream|dreamer|erase|eraser)+$";
        Console.WriteLine(Regex.IsMatch(s, pattern) ? "YES" : "NO");
    }
}


Measured memory_bytes: 8060
#include <bits/stdc++.h>
const long long INF = 1e9;
const long long MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n) for(long long i=0;i<(n);++i)
#define REPR(i,n) for(long long i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

class union_find {
private:
    vector<ll> par;
    vector<ll> ran;
    vector<ll> m_size;
public:
    union_find(ll n);
    ll find(ll x);
    void unite(ll x, ll y);
    bool same(ll x, ll y);
    ll size(ll x);
};

union_find::union_find(ll n){
    par.resize(n);
    iota(par.begin(), par.end(), 0);
    ran.resize(n, 0);
    m_size.resize(n, 1);
};

ll union_find::find(ll x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (ran[x] < ran[y]) swap(x,y);
    par[y] = x;
    m_size[x] += m_size[y];
    if (ran[x]==ran[y]) ran[x]++;
};

ll union_find::size(ll x) {
    return m_size[find(x)];
}

bool union_find::same(ll x, ll y) {
    return (find(x) == find(y));
};


int main() {
    int n,q;
    cin >> n >> q;
    union_find uf(n);
    REP(i,q) {
        int c,x,y;
        cin >> c >> x >> y;
        if (c) cout << uf.same(x,y) << endl;
        else uf.unite(x,y);
    }
}


Measured memory_bytes: 3236
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int primax = 10000;
		int[] pri = new int[primax+100];
		for(int i=2;i<=primax;i++) pri[i] = i;
		for(int i=2;i<=primax+1;i++){
			for(int j=i+i;j<=primax;j+=i){
					pri[j]=0;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			for(int i=n;i>0;i--){
				if(pri[i]>0 && pri[i-2]>0){
					System.out.println((i-2) + " " + i);
					break;
				}
			}
		}
	}	
}

Measured memory_bytes: 33520
def smaller(x, y):
	if x < y:
		return x
	return y

N, Ma, Mb = map(int, input().split())
dp = []
for i in range(0, 401):
	lst = []
	for j in range(0, 401):
		lst.append(-1)
	dp.append(lst)
dp[0][0] = 0
for i in range(0, N):
	a, b, c = map(int, input().split())
	next = []
	for j in range(0, 401):
		for k in range(0, 401):
			if dp[j][k] != -1:
				if dp[j+a][k+b] == -1:
					next.append([j+a, k+b, dp[j][k]+c])
				else:
					if dp[j][k]+c == smaller(dp[j+a][k+b], dp[j][k]+c):
						next.append([j+a, k+b, dp[j][k]+c])
	for j in range(0, len(next)):
		if next[j][0] <= 400 and next[j][1] <= 400:
			dp[next[j][0]][next[j][1]] = next[j][2]
min = 5000000000000000
index = 1
while Ma*index <= 400 and Mb*index <= 400:
	if dp[Ma*index][Mb*index] != -1:
		min = smaller(min, dp[Ma*index][Mb*index])
	index += 1
if min == 5000000000000000:
	print(-1)
else:
	print(min)

Measured memory_bytes: 47836
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++)cin>>A[i];
    int dp[k+1]={0};
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(A[j]>i)
            break;

            dp[i] |= (1-dp[i-A[j]]); 
        }
    }
    if(dp[k])
    cout<<"First";
    else
    cout<<"Second\n";

return 0;
}

Measured memory_bytes: 4384
def count_paths(A, DP, N, M):
    DP[0][0] = 1
    for i in range(N):
        for j in range(M):
            if i==0 and j==0:
                DP[0][0] = 1
            else:
                if A[i][j] == '#':
                    DP[i][j] = 0
                else:
                    DP[i][j] = (DP[i-1][j]+DP[i][j-1])%(1000000007)
    return DP[N-1][M-1]
N, M = [int(s) for s in input().split(" ")]
A = []
DP = []
for i in range(N):
    DP.append([0]*M)
    z = [ch for ch in input()]
    A.append(z)
result = count_paths(A, DP, N, M)
print("{}".format(result))



Measured memory_bytes: 51540
import java.util.*;
import java.util.stream.*;

class Main{

	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();

		ArrayList<ArrayList<Integer>>g=new ArrayList<>(n);
		for(int i=0;i<n;++i)
			g.add(new ArrayList<>(1));

		int[] c=new int[n];
		for(int i=0;i<n-1;++i){
			int a=s.nextInt()-1;
			int b=s.nextInt()-1;
			++c[a];
			++c[b];
			g.get(a).add(b);
			g.get(b).add(a);
		}

		PriorityQueue<Integer> v=new PriorityQueue<>(Comparator.reverseOrder());
		for(int i=0;i<n;++i)
			v.add(s.nextInt());

		int root=IntStream.range(0,n).boxed()
				.max(Comparator.<Integer>comparingInt(i->c[i]))
				.get();

		int[] w=new int[n];
		f(root,w,v,g);

		{
			IntSummaryStatistics iss=Arrays.stream(w).summaryStatistics();
			System.out.println(iss.getSum()-iss.getMax());
		}
		System.out.println(Arrays.stream(w).mapToObj(String::valueOf)
				.collect(Collectors.joining(" ")));
	}

	private static void f(int root,int[] w,PriorityQueue<Integer> v, ArrayList<ArrayList<Integer>> g){
		w[root]=v.poll();
		for(int next:g.get(root)) {
			if(w[next]==0)
				f(next,w,v,g);
		}
	}
}

Measured memory_bytes: 47764
#include<bits/stdc++.h>
using namespace std;
int res;
 
int main()
{
    long long  ans=0,i,j,n,t,b,c;
    string s,s1,s2;
    cin>>t;
    int ara[t];
    for(i=0;i<t;i++)
    {
        cin>>ara[i];
 
    }
    int ret=ara[0];
     for(i=1;i<t;i++)
    {
       if(ara[i]>=ret)
        ret=ara[i];
       else
       {
           ans+=(ret-ara[i]);
 
       }
    }
    cout<<ans<<"\n";
 
    return 0;
}

Measured memory_bytes: 4376
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N, X, Y;
  cin >> N >> X >> Y;
  vector<int32_t> dist(N, 0);
  for (int s = 0; s < N; s++) {
    for (int e = s + 1; e < N; e++) {
      if (s <= X - 1 && e <= X - 1) {
        //cout << "T1:" << s << "," << e  << "," << e-s << endl;
        dist[e - s]++;
      } else if (s <= X - 1 && e <= Y - 1) {
        int32_t d = min(e - s, X- 1 - s + 1 + Y - 1 - e);
        //cout << "T2:" << s << "," << e  << "," << d << endl;
        dist[d]++;
      } else if (s <= X - 1) {
        //cout << "T3:" << s << "," << e  << "," << X-s+e-Y+1<< endl;
        dist[X-s+e-Y+1]++;
      } else if (s <= Y - 1 && e <= Y - 1) {
        int32_t d = min(e - s, s - (X-1) + 1 + Y - 1 - e);
        //cout << "T4:" << s << "," << e  << "," << d << endl;
        dist[d]++;
      } else if (s <= Y - 1) {
        int32_t d = min(e - s, s - (X-1) + 1 + e - (Y-1));
        //cout << "T5:" << s << "," << e  << "," << d << endl;
        dist[d]++;
      } else {
        //cout << "T6:" << s << "," << e << endl;
        dist[e - s]++;
      }
    }
  }
  for (int k = 1; k < N; k++) {
    cout << dist[k] << endl;
  }


  return 0;
}



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

using namespace std;

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

  int q, h, s, d;
  int64_t n;
  cin >> q >> h >> s >> d >> n;

  q *= 4;
  h *= 2;
  s = min(min(q, h), s);
  int64_t ans = min(n * s, (n / 2) * d + (n - (n / 2) * 2) * s);
  // cerr << n * one << '\n';
  // cerr << (n / 2) * d + (n - (n / 2) * 2) * one << '\n';

  cout << ans << '\n';

  return 0;
}


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

int gcd(int a,int b){
  if(a==0)return b;
  else  return gcd(b%a,a);
}

int main(){
  int a,s,k=0;
  cin >> a >>s;
  vector<int>b(a);
  for(int i=0;i<a;i++){
    cin >> b.at(i);
  }
  k=abs(b.at(0)-s);
  
  for(int i=0;i<a-1;i++){
    k=min(abs(s-b.at(i)),k);
  }
  for(int i=0;i<a-1;i++){
    
    if((abs(b.at(i+1)-b.at(i)))%k!=0 && k>gcd(abs(b.at(i+1)-b.at(i)),k)) k=gcd(abs(b.at(i+1)-b.at(i)),k);
  }
  cout << k << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>
#include<iostream>

int main(){
	int a = 0, b;
	for (int i = 0; i < 10; ++i){
		scanf("%d",&b);
		a += b;
	}
	printf("%d\n", a);
	
}

Measured memory_bytes: 1188
import sys
input = sys.stdin.readline

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

dp = [None]*N
dp[0] = 0
dp[1] = abs(H[0]-H[1])

for i in range(2, N):
    dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]))

print(dp[-1])

Measured memory_bytes: 14108
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
#define endl "\n"
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

 
ll mul_inv(ll a, ll b) {
    ll b0 = b, t, q;
    ll x0 = 0ll, x1 = 1ll;
    if (b == 1ll) return 1ll;
    while (a > 1ll) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0ll) x1 += b0;
    return x1;
}
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
#define varr2 vector<array<ll,2> >
#define varr3 vector<array<ll,3> >
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=2e5+2;





int main()
{ fastio;
//freopen("input.txt, "r", stdin); 
//freopen("output.txt", "w", stdout);

ll n,m;cin>>n>>m;
vector<set<ll> >gr(n);
forl(i,0,m){
    ll x,y;cin>>x>>y;
    x--;y--;
    gr[x].insert(y);
    gr[y].insert(x);
}
ll ans=0;
vll vis(n,0ll);
forl(i,0,n){
    if(vis[i]!=0)continue;
    vll k;
    k.pb(i);
    ll it=0;
    vis[i]=1;
    while(it!=k.S){
        for(auto x:gr[k[it]]){
            if(vis[x]==0){
                vis[x]=1;k.pb(x);
            }
        }

        it++;
    }
    ll f=k.S;
ans=max(ans,f);
}
p1(ans);



return 0;
}





  







Measured memory_bytes: 35012
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		Arrays.fill(a, -1);
		int len = 0;
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			int r = len;
			int l = -1;
			while(r-l>1) {
				int mid =(r+l)/2;
				if(a[mid] < b) r = mid;
				else l = mid;
			}
			a[r] = b;
			if(r == len) len++;
		}

		System.out.println(len);
		sc.close();
	}
}

Measured memory_bytes: 52228
from fractions import gcd


def factor(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n > 1:
        res.append(n)
    return res


A, B = map(int, input().split())
g = gcd(A, B)
print(len(set(factor(g))) + 1)


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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define fr(a,b) for(ll i=a;i<b;i++)

int32_t main(){
#ifdef _MSC_VER
    _CRT_SECURE_NO_WARNINGS
#endif
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
#pragma warning(suppress: 4101) srand(time(nullptr));
    cout << setprecision(20) << fixed;
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
     ll ans= max(max(a*d,b*d),max(a*c,b*c));
     cout<<ans<<endl;
    return 0;
}

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

int gcd(int a, int b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}

long long lcm(int a, int b) {
  long long c = a;
  c *= b;
  return c / gcd(a, b);
}

int main() {
  int a, b;
  cin >> a >> b;

  cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
  ll n,k; cin >> n >> k;
  ll count = 0;
  while(n >= k){
    n /= k;
    count++;
  }
  
  cout << count + 1 << endl;
}

Measured memory_bytes: 256
import math

num = int(input())
array = [int(x) for x in input().split()]

zero_array = array[0::2]
one_array = array[1::2]

if num % 2 == 0:
    one_array = one_array[:int(num/2)]
    pick = one_array[::-1] + zero_array[:int(num/2)]
else:
    one_array = one_array[:int(num/2)]
    pick= one_array[::-1] + zero_array[:math.ceil(num/2)]

if num % 2 == 0:
    print(" ".join(map(str, pick)))
else:
    print(" ".join(map(str, pick[::-1])))


Measured memory_bytes: 33468
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC82(void);
void ABC83(void);
void ABC84(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC86();
}

void ABC86(){
    int a,b,c=1,bk,i,ans=0;
    cin>>a>>b;
    bk=log(b)/log(10)+1;
    for(i=0;i<bk;i++){
        c*=10;
    }
    c=c*a+b;
    cerr<<c<<endl;
    for(i=1;i<=1000;i++){
        if(i*i==c)ans=1;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t,a,h,ans;
	double anstmp=1e9;
	cin>>n>>t>>a;
	for(int i=0;i<n;i++){
		cin>>h;
		if(abs(t-h*0.006-a)<abs(anstmp-a)){
			ans=i+1;
			anstmp=t-h*0.006;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()

# MOD Kでの値を集計
C = Counter()
for a in range(1, N+1):
    C[a%K] += 1

# aを決め打ちして全探索
ans = 0
for a in range(K):
    b = (K - a) % K
    c = (K - a) % K
    if (b + c) % K == 0:
        ans += C[a] * C[b] * C[c]
print(ans)


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, m;
	ll ans = 0;

	cin >> n >> m;

	vector<pair<ll, bool>> v(n, make_pair(1, false));

	v[0] = make_pair(1, true);

	REP(i, m) {
		ll x, y;
		cin >> x >> y;
		if (v[x - 1].first == 1) {
			if (v[x - 1].second) {
				v[x - 1] = make_pair(0, false);
				v[y - 1] = make_pair(v[y - 1].first + 1, true);
			}
			else {
				v[x - 1] = make_pair(0, false);
				v[y - 1] = make_pair(v[y - 1].first + 1, v[y - 1].second);
			}
		}
		else if (v[x - 1].second) {
			v[x - 1] = make_pair(v[x - 1].first - 1, true);
			v[y - 1] = make_pair(v[y - 1].first + 1, true);
		}
		else {
			v[x - 1] = make_pair(v[x - 1].first - 1, false);
			v[y - 1] = make_pair(v[y - 1].first + 1, v[y - 1].second);
		}
	}

	REP(i, n) {
		if (v[i].second) {
			ans++;
		}
	}

	cout << ans << endl;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    for(int i = 0; i < n; i++)cin >> m[i];
    x -= accumulate(m.begin(), m.end(), 0);
    cout << x / *min_element(m.begin(), m.end()) + n << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
long long int a[6],p,s,j,h;
  
  for(p=0;p<6;p++)
  {
  cin >> a[p];
  }
  
  for(p=1;p<5;p++)
  {
  for(s=p+1;s<6;s++)
  {
    if(a[p]>a[s]){
    j=a[p];
      a[p]=a[s];
      a[s]=j;
    }
  }
  }
  if(a[0]>a[1]){
    
  h=4+(a[0]/a[1]);
    
  if((a[0]%a[1])==0)
  {
  cout << h << endl;
  }
    
  else if((a[0]%a[1])!=0)
  {
  cout << h+1 << endl;
  }
    return 0;
  }
  
  cout << 5 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	rep(i,0,10000){
		int a,b; char c;
		cin>>a>>c>>b;
		if(c=='?')return 0;
		if(c=='+')cout<<a+b<<endl;
		else if(c=='/')cout<<a/b<<endl;
		else if(c=='-')cout<<a-b<<endl;
		else cout<<a*b<<endl;
		
	}


	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main() {
    int n, r;
    string s;
    vector<string> str;
    int top = 1;
    int front = 2;
    int left = 3;
    int _top, _left, _front;
    while (cin >> n, n != 0) {
        top = 1;
        front = 2;
        left = 3;
        int res = 1;
        for (int i = 0; i < n; i++) {
            cin >> s;
            _top = top;
            _left = left;
            _front = front;
            if (s == "North") {
                _top = front;
                _front = 7 - top;
            }
            if (s == "East") {
                _top = 7 - left;
                _left = top;
            }
            if (s == "West") {
                _top = left;
                _left = 7 - top;
            }
            if (s == "South") {
                _top = 7 - front;
                _front = top;
            }
            if (s == "Right") {
                _left = 7- front;
                _front = left;
            }
            if (s == "Left") {
                _left = front;
                _front = 7 - left;
            }
            top = _top;
            left = _left;
            front = _front;
            res += top;
        }
        cout << res << endl;
    }
}

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

using namespace std;

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

    using ll = long long;

    vector<ll> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    const ll inf = 1LL << 60;

    vector<vector<ll>> dp(n, vector<ll>(n, inf));

    for (int i = 0; i < n; i++) {
        dp[0][i] = 0;
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j + i < n; j++) {
            ll s = 0;
            for (int k = 0; k <= i; ++k) {
                s += a[j + k];
            }

            for (int k = 0; k < i; k++) {
                dp[i][j] = min(dp[i][j], dp[k][j] + dp[i - k - 1][j + k + 1]);
            }

            dp[i][j] += s;
        }
    }

    cout << dp[n - 1][0] << endl;
}


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

using namespace std;

int main() {

	while(1){
	int h;
	cin >> h;
	if (h == 0) { break; }
	vector<deque<int>> p(5, deque<int>());
	int score = 0;

	for (int i = 0; i < h; i++) {
		int in1;
		for (int j = 0; j < 5; j++) {
			cin >> in1;
			p[j].push_front(in1);
		}
	}

	while (1) {
		bool chgflg = false;

		for (int i = 0; i < h; i++) {

			int ernum, ernumcount;
			map<int, int> counter;

			//横に並んだ数字カウント
			for (int j = 0; j < 5; j++) {
				counter[p[j].at(i)]++;
			}
			//3つ以上を記憶する
			ernum = -1;
			for (int j = 1; j <= 9; j++) {
				if (counter[j] >= 3) {
					ernum = j;
					ernumcount = counter[j];
					break;
				}
			}
			if (ernum == -1) { continue; }

			//繋がってるか判定&ポイント追加
			if (ernumcount == 3) {
				for (int j = 0; j < 3; j++) {
					if (p[j].at(i) == ernum
						&& p[j + 1].at(i) == ernum
						&& p[j + 2].at(i) == ernum) {
						score += ernum * 3;
						p[j].at(i) = -1;
						p[j + 1].at(i) = -1;
						p[j + 2].at(i) = -1;
						chgflg = true;
						break;
					}
				}

			}
			else if (ernumcount == 4) {
				int chigauposi = -1;
				for (int j = 0; j < 5; j++) {
					if (p[j].at(i) != ernum) {
						chigauposi = j;
					}
				}

				if (chigauposi == 0) {
					chgflg = true;
					score += ernum * 4;
					p[1].at(i) = -1;
					p[2].at(i) = -1;
					p[3].at(i) = -1;
					p[4].at(i) = -1;
				}
				else if (chigauposi == 4) {
					chgflg = true;
					score += ernum * 4;
					p[0].at(i) = -1;
					p[1].at(i) = -1;
					p[2].at(i) = -1;
					p[3].at(i) = -1;
				}
				else if (chigauposi == 1) {
					chgflg = true;
					score += ernum * 3;
					p[2].at(i) = -1;
					p[3].at(i) = -1;
					p[4].at(i) = -1;
				}
				else if (chigauposi == 3) {
					chgflg = true;
					score += ernum * 3;
					p[0].at(i) = -1;
					p[1].at(i) = -1;
					p[2].at(i) = -1;
				}

			}
			else if (ernumcount == 5) {
				chgflg = true;
				score += ernum * 5;
				p[0].at(i) = -1;
				p[1].at(i) = -1;
				p[2].at(i) = -1;
				p[3].at(i) = -1;
				p[4].at(i) = -1;
			}

		}

		if (chgflg == false) { break; }

		//消去
		for (int i = h - 1; i >= 0; i--) {
			for (int j = 0; j < 5; j++) {
				if (p[j].at(i) == -1) {
					p[j].erase(p[j].begin() + i);
					p[j].push_back(0);
				}
			}
		}
	}

	cout << score << endl;
}
	return 0;

}


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

string alp = "01+-*()";
void search(int cnt, string &curr, vector<string> &res){
    if(cnt == 0){
        res.push_back(curr);
        return;
    }
    for(char c: alp){
        curr += c;
        search(cnt-1, curr, res);
        curr.pop_back();
    }
}

bool is_operator(char c){
    return c=='+' or c=='-' or c=='*';
}

int parse(int b, int e, string &s){
    vector<int> nums;
    vector<char> opes;
    enum type{num, ope, brac};
    type prevtype = ope;
    int currnum = 0;
    for(int p=b; p<e; p++){
        if(prevtype == ope and is_operator(s[p])) return -1;
        if(prevtype == brac and !is_operator(s[p])) return -1;
        if(s[p] == ')') return -1;
        if(prevtype != ope and s[p] == '(') return -1;
        
        if(is_operator(s[p])){
            nums.push_back(currnum);
            opes.push_back(s[p]);
            currnum = 0;
            prevtype = ope;
        }else if(s[p] == '('){
            int depth = 1;
            int beginpos = ++p;
            while(p < e){
                if(s[p]=='(') depth++;
                if(s[p]==')') depth--;
                if(depth==0) break;
                p++;
            }
            if(p==e and depth>0) return -1;
            currnum = parse(beginpos, p, s);
            if(currnum == -1) return -1;
            prevtype = brac;
        }else{
            currnum *= 2;
            currnum += s[p]-'0';
            if(currnum >= 1024) return -1;
            prevtype = num;
        }
    }
    if(prevtype == ope) return -1;
    nums.push_back(currnum);

    if(b == e) return -1;
    if((b!=0 or e!=(int)s.length()) and opes.empty()) return -1;
    vector<int> newnums;
    vector<int> newopes;
    newnums.push_back(nums[0]);
    for(int i=0; i<(int)opes.size(); i++){
        if(opes[i] == '*'){
            newnums.back() *= nums[i+1];
            if(newnums.back() >= 1024) return -1;
        }else{
            newopes.push_back(opes[i]);
            newnums.push_back(nums[i+1]);
        }
    }
    int res = newnums[0];
    for(int i=0; i<(int)newopes.size(); i++){
        if(newopes[i] == '+'){
            res += newnums[i+1];
        }else{
            res -= newnums[i+1];
        }
        if(res<0 or 1024<=res) return -1;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    vector<int> dots_idx;
    for(int i=0; i<(int)s.length(); i++){
        if(s[i] == '.') dots_idx.push_back(i);
    }

    vector<string> filling;
    string tmp = "";
    search(dots_idx.size(), tmp, filling);
    int ans = -1;
    for(string fil: filling){
        for(int i=0; i<(int)dots_idx.size(); i++){
            s[dots_idx[i]] = fil[i];
        }
        ans = max(ans, parse(0, s.length(), s));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3980
#include<stdio.h>
 
int D[107][7],i,j,N;
int G[55][6]={
    {1,2,3},{1,3,5},{1,5,4},{1,4,2},
    {2,1,4},{2,4,6},{2,6,3},{2,3,1},
    {3,1,2},{3,2,6},{3,6,5},{3,5,1},
    {4,1,5},{4,2,1},{4,6,2},{4,5,6},
    {5,1,3},{5,3,6},{5,4,1},{5,6,4},
    {6,2,4},{6,4,5},{6,5,3},{6,3,2}};
 
int ch(int a,int b)
{
    int i;
    for(i=0;i<24;i++)
    {
        if(D[a][1]==D[b][G[i][0]]&&
           D[a][2]==D[b][G[i][1]]&&
           D[a][3]==D[b][G[i][2]]&&
           D[a][6]==D[b][7-G[i][0]]&&
           D[a][5]==D[b][7-G[i][1]]&&
           D[a][4]==D[b][7-G[i][2]])
        return 1;
    }
    return 0;
}
 
int main()
{
    scanf("%d",&N);
    for(i=0;i<N;i++)
        for(j=1;j<=6;j++)
            scanf("%d",&D[i][j]);
    for(i=0;i<N;i++)
        for(j=i+1;j<N;j++)
        {
            if(ch(i,j))
            {
                puts("No");
                return 0;
            }
        }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2096
n = int(input())
p = list(map(int,input().split()))

ans = 0
n_min = 0
for i in range(0,n):
    if i == 0:
        ans += 1
        n_min = p[i]
        continue
    if p[i] <= n_min:
        ans += 1
        n_min = p[i]
print(ans)

Measured memory_bytes: 24744
H,W,D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [tuple(map(int, input().split())) for _ in range(Q)]

num = [None] * (H*W)
for i in range(H):
    for j in range(W):
        num[A[i][j] - 1] = (i,j)


accum = [0] * (H*W)

for i in range(D):
    j = 0
    while i + j*D <= (H*W) - 1:
        if j == 0:
            accum[i + j*D] = 0
        else:
            curr = i + j*D
            prev = i + (j-1)*D
            accum[curr] = accum[prev] + abs(num[prev][0] - num[curr][0]) + abs(num[prev][1] - num[curr][1])

        j += 1

for l,r in LR:
    print(accum[r-1] - accum[l-1])

    

Measured memory_bytes: 31396
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, ans, z[5009];
string s;

void fun(int a)
{
	int cur = 0;
	while (a + 1 + cur < n && s[a + cur] == s[a + 1 + cur]) {
		cur++;
	}
	z[a + 1] = cur;
	ans = max(ans, min(z[a + 1], 1));
	int l = a + 1, r = a + 1 + cur;
	for (int i = a + 2; i < n; i++) {
		if (r < i) {
			cur = 0;
			while (i + cur < n && s[a + cur] == s[i + cur]) {
				cur++;
			}
			z[i] = cur;
			l = i; r = i + cur;
		}
		else {
			int k = z[a + i - l];
			if (i + k < r) {
				z[i] = k;
			}
			else {
				l = i;
				while (r < n && s[r] == s[a + r - i]) {
					r++;
				}
				z[i] = r - l;
			}
		}
		ans = max(ans, min(z[i], i - a));
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (int i = 0; i < n - 1; i++) {
		fun(i);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

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

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

  ll H; cin >> H;
  ll N; cin >> N;
  vector<ll> A(N, 0), B(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  ll AMAX = *max_element(A.begin(), A.end());

  ll INF = 1e15;
  vector<vector<ll>> dp(N + 1, vector<ll>(H + AMAX + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    dp[i + 1][0] = 0;
    for (int j = 0; j <= H + AMAX; j++) {
      if (j < A[i]) {
        dp[i + 1][j] = min(dp[i][j], B[i]);
      } else {
        dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
      }
    }
  }

  // for (int i = 0; i < dp.size(); i++) { cout << dp[i][0]; for (int j = 1; j < dp[i].size(); j++) { cout << ' ' << dp[i][j]; } cout << '\n'; }
  
  cout << dp[N][H] << '\n';
  return 0;
}

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

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var count = 0;
            for(int i = 0; i < 3; i++)
            {
                if (s[i] == t[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int N = 405;
int n;
long long a[N], sum[N][N], dp[N][N];
int main(int argc, char const *argv[])
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		long long s = 0;
		for (int j = i; j < n; ++j)
		{
			s += a[j];
			sum[i][j] = s;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		dp[i][i] = 0;
	}
	for (int len = 2; len <= n; ++len)
	{
		for (int start = 0; start <= n - len; ++start)
		{
			int end = start + len - 1;
			dp[start][end] = dp[start][end - 1] + sum[start][end];
			for (int j = end - 1; j > start; --j)
			{
				dp[start][end] = min(dp[start][end], dp[start][j - 1] + dp[j][end] + sum[start][end]);
			}
		}
	}
	cout << dp[0][n - 1];
	return 0;
}

Measured memory_bytes: 2816
# coding: utf-8

N, M = map(int, input().split())
p_dict = {}
for i in range(M):
    p, y = map(int, input().split())
    if p not in p_dict.keys():
        p_dict[p] = [[y, p, i]]
    else:
        # yとp元の順番を入れとく
        p_dict[p].append([y, p, i])
ans = []
for p in p_dict.keys():
    p_dict[p].sort()
    for i in range(len(p_dict[p])):
        # 昇順で並べたときの順番を入れとく
        p_dict[p][i].append(i+1)
        ans.append(p_dict[p][i])
# ans = [y, p, input_index, sorted_index]
ans.sort(key=lambda x: x[2])
for y, p, oi, si in ans:
    print("{:06d}{:06d}".format(p, si))


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n,ans=-2e9;
    cin>>n;
    int f[105][10],p[105][11];
    m0(f);
    m0(p);

    for(int i = 0; i < n; i++)
    {        
        for(int j = 0; j < 10; j++)
        {
            cin>>f[i][j];
        }        
    }
    
    for(int i = 0; i < n; i++)
    {        
        for(int j = 0; j < 11; j++)
        {
            cin>>p[i][j];
        }        
    }
    
    for(int bit = 1; bit < (1<<10); bit++)
    {
        int cnt[105];
        int tmp=0;
        m0(cnt);
        
        for(int day = 0; day < 10; day++)
        {
            if(((bit>>day)&1)==1)
            {
                for(int store = 0; store < n; store++)
                {
                    if(f[store][day]==1)
                    {
                        cnt[store]++;
                    }
                }
            }
        }
        
        for(int store = 0; store < n; store++)
        {
            tmp+=p[store][cnt[store]];
        }
        ans=max(ans,tmp);
    }
    

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

using namespace std; 

int main() {
    set<string> s;
    string t;
    int n = 0;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> t;
        s.insert(t);
    }
    if(s.size() == 4){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
    
    return 0; 
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19
constexpr static double EPS = 1e-10;

int main() {
    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b)) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int count = 0;
        for (int i = 0 ; i <= a ; i++) {
            for (int j = 0 ; j <= b ; j++) {
                for (int k = 0 ; k <= c ; k++) {
                    if (500 * i + 100 * j + 50 * k == x) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);

    }

}

Measured memory_bytes: 21844