akhauriyash/Code-Regression huggingface dataset:
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
const int MAXN = 3e5 + 10 , MOD = 998244353;
int n , a , b , k , j , ans , fact[MAXN] , inv[MAXN] , finv[MAXN];
void fac()
{
	///base
	fact[0] = fact[1] = finv[0] = finv[1] = inv[1] = 1;
	///update
	for(int i = 2 ; i < MAXN ; i ++)
		fact[i] = fact[i - 1] * i % MOD , inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD , finv[i] = finv[i - 1] * inv[i] % MOD;
	return;
}
int choose(int n , int k)
{
	if(n < k || n < 0 || k < 0)
		return 0;
	return fact[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int32_t main()
{
	cin >> n >> a >> b >> k , fac();
	for(int i = 0 ; i <= n ; i ++)
		if(i * a <= k and !((k - a * i) % b) and (k - a * i) / b <= n)
			j = (k - a * i) / b , (ans += choose(n , i) * choose(n , j)) %= MOD;
	return cout << ans << endl , 0;
}


Measured memory_bytes: 7296
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<set>
#include<queue>
#include<string>
#include<sstream>
#include<iostream>
#include<sstream>
#include<stack>
#include<map>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
	int i,j,a[60];
	int n=0;
	for (i = 3; i <= 55555; i++)
	{
		int flag = 1;
		for (j = 2; j <= sqrt(i); j++)
		{
			if (i%j == 0)flag = 0;
		}
		if (flag==1&&i % 5 == 1)
		{
			a[n] = i;
			n++;
			if (n > 55)break;
		}
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		printf("%d", a[i]);
		if (i != n - 1)printf(" ");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,a;
    while(cin>>n){
        int f=1;
        for(int i=0;i<n;i++){
            cin>>a;
            if(a%2==0){
                if(a%3!=0 && a%5!=0)
                    f=0;
            }
        }
        f?cout<<"APPROVED"<<endl:cout<<"DENIED"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[4100];
int n,m;
int main()
{
    //cout<<(1<<1)<<" "<<(1<<0);
    scanf("%d%d",&n,&m);
    int sum=(1<<n);
    for(int i=0;i<sum;i++)
        dp[i]=1e9;
    dp[0]=0;
    while(m--)
    {
        int t=0;
        int a,b;
        scanf("%d%d",&a,&b);
        while(b--)
        {
            int x;
            scanf("%d",&x);
            x=(1<<--x);
            t|=x;
        }
        for(int i=0;i<sum;i++)
            dp[i|t]=min(dp[i]+a,dp[i|t]);
    }
    printf("%d",dp[sum-1]==1e9?-1:dp[sum-1]);
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abk = scanner.nextLine().split(" ", 3);
        long a = Long.parseLong(abk[0]);
        long b = Long.parseLong(abk[1]);
        long k = Long.parseLong(abk[2]);

        long firstEnd = Math.min(b, a + k - 1);
        for (long i = a; i <= firstEnd; i++) {
            System.out.println(i);
        }
        for (long i = Math.max(b - k + 1, firstEnd + 1); i <= b; i++) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 25044
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
	public class QuestionA
	{
		public static void Main(string[] args)
		{
			// 整数の入力
			int a = int.Parse(Console.ReadLine());
			int b = int.Parse(Console.ReadLine());
			int h = int.Parse(Console.ReadLine());

			Console.WriteLine((a + b) * h / 2);

		}
	}
}


Measured memory_bytes: 27196
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans=0;
ll x[100005],y[100005],z[100005];
float st;
stack <ll> ana;


ll digi(ll x){
	ll nono=0;
	while(x>0){
		nono += x%10;
		x/=10;
	}
	return nono;
}
int main(){
	cin>>n;
	x[1]=1;
	st=INF;
	for(i=1000000000000000;i>=1;i--){
		if((float)(i*1.000/digi(i))<=st){
			ana.push(i);
			st = i*1.000/digi(i);
		}
		if(i>=1000000000000 && i%10000000000 == 9999999999)i-=9999999999;
		if(i>=100000000 && i%1000000 == 999999)i-=999999;
		if(i>=1000000 && i%10000 == 9999)i-=9999;
		if(i>=10000 && i%100==99)i-=98;
	}
	while(n>0){
		p(ana.top());
		ana.pop();
		n--;
	}
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;

int n;
int main() {
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>n;
    bool judge=(n>=30);
    if(judge) cout<<"Yes";
    else cout<<"No";
    return 0;
}




Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int a[n], b[n];
	set<int> s;
	rep(i,0,n){
		cin >> a[i];	
		b[i] = a[i];
	}
	sort(b,b+n);
	rep(i,0,n){
		if(i&1){
			s.insert(b[i]);
		}
	}
	int ans = 0;
	rep(i,0,n){
		if(i % 2 == 0){
			ans += s.count(a[i]);
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int cnt = 0;
	int ssize = s.size();
	int n = ssize / 2;
	if (ssize % 2 == 0) {
		if (s[n] != s[n - 1]) {
			cout << n << endl;
			return 0;
		} else {
			for (int i = 0; i <= n; i++) {
				if (s[n] == s[n + i] && s[n - 1] == s[n - 1 - i]) {
					cnt++;
				} else {
					break;
				}
			}
			cout << n + cnt << endl;
			return 0;
		}
	} else {
		for (int i = 0; i <= n; i++) {
			if (s[n] == s[n + i] && s[n] == s[n - i]) {
				cnt++;
			} else {
				break;
			}
		}
		cout << n + cnt << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,last) for (int i=0;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define prints(str) cout << str << " ";
#define printn(str) cout << str << endl;
 
typedef long long ll;
 
ll table_comb[51][51];
 
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<ll> v(N);
  REP(i,N){ cin >> v[i]; }
  sort(v.begin(), v.end(), greater<ll>());
 
  double max_average = 0;
  REP(i,A){
    max_average += v[i];
  }
  max_average /= A;
  cout << fixed << max_average << endl;
 
  REP(i,N+1){
    for (int j=0;j<=i;++j) {
      if (i == 0 || j == 0) {
        table_comb[i][j] = 1;
      } else {
        table_comb[i][j] = table_comb[i-1][j-1] + table_comb[i-1][j];
      }
    }
  }
 
  if (v[0] != v[A]) {
    if (v[A-1] != v[A]) {
      printn(1);
    } else {
      int bigger = 0;
      int cnt = 0;
      REP(i,N){
        if (v[A-1] < v[i]) ++bigger;
        if (v[i] == v[A-1]) ++cnt;
      }
      ll ans = table_comb[cnt][A-bigger];
      printn(ans);
    }
  } else {
    int cnt = 0;
    REP(i,N){
      if (v[i] < v[0]) break;
      ++cnt;
    }
    ll ans = 0;
 
    for (int i=A;i<=B;++i) {
      if (i <= cnt) {
        ans += table_comb[cnt][i];
      }
    }
    printn(ans);
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define true 1
#define false 0
#define N 10000

int isprime(int);

int main(){
  int n, cnt = 0;
  int a[N];
  int i;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }

  for(i=0;i<n;i++){
    cnt += isprime(a[i]);
  }

  printf("%d\n", cnt);
}

int isprime(int x){
  int i;
  
  if(x == 2) return true;

  if(x < 2 || x % 2 == 0) return false;

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0) return false;
    i = i + 2;
  }

  return true;
}



Measured memory_bytes: 2128
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int one=0;
        int zero=0;
        
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='0'){
                zero++;
            }else{
                one++;
            }
        }
        
        if(zero<one){
            System.out.println(zero*2);
        }else{
            System.out.println(one*2);
        }
   }
}


Measured memory_bytes: 39448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,j,i,ans=1;
    set<string>s;
    string str;
    cin>>n;
    for(int k=0; k<n; k++)
    {
        cin>>str;
    s.insert(str);
    }


   /* vector<string>s;
    cin>>str;
    string str;
    s.push_back(str);
    {
        cin>>str;

        for(i=0; i<s.size(); i++)
        {
            if(s.at(i)==str)
            {
                break;
            }
            else
            {
                s.push_back(str);
                //ans++;
                break;
            }
        }

    }
    */
    cout<<s.size()<<endl;
    return 0;
}




Measured memory_bytes: 19124
#include <iostream>

using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    int a=n,b=0;
    while(n>0){
        b+=n%10;
        n/=10;
    }
    if(a%b==0){
        cout <<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def solve():
    Q, H, S, D = [int(i) for i in input().split()]
    P = [(250, Q), (500, H), (1000, S), (2000, D)]
    P.sort(key=lambda t: t[1] / t[0])
    N = int(input()) * 1000
    ans = 0
    for p in P:
        if N == 0:
            break
        x, y = p
        n = int(N / x)
        ans += n * y
        N -= n * x
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 61820
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

ll mod(ll a)
{
	if(a<inf)return a;
	else 
	return a%inf;
}
 void test_cases()
{

ll n;
cin>>n;

ll f=n/15;

ll x=n*800,y=200*f;

cout<<x-y;


}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


Measured memory_bytes: 3660
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
//const ll MOD = INF + 7;
//Combination MOD
const ll MOD = INF + 7;
const ll SMX = 1e5 * 6;
vector<ll> fac(SMX);
vector<ll> fac_inv(SMX);

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;

    ll tmp = fac_inv[a - b] * fac_inv[b] % MOD;
    return tmp * fac[a] % MOD;
}
   
     
int main(){
   fac[0] = 1;
   fac_inv[0] = 1;
   for(ll i = 0; i < SMX; i++){
       fac[i + 1] = fac[i] * (i + 1) % MOD;
       fac_inv[i + 1] = fac_inv[i] * mpow(i + 1, MOD - 2) % MOD;
   }
 
   ll n, m;
   cin >> n >> m;
   ll sum = 0;
   rep(i, m + 1){
      ll s;
      
      if(m - i < 0 || n - i < 0)break;
      s = ((comb(m - i, n - i) * fac[n - i]) % MOD * comb(n, i)) % MOD;

      //if(s <= 0)break;
      if(i % 2 == 0)sum = (sum + s) % MOD;
      else sum = (sum - s) % MOD;
     if(sum < 0)sum += MOD;
     //cout << s << endl;
   }
   //cout << sum << endl;
  ll base = 1;
   
   base = (comb(m, n) * fac[n]) % MOD;
   if(base < 0)base += MOD;
   //cout << base << endl;
   ll res = (base * sum) % MOD;
   if(res < 0)res += MOD;
   //cout << base << " " << sum << endl;
  cout << res << endl;
}

Measured memory_bytes: 12680
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int N=1e5+7;
int fri[N];
int ans[N],sum[N];
int find(int x){
	return fri[x]==x?x:fri[x]=find(fri[x]);
}
void join(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx!=fy){
		fri[fy]=fx;
		sum[fx]+=sum[fy];
	}
}
int n,m,k;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;i++){
		fri[i]=i;
		sum[i]=1;
	}
	while(m--){
		int a,b;
		scanf("%d%d",&a,&b);
		ans[a]++;
		ans[b]++;
		join(a,b);
	}
	while(k--){
		int a,b;
		scanf("%d%d",&a,&b);
		if(find(a)==find(b)){
			ans[a]++;
			ans[b]++;
		}
	}
	for(int i=1;i<=n;i++)printf("%d ",sum[find(i)]-ans[i]-1);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define sc1(x) scanf("%d", &x)
#define sc2(x, y) scanf("%lld%lld", &x, &y)
#define sc3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define pr(x) printf("%lld\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 100010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
ll n, s;
int main()
{
	//freopen("math.in", "r", stdin);
	//freopen("math.out", "w", stdout);
	scanf("%lld%lld", &n, &s);
	if (s == n)
	{
		printf("%lld\n", s + 1);
		return 0;
	}
	if (s > n)
	{
		printf("-1");
		return 0;
	}
	for (ll i = 2; i * i <= n; i++)
	{
		ll q = n, num = 0;
		while (q)
		{
			num += q % i;
			q /= i;
		}
		if (num == s) 
		{
			printf("%lld\n", i);
			return 0;
		}
	} 
	ll y = n - s;
	ll num;
	for (ll i = sqrt(y); i >= 1; i--)
	{
		if (y % i == 0)
		{
			num = y / i + 1;
			ll j = s - i;
			if (i < num && num >= 2 && j < num && j >= 0)
			{
				printf("%lld\n", num);
				return 0;
			}
		}
	}
	printf("-1");
	return 0;
}


Measured memory_bytes: 384
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))
r = 0
if K <= N:
    current = 1
    for i in range(K):
        current = A[current-1]
    print(current)
else:
    isReturn = [0 for i in range(N)]
    step = 1
    current = 1
    isReturn[current-1] = step
    for i in range(N):
        current = A[current-1]
        step += 1
        if isReturn[current-1] == 0:
            isReturn[current-1] = step
        else:
            r = step - isReturn[current-1]
            break
    
    t = ((K-step) % r) + 1
    for i in range(t):
        current = A[current-1]
        
    print(current)
    
    
                
            
    
    
                
            


Measured memory_bytes: 32244
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005

int a[MAX];

bool Bsearch(int l,int r,int x) {
    if(l>r) return false;
    int mid = (l+r)/2;
    if(a[mid]==x) return true;
    if(a[mid]< x) return Bsearch(mid+1,r,x);
    if(a[mid]> x) return Bsearch(l,mid-1,x);
}

int main() {
    int n; scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int t; scanf("%d",&t);
    int ans = 0;
    while(t--) {
        int x; scanf("%d",&x);
        if(Bsearch(1,n,x)) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
 
int main(void){
  int n;
  cin >> n;
  
  int sum = 0;
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    sum += (temp - 1);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    while(1){
        int a;
        int b;
        int tmp;
        cin>>a>>b;
        if(a==0&b==0){
            break;
        }
        else{
            if(a>b){
                tmp = a; a = b; b = tmp;
            }
            cout<<a<<" "<<b<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    long long X;
    int num = scanf("%llu", &X);
    if(num!=1) return 1;
    long long m = 100;
    int y = 0;
    while(1){
        m += m/100;
        y++;
        if(m>=X){
            printf("%d", y);
            return 0;
        }
    }
}

Measured memory_bytes: 1732
n, m = map(int, input().split())
a = [int(input()) for i in range(n)]
for k in range(1, m+1):
    for i in range(n-1):
        if a[i]%k > a[i+1]%k: a[i], a[i+1] = a[i+1], a[i]
print(*a, sep='\n')


Measured memory_bytes: 5616
#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, X, T;
    cin >> N >> X >> T;
    if (N % X == 0) cout << T * (N / X) << endl;
    else            cout << T * (N / X + 1) << endl;
    return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}



signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    long double n,x,t;
    cin>>n>>x>>t;
    int z=ceil(n/x);
    z*=t;
    cout<<z;

}       


Measured memory_bytes: 3740
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n;
    string s;
    cin >> n >> s;

    vector<ll> wimos(n+1, 0);
    REP(i, n) {
        wimos[i+1] = wimos[i] + (s[i] == '.');
    }
    ll ans = LINF;
    REP(i, n+1) {
        ll wf = i - wimos[i];
        ll we = wimos[n] - wimos[i];
        chmin(ans, wf + we);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2180
#include <iostream>

using namespace std;

int main(){
    int N,M;
    cin >> N;
    int T[N]={};
    for (int i = 0;i < N;i++ ){
       cin >> T[i]; 
    }
    cin >> M;
    int X[M]={},index[M]={};
    for (int i = 0;i < M;i++){
    cin >>index[i];
    cin >> X[i];
    }
    for(int i = 0 ;i < M ; i++){
        int sum = 0 ;
        for (int j=0 ; j<N; j++){
            sum += (index[i]-1==j)? X[i] : T[j] ;
        }
        cout << sum << endl;
    }
}

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

signed main() {
  int N;
  cin >> N;
  
  vector<vector<int>> hito(N, vector<int>(N));
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < N; j++ ){
      hito.at(i).at(j) = -1;
    }
  }
  
  int A, X, Y;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    for( int j = 0; j < A; j++ ){
      cin >> X >> Y;
      hito.at(i).at(X-1) = Y;
    }
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit){
    int cnt = 0;
    bool fg = true;
    for (int i = 0; i < N; ++i) {
      if (bit & (1<<i)) { // i が bit に入るかどうか
        for( int j  = 0; j < N; j++ ){
          if( hito.at(i).at(j) == 1 && hito.at(j).at(i) == 0 ) fg = false;
          if (bit & (1<<j)){
            if( hito.at(i).at(j) == 0 ) fg = false;
            //if( hito.at(j).at(i) == 0 ) fg = false;
          }
          else{
            if( hito.at(i).at(j) == 1 ) fg = false;
            //if( hito.at(j).at(i) == 1 ) fg = false;
          }
        }
        if( fg == true ) cnt++;
      }
    }
    if(fg == true) ans = max( ans, cnt );
  }
  cout << ans << endl;

}


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

const int mod = 1000000007;
int n;
long long ans;
string s1, s2;

int main() {
	cin>>n>>s1>>s2;
	int i = 0;
	int type;
	if(s1[0] == s2[0]){	
		ans= 3;
		type = 0;
		i++;
	}
	else{
		ans = 6;
		type = 1;
		i+=2;
	}
	while(i<n){
		if(type == 0){
			ans = (ans*2) % mod;
			if(s1[i] == s2[i]){
				i++;
			}
			else{
				i+=2;
				type = 1;
			}
		}
		if(type == 1){
			if(s1[i] == s2[i]){
				i++;
				type = 0;
			}
			else{
				ans = (ans*3)%mod;
				i+=2;
			}
		}
	}
	cout<<ans;
	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);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A + B >= 24) {
      System.out.println(A + B -24);
    } else {
      System.out.println(A + B);
    }
  }
}


Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {
    ll N;
    cin >> N;

    ll a[N];

    REP(i,N)
    {
        cin >> a[i];
    }

    ll t[9] = {400,800,1200,1600,2000,2400,2800,3200,4801};
    bool s[9] = {};
  
  	ll yaba = 0;

    REP(i,N)
    {
        REP(j,9)
        {
            if(a[i] < t[j])
            {
                s[j] = true;
              	if(j == 8)++yaba;
                break;
            }
        }
    }
    ll cnt = 0;

    REP(i,8)
    {
        if(s[i])++cnt;
    }

    ll iMax = cnt;
    ll iMin = cnt;

    if(s[9])
    {
        iMax += yaba;
    }
    if(iMin == 0)iMin = 1;

    cout << iMin << " " << iMax << endl;


    return 0;
}

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

using namespace std;
#define ll long long
#define mod 1000000007

ll dp[3001][3001][2];
vector<ll> v, pre;

ll f(ll l, ll r, ll player) {
    if (l > r) return 0;
    else if (l == r) return v[l];

    if (dp[l][r][player] != -1) return dp[l][r][player];

    ll score1 = v[l] + pre[r] - pre[l] - f(l + 1, r, 1 - player);
    ll score2 = v[r] + pre[r - 1] - (l ? pre[l - 1] : 0) - f(l, r - 1, 1 - player);

    dp[l][r][player] = max(score1, score2);
    return dp[l][r][player];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    memset(dp, -1, sizeof(dp));
    
    ll n;
    cin >> n;
    
    v.resize(n);
    pre.resize(n);
    
    for (auto &i : v) {
        cin >> i;
    }

    pre[0] = v[0];
    for (ll i = 1; i < n; i++) {
        pre[i] = pre[i - 1] + v[i];
    }
    
    cout << 2 * f(0, n - 1, 0) - pre[n - 1];
}


Measured memory_bytes: 144628
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
h,w=map(int,input().split())
a=[input() for _ in range(h)]
cnt={}
for i in range(h):
    ar=a[i]
    for j in ar:
        if j in cnt:
            cnt[j]+=1
        else:
            cnt[j]=1
if h%2==0:
    if w%2==0:
        for i in cnt:
            if cnt[i]%4!=0:
                print("No")
                break
        else:
            print("Yes")
    else:
        res=0
        for i in cnt:
            if cnt[i]%4!=0 and cnt[i]%4!=2:
                print("No")
                break
            elif cnt[i]%4==2:
                res+=1
        else:
            if res>h//2:
              print("No")
            else:
              print("Yes") 
else:
    res=0
    if w%2==0:
        for i in cnt:
            if cnt[i]%4!=0 and cnt[i]%2==0:
                res+=1
            elif cnt[i]%2!=0:
                print("No")
                break
        else:
            if res>w//2:
                print("No")
            else:
                print("Yes")
    else:
        res1=0
        for i in cnt:
            if cnt[i]%4!=0  and cnt[i]%2==1:
                res1+=1
            if cnt[i]%4!=0 and cnt[i]%2==0:
                res+=1       
        if res1==1 and res<=(h-1)//2+(w-1)//2:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 68676
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
  int r,D,x[12],i;
  char str[1000],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  r=atoi(p);
  p=strtok(NULL," \n");
  D=atoi(p);
  p=strtok(NULL," \n");
  x[0]=atoi(p);
  
  for(i=1;i<11;i++){
    x[i]=r*x[i-1]-D;
    printf("%d\n",x[i]);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int K,T,a=0,temp,ans;
  cin>>K>>T;
  for(int i=0;i<T;i++){
    cin>>temp;
    a=max(a,temp);
  }

  a-=(K+1)/2;
  if(a<=0){
    cout<<0<<endl;
    return 0;
  }
  ans=a*2;
  if(K%2==0) ans--;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	a = LI()
	a = [0]+a
	dp_t = defaultdict(lambda: -10**18)
	dp_f =  defaultdict(lambda: -10**18)
	dp_f[(0,0)]=0
	for i in range(1,n+1):
		dp_f[(i,(i-1)//2)]=max(dp_f[(i-1,(i-1)//2)], dp_t[(i-1,(i-1)//2)])
		dp_t[(i,(i-1)//2)]=dp_f[(i-1,(i-1)//2-1)]+a[i]
		dp_f[(i,(i-1)//2+1)]=max(dp_f[(i-1,(i-1)//2+1)], dp_t[(i-1,(i-1)//2+1)])
		dp_t[(i,(i-1)//2+1)]=dp_f[(i-1,(i-1)//2)]+a[i]
	print(max(dp_t[(n,n//2)],dp_f[(n,n//2)]))
if __name__ == '__main__':
	main()

Measured memory_bytes: 202588
L, R=map(int, input().split())

if R - L >= 2019:
    print(0)
    
else:
    ans=float("INF")
    for i in range(L, R):
        for j in range(i+1,R+1):
            ans=min(ans, (i*j)%2019)
    print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i) cin >> a.at(i);

  vector<long long> s(N + 1, 0);
  map<long long, long long> nums;
  for (int i = 0; i < N; ++i) s.at(i + 1) = s.at(i) + a.at(i);
  for (int i = 0; i < N + 1; ++i) nums[s[i]]++;

  long long ans = 0;
  for (auto it : nums) {
    long long num = it.second;
    ans += num * (num - 1) / 2;
  }

  cout << ans << endl;
}

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

class RangeCount {
    const int ST_SIZE = (1 << 20) - 1;
    int n;
    vector<int> data;
    vector<vector<int>> segtree;

    void init(int k, int l, int r) {
        if (r - l == 1) {
            segtree[k].push_back(data[l]);
        } else {
            int lch = k * 2 + 1;
            int rch = k * 2 + 2;
            init(lch, l, (l + r) / 2);
            init(rch, (l + r) / 2, r);
            segtree[k].resize(r - l);

            merge(segtree[lch].begin(), segtree[lch].end(), segtree[rch].begin(), segtree[rch].end(),
                  segtree[k].begin());
        }
    }

    // number of x in [i, j)
    int query(int i, int j, int x, int k, int l, int r) {
        if (j <= l || r <= i) {
            return 0;
        }

        if (i <= l && r <= j) {
            return upper_bound(segtree[k].begin(), segtree[k].end(), x) - segtree[k].begin();
        }

        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }

public:
    RangeCount(const vector<int> &v) {
        n = v.size();
        data = vector<int>(v);
        segtree = vector<vector<int>>(ST_SIZE);
        init(0, 0, n);
    }

    int exact(int i, int j, int x) { return query(i, j, x, 0, 0, n) - query(i, j, x - 1, 0, 0, n); }

    int le(int i, int j, int x) { return query(i, j, x, 0, 0, n); }

    int lt(int i, int j, int x) { return query(i, j, x - 1, 0, 0, n); }

    int ge(int i, int j, int x) { return query(i, j, 1e9, 0, 0, n) - query(i, j, x - 1, 0, 0, n); }

    int gt(int i, int j, int x) { return query(i, j, 1e9, 0, 0, n) - query(i, j, x, 0, 0, n); }
};

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

    int n;
    cin >> n;
    vector<int> ls(n);
    for (int i = 0; i < n; i++) cin >> ls[i];
    sort(ls.begin(), ls.end());

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int cnt = lower_bound(ls.begin(), ls.end(), ls[i] + ls[j]) - ls.begin();
            ans += cnt - (j + 1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
K = int(input())

l = []
for i in range(1, K+1):
    for j in range(len(s)+1):
        if j+i > len(s):
            continue
        l.append(s[j:j+i])

l = list(set(l))
l.sort()
print(l[K-1])

Measured memory_bytes: 5068
N, K = map(int, input().split())
sunuke = [0] * N
for i in range(K):
    d = int(input())
    A = list(map(int, (input().split())))
    for j in range(d):
        sunuke[A[j]-1] = 1
ans = N - sum(sunuke)
print(ans)

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

using namespace std;
int main()
{
    int n,a,b,a1,b1;
    cin>>n>>a>>b;
    a1=abs(n-a);
    b1=abs(n-b);
    if(a1>b1){
        cout<<"B"<<endl;
    }
    else{
        cout<<"A"<<endl;
    }
}


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

string grf(int x) {
	string s;
	if (x == 0) {
		s = "-";
		return s;
	}
	else {
		for (int i = 0;i < x;i++)s.push_back('*');
	}
	return s;
}

int main() {
	int n;
	while (cin>> n, n) {
		int a[10] = {};
		for (int i = 0;i < n;i++) {
			int b;
			cin >> b;
			a[b]++;
		}
		for (int i = 0;i < 10;i++) {
			cout << grf(a[i]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3032
import numpy as np

h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
ans = [["" for _ in range(w)] for _ in range(h)]
ptr = 0
for y in range(h):
    for x in range(w):
        if a[ptr] == 0:
            ptr += 1
        ans[y][x] = str(ptr+1)

        a[ptr] -= 1

for y in range(h):
    print(" ".join(ans[y] if y % 2 == 0 else reversed(ans[y])))


Measured memory_bytes: 27444
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#define MAX_N (100000)
#define MAX_M (100000)

using namespace std;

void find_path(const vector<vector<int>> &adj_lists, vector<int> &path,
               vector<int> &us, int cur) {
  // printf("%d\n", cur);
  for (const int nxt : adj_lists[cur]) {
    if (!us[nxt]) {
      us[nxt] = 1;
      path.push_back(nxt);
      find_path(adj_lists, path, us, nxt);
      break;
    }
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int N, M, as[MAX_M], bs[MAX_M];
  scanf("%d %d", &N, &M);
  for (int k = 0; k < M; k++) {
    scanf("%d %d", &as[k], &bs[k]);
    as[k]--;  // NOTE : modified input
    bs[k]--;  // NOTE : modified input
  }

  // create graph
  vector<vector<int>> adj_lists(N, vector<int>());
  for (int k = 0; k < M; k++) {
    const int a = as[k], b = bs[k];
    adj_lists[a].push_back(b);
    adj_lists[b].push_back(a);
  }

  // solve
  vector<int> path1, path2, us(N, 0);
  us[0] = 1;
  find_path(adj_lists, path1, us, 0);
  find_path(adj_lists, path2, us, 0);

  // print answer
  printf("%d\n", (int) path1.size() + (int) path2.size() + 1);
  for (int i = path1.size() - 1; i >= 0; i--) {
    printf("%d\n", path1[i] + 1);
  }
  printf("%d\n", 0 + 1);
  for (int i = 0; i < path2.size(); i++) {
    printf("%d\n", path2[i] + 1);
  }

  return 0;
}


Measured memory_bytes: 13688
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_N = 110;
const int MAX_M = 110;

ll d[MAX_N][MAX_M];
bool isCold[MAX_N];

vector<pii> es[MAX_N];

int main(){
    int n, timeLimit, cold_town_num, m , s, t;
    while(cin >> n >> timeLimit >> cold_town_num >> m >> s >> t) {
        if(n == 0 && timeLimit == 0 && cold_town_num == 0 && m == 0 && s == 0 && t == 0) break;
        rep(i, MAX_N) rep(j, MAX_M) d[i][j] = INF;
        rep(i, MAX_N) isCold[i] = false;
        rep(i, MAX_N) es[i].clear();
        rep(i, cold_town_num) {
            int a;
            cin >> a;
            isCold[a] = true;
        }
        rep(i, m) {
            int x, y, t;
            cin >> x >> y >> t;
            es[x].push_back({y, t});
            es[y].push_back({x, t});
        }
        d[s][timeLimit] = 0;
        using P = pair<ll, pii>;
        priority_queue<P,vector<P>,greater<P> > q;
        q.push({0, {s, timeLimit}});
        while(!q.empty()) {
            auto p = q.top();
            q.pop();
            int i = p.se.fi, j = p.se.se;
            auto cost = p.fi;
            if(d[i][j] < cost) continue;
            if(isCold[i] && j != timeLimit) {
                if(d[i][j+1] > cost + 1) {
                    d[i][j+1] = cost + 1;
                    q.push(make_pair(cost+1, make_pair(i, j+1)));
                }
            } 
            for(auto&& e : es[i]) {
                int nxt = e.fi;
                int t = e.se;
                if(j - t >= 0) {
                    int  k = j - t;
                    if(d[nxt][k] > cost + t) {
                        d[nxt][k] = cost + t;
                        q.push(make_pair(d[nxt][k], make_pair(nxt, k)));
                    }
                }
            }            
        }
        ll ans = INF;
        rep(i, timeLimit+1) ans = min(ans, d[t][i]);
        if(ans == INF) cout << "Help!" << endl;
        else cout << ans << endl;
    }
    return 0;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    
    int n,k;
    cin>>n>>k;
    vector<int> p(n),c(n);
    rep(i,n){ 
        cin>>p[i];
        p[i]--;
    }
    rep(i,n) cin>>c[i];
    ll ans=-INF;
    int cm;
    rep(i,n){
        ll point=0;
        cm=i;
//        set<int> s;
//        s.insert(cm);
        bool bcyc=false;
        ll mcyc=-INF;
        ll lcyc=0;
        rep(j,k){
            lcyc++;
            cm=p[cm];
            point+=c[cm];
            mcyc=max(mcyc,point);
//            if(s.count(cm)){ 
            if(i==cm){ 
                bcyc=true;
                break;
                }
//            s.insert(cm);
        }
        if(bcyc){
            if(point<=0) ans=max(ans,mcyc);
            else {
                point=(k/lcyc-1)*point;
                cm=i;
                mcyc=-INF;
                rep(j,k%lcyc+lcyc){
                    cm=p[cm];
                    point+=c[cm];
                    mcyc=max(mcyc,point);
                }
                ans=max(ans,mcyc);
            }
        }
        else{
            ans=max(ans,mcyc);
        }
//        cout<<i<<" "<<point<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;


long long ans = 0x3f3f3f3f3f3f3f3fLL;
long long sum[300005], b[105];
int a[300005];
int n;

long long gao(int x, int y, int z) {
	b[1] = sum[x];
	b[2] = sum[y] - sum[x];
	b[3] = sum[z] - sum[y];
	b[4] = sum[n] - sum[z];

	sort(b + 1, b + 1 + 4);
	
	return b[4] - b[1];
}
int main( ) {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	int curx = 1, cury = 3;
	for (int i = 3; i <= n - 1; i ++) {
		while (curx + 1 <= i - 2 && sum[curx + 1] * 2 <= sum[i - 1]) ++ curx;
		while (cury + 1 < n && (sum[cury + 1] - sum[i - 1]) * 2 <= sum[n] - sum[i - 1]) ++ cury;
		ans = min(ans, gao(curx, i - 1, cury));
		if (curx + 1 <= i - 2 && cury + 1 < n) {
			ans = min(ans, gao(curx + 1, i - 1, cury + 1));
		}
		if (curx + 1 <= i - 2) ans = min(ans, gao(curx + 1, i - 1, cury));
		if (cury + 1 < n) ans = min(ans, gao(curx, i - 1, cury + 1));
	}
	printf("%lld\n", ans);
	return 0;
}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int r;
  cin >> r;
  cout << r * 3.141592653589793238 * 2 << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3788
#include <stdio.h>
#include <math.h>

struct point { double x, y; };

void koch(int n, struct point a, struct point b) {
  if (n == 0) {
    return;
  }
  struct point s, t, u;
  double th = 3.14159265 * 60.0 / 180.0;
  
  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main() {
  struct point a, b;
  int n;
  
  scanf("%d", &n);
  
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
  
  return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a+b >= c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int axis[1000000],size=0;
int theO(){
  if(size<=0) return 0;
  return axis[--size];
}
int hyakushiki(int a){
  axis[size++]=a;
  return 0;
}
int expert(char *jojo){
  if(*jojo=='+'||*jojo=='-'){
    jojo++;
    if (*jojo>='0'&&*jojo<='9') return 1;
    return 0;
  }
  if(*jojo>='0'&&*jojo<='9') return 1;
  return 0;
}
int Zgundam(char *lim){
  int Z=0,n=0;
  if(*lim=='+')lim++;
  else if(*lim=='-'){
    Z=1;
    lim++;
  }
  while(*lim>='0'&&*lim<='9'){
    n=n*10+(*lim-'0');
    lim++;
  }
  if(Z)return -n;
  return n;
}
int gundam_mk2(char *A){
  int x1,x2,n;
  while(*A){
    if (expert(A)){
      n=Zgundam(A);
      hyakushiki(n);
      while(*A=='-'||*A=='+'){
	A++;
      }
      while(n){
	n/=10;
	A++;
      }
    }
    else{
      switch(*A){
      case '+':x1=theO();
	x2=theO();
	hyakushiki(x1+x2);
	break;
      case '-':x1=theO();
	x2=theO();
	hyakushiki(x2-x1);
	break;
      case '*':x1=theO();
	x2=theO();
	hyakushiki(x2*x1);
	break;
      }
      A++;
    }
  }
  return theO();
}
int main(){
  char array[1000000];
  scanf("%[^\n]*s", array);
  printf("%d\n",gundam_mk2(array));
  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int K, X;
	cin >> K >> X;
	int left = X - K + 1;
	int right = X + K - 1;
	for (int i = left; i <= right; i++) {
		cout << i << " ";
	}
	return 0;
}

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

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

static const int INF = 1e9;

void warshall_floyd(vector<vector<int>>& dist)
{
    const int n = dist.size();
    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}

int main()
{
    ios::sync_with_stdio(false);

    int n, m, c, s, g;
    while (cin >> n >> m >> c >> s >> g, n) {
        --s; --g;
        vector<vector<vector<int>>> dist(c, vector<vector<int>>(n, vector<int>(n, INF)));
        rep(i, m) {
            int x, y, d, e; cin >> x >> y >> d >> e; --x; --y; --e;
            dist[e][x][y] = min(dist[e][x][y], d);
            dist[e][y][x] = min(dist[e][y][x], d);
        }

        vector<int> n_spans(c);
        rep(i, c) cin >> n_spans[i];

        vector<vector<int>> spans(c);
        vector<vector<int>> grads(c);
        vector<vector<int>> fares(c);
        rep(i, c) {
            spans[i].resize(n_spans[i]);
            spans[i][0] = 0;
            rep(j, n_spans[i] - 1) cin >> spans[i][j + 1];

            grads[i].resize(n_spans[i]);
            rep(j, n_spans[i]) cin >> grads[i][j];

            fares[i].resize(n_spans[i]);
            fares[i][0] = 0;
            for (int j = 1; j < n_spans[i]; ++j)
                fares[i][j] = fares[i][j-1] + (spans[i][j] - spans[i][j-1]) * grads[i][j-1];
        }

        vector<vector<int>> costs(n, vector<int>(n, INF));
        rep(i, c) {
            rep(j, n) dist[i][j][j] = 0;
            warshall_floyd(dist[i]);

            rep(j, n) rep(k, n) {
                int d = dist[i][j][k];
                if (d == INF) continue;
                auto it = prev(upper_bound(begin(spans[i]), end(spans[i]), d));
                int idx = distance(begin(spans[i]), it);
                int fare = fares[i][idx] + grads[i][idx] * (d - spans[i][idx]);
                costs[j][k] = min(costs[j][k], fare);
            }
        }

        warshall_floyd(costs);
        cout << (costs[s][g] == INF ? -1 : costs[s][g]) << endl;
    }
}

Measured memory_bytes: 1876
S = str(input())
L = len(S)
valueChangedIndex = []
s = S[0]
for i in range(1, L):
    if S[i] != s:
        valueChangedIndex.append(max(i, L-i))
    s = S[i]

if len(valueChangedIndex) == 0:
    print(L)
else:
    print(min(valueChangedIndex))

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

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    while(true){
    if(C-B<=0){
        cout << "Yes" << endl; return 0;
    }
    C=C-B;
    if(A-D<=0){
        cout << "No" << endl; return 0;
    }
    A=A-D;
}
    
return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
 
#define INF_LL 1e18
#define INF 1e9
 
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
 
using namespace std;
 
using ll = long long;
using PII = pair<int, int>;
 
class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;
 
public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}
 
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}
 
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
 
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
 
	bool same(int x, int y){
		return find(x) == find(y);
	}
};
 
ll mod = 1e9+7;
 
ll powm(ll x, ll a){
	ll res = 1;
	REP(i, a){
		res = (res * x) % mod;
	}
	return res;
}

class BIT{
	vector<ll> dat;
	int n;
public:
	BIT(int n_){
		n = n_;
		REP(i, n+1){
			dat.push_back(0);
		}
	}

	void add(int i, int x){
		while(i <= n){
			dat[i] += x;
			i += i & -i;
		}
	}

	int sum(int i){
		int res = 0;
		while(i > 0){
			res += dat[i];
			i -= i & -i;
		}
		return res;
	}
};

bool comp(PII lhs, PII rhs){
	return (lhs.second-lhs.first) < (rhs.second-rhs.first);
}

int main(void){
	int N, M;
	PII item[300030];
	cin >> N >> M;
	BIT bit0(M+1), bit1(M+1);

	REP(i, N){
		cin >> item[i].first >> item[i].second;
	}
	sort(item, item+N, comp);

	ll ans = N;
	int in = 0;
	FOR(d, 1, M+1){
		while(item[in].second - item[in].first + 1 < d && in < N){
			bit0.add(item[in].first, -1*(item[in].first-1));
			bit1.add(item[in].first, 1);
			bit0.add(item[in].second+1, 1*item[in].second);
			bit1.add(item[in].second+1, -1);
			in++;
			ans--;
		}
		int d_t = d;
		ll cnt = 0;
		while(d_t < M+1){
			cnt += (bit0.sum(d_t)+bit1.sum(d_t)*d_t)-(bit0.sum(d_t-1)+bit1.sum(d_t-1)*(d_t-1));
			d_t += d;
		}
		cout << ans + cnt << endl;
	}
}


Measured memory_bytes: 4980