akhauriyash/Code-Regression huggingface dataset:
def main():
    N = int(input())
    S = input()
    # ans_w, ans_b = 0, 0

    # started = False
    # for s in S:
    #     if s == '#':
    #         started = True
    #     if started and s == '.':
    #         ans_w += 1
    # started = False
    # for i in range(N):
    #     s = S[N - 1 - i]
    #     if s == '.':
    #         started = True
    #     if started and s == '#':
    #         ans_b += 1
    # print(min(ans_w, ans_b))
    Ws, Bs = [], []
    c = S[0]
    l = 1
    for i in range(1, N):
        s = S[i]
        if c == s:
            l += 1
        else:
            if c == '.':
                Ws.append(l)
            else:
                Bs.append(l)
            l = 1
            c = s
    if c == '.':
        Ws.append(l)
    else:
        Bs.append(l)
    # print(Ws, Bs)
    len_ws = len(Ws)
    len_bs = len(Bs)
    if len_ws == 0 or len_bs == 0:
        print(0)
        return
    if len_ws == 1:
        if len_bs == 1:
            if S[0] == '.':
                print(0)
            else:
                print(min(Bs[0], Ws[0]))
        else:
            # len_bs == 2
            print(min(Ws[0], Bs[0]))
        return
    if len_bs == 1:
        # len_ws == 2
        print(min(Ws[1], Bs[1]))
        return

    # len_ws >= 2 and len_bs >= 2
    sum_w_s, sum_w_r, sum_b_s, sum_b_r = [0]*len_ws, [0]*len_ws,  [0]*len_bs, [0]*len_bs
    sum_w_s[0] = Ws[0]
    sum_w_r[0] = Ws[-1]
    sum_b_s[0] = Bs[0]
    sum_b_r[0] = Bs[-1]
    for i in range(1, len_ws):
        sum_w_s[i] = sum_w_s[i - 1] + Ws[i]
        sum_w_r[i] = sum_w_r[i - 1] + Ws[len_ws - 1 - i]
    for i in range(1, len_bs):
        sum_b_s[i] = sum_b_s[i - 1] + Bs[i]
        sum_b_r[i] = sum_b_r[i - 1] + Bs[len_bs - 1 - i]
    # print(sum_w_s, sum_w_r, sum_b_s, sum_b_r)
    ans = min(sum_w_s[-1], sum_b_s[-1])
    if S[0] == '#':
        for i in range(len_ws - 1):
            a = sum_b_s[i] + sum_w_r[len_ws - 2 - i]
            ans = min(a, ans)
    else:
        ans = min(ans, sum_w_s[-1] - Ws[0])
        for i in range(len_ws - 1):
            a = sum_w_r[i] + sum_b_s[len_bs - 2 - i]
            ans = min(a, ans)
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
  int ww,n;
  char c;
  int v[1050], w[1050];
  int dp[1050];

  int datacase=1;
  while( cin>>ww && ww ){
    cin >> n;
    for( int i=0;i<n;i++ )
      cin >> v[i] >> c >> w[i];

    dp[0]=0;
    for( int i=1;i<=ww;i++ )
      dp[i] = -1;


    for( int j=0;j<n;j++ ){
      for( int i=ww-w[j];i>=0;--i){
      //      for( int i=0;i<=ww-w[j];i++ ){ // 間違い
	if( dp[i]>=0 ){
	  int k =i+w[j];
	  dp[k] = max( dp[k],dp[i]+v[j] );
	}
      }
    }

    int aw=0,av=0;
    for( int i=0;i<=ww;i++ ){
      //      cout << i << "\t" << dp[i] << endl;
      if( dp[i]>av ){
	av=dp[i]; aw=i;
      }
    }
    cout << "Case " << datacase++ << ":" << endl;
    cout << av << endl;
    cout << aw << endl;


  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
s = [0]*n
c = [1]*n
A = [0]*n
k = 0

for i in range(n):
	s[i] = input()

s.sort()    
    
for i in range(n-1): 
	if s[i] == s[i+1]:
		c[i+1] += c[i]
      
M = max(c)

for i in range(n):
	if c[i] == M:
		print(s[i])


Measured memory_bytes: 26524
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s;cin>>s;
  reverse(all(s));
  int n = sz(s);

  vvi dp(n+1, vi(13,0));
  dp[0][0] = 1;
  int mul = 1;
  rep(i, 0, n){
    rep(j, 0, 13){
      if (s[i]=='?'){
        rep(x, 0, 10){
          dp[i+1][(j+mul*(x))%13] += dp[i][j];
          dp[i+1][(j+mul*(x))%13] %= MOD;
        }
      }
      else{
        dp[i+1][(j+mul*(s[i]-'0'))%13] += dp[i][j];
        dp[i+1][(j+mul*(s[i]-'0'))%13] %= MOD;
      }
    }

    mul *= 10;
    // mul %= MOD;
    mul %= 13;
    int y = 0;
    rep(j, 13) {
      y += dp[i+1][j];
    }
  }
  cout << dp[n][5]%MOD << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 13648
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
	typedef long long ll;
	ll n,m,l,r,ans;
	int main(){
		IOS
		cin>>n>>m;
		l=1; r=n;
		for(int i=0;i<m;i++){
			ll tl,tr;
			cin>>tl>>tr;
			l=max(l,tl);
			r=min(r,tr);
			
		}
		ans=max(0ll,r-l+1);
		cout<<ans<<endl;
	} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MN 100
using namespace std;
typedef long long LL;
int n,p,a[MN],even=0,odd=0;
LL ans=0,C[100][100]={0};
int main()
{
    C[0][0]=1;
    for (int i=1;i<=52;i++)
    {
        C[i][0]=1;
        for (int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j]+C[i-1][j-1]);
    }
    scanf("%d%d",&n,&p);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%2)odd++;else even++;
    }
    LL pow2=1;
    for(int i=0;i<even;i++)pow2=pow2<<1;
    if(p==1)
    {
        LL pre=0;
        for(int i=1;i<=odd;i+=2)
        {
            pre=pre+C[odd][i];
        }
        LL ans=pre*pow2;
        cout<<ans<<endl;
    }else
    {
        LL pre=0;
        for(int i=0;i<=odd;i+=2)
        {
            pre=pre+C[odd][i];
        }
        LL ans=pre*pow2;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
prime = []
max_num = math.sqrt(55555)
data = [i + 1 for i in range(1, 55555)]
while True:
  p = data[0]
  if p >= max_num:
    prime += data
    break
  prime.append(p)
  data = [e for e in data if e % p != 0]
satisfy_prime = [p for p in prime if p % 5 == 1]

n = int(input())
print(" ".join([str(p) for p in satisfy_prime[:n]]))


Measured memory_bytes: 5528
#include<iostream>

using namespace std;

char c[55][55]; int H, W, cnt;

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> c[i][j];
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') cnt++;
		}
	}
	if (cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	int n;
	scanf("%d",&n);
	ll ans=0;
	rep(i,0,n){
		int x,y;
		scanf("%d%d",&x,&y);
		ans+=y-x+1;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define sort(v) sort(v.begin(),v.end());
const ll mod = 1E9+7;

int main()
{
   ll n;
   cin>>n;
   string ans;
   while(n!=0){
      ll r = (n-1)%26;
      char x = char(r+97);
      ans+=x;
      n = (n-r)/26;
   }
   reverse(ans.begin(),ans.end());
   cout<<ans<<endl;
}


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

int d;
int x[12][12];

int is_integer(int i, int j) {
  int dist = 0, inc = 1;
  rep (k, d) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
  rep (inc, 150) if (inc * inc == dist) return 1;
  return 0;
}

int main() {
  int n;
  cin >> n >> d;
  int ans = 0;
  rep (i, n) rep (j, d) cin >> x[i][j];
  rep (i, n) rep (j, i) ans += is_integer(i, j);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 200;

char s[N];

bool check(int L,int R){
	bool flag=false;
	while(s[L]==s[R]&&L<=R){
		// cout<<"L="<<L<<"  R="<<R<<'\n';
		if((L==R-1||L==R-2||L==R) && s[L]==s[R]) flag=true;
		L++,R--;
	}
	return flag;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s+1;
	int len=strlen(s+1);
	int mid=(len+1)/2;
	// cout<<"mid="<<mid<<'\n';
	if(check(1,mid-1)&&check(mid+1,len)&&check(1,len)) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
def prime_factorize(n):
  a=[]
  while n%2==0:
    a.append(2)
    n//=2
  f=3
  while f*f<=n:
    if n%f==0:
      a.append(f)
      n//=f
    else:
      f+=2
  if n!=1:
    a.append(n)
  return a
print(1+len(set(prime_factorize(a))&set(prime_factorize(b))))


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

typedef pair<int,int> P;
const int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int H,W,i,j,r=0;
    cin >> H >> W;
    vector<string> f(H);
    vector<vector<int>> d(H, vector<int>(W,INF));
    queue<P> q;
    P p;

    for(i=0; i<H; i++) {
        cin >> f.at(i);
        for(j=0; j<W; j++)
            if(f.at(i).at(j) == '#') {
                q.push(P(i,j));
                d.at(i).at(j) = 0;
            }
    }

    
    while(!q.empty()) {
        p = q.front();
        q.pop();

        for(i=0; i<4; i++) {
            int nx=p.first+dx[i], ny=p.second+dy[i];
            if(nx<0 || nx>=H || ny<0 || ny>=W)
                continue;
            if(f.at(nx).at(ny)=='.' && d.at(nx).at(ny)==INF) {
                d.at(nx).at(ny) = min(d.at(nx).at(ny), d.at(p.first).at(p.second)+1);
                q.push(P(nx,ny));
            }
        }
    }

    cout << d.at(p.first).at(p.second) << endl;
}

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

#define min(a,b) (a > b) ? b : a

int main()
{
    int N;
    int A[100];
    int B[100];

    std::cin >> N;
    for (int i = 0; i < N - 1; i++) {
        std::cin >> B[i];
    }

#if 1
    for (int i = 0; i < N; i++) {
        if (i == 0)
            A[0] = B[0];
        else if (i == N -1)
            A[i] = B[i - 1];
        else {
            A[i] = min(B[i], B[i - 1]);
        }
    }

    int sum  =0;
    for (int i = 0; i < N; i++) {
        sum += A[i];
    }

    std::cout << sum << std::endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string ans = "YES";
	int n; cin >> n;
	int cnt = 0;
	rep(i, 1, n)
	{
		int p; cin >> p;
		if (p != i)
		{
			++cnt;
			if (cnt > 2)ans = "NO";
		}
	}
	cout << ans << endl;
}

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();
       int area = a * b;
       int length = 2 * (a + b);
       System.out.println(area + " " + length);   }
}


Measured memory_bytes: 25876
#include <iostream>

using namespace std;

int main(void) {
  long N;
  long sum = 0;
  long max = 0;
  cin >> N;
  for (long i = 0; i < N; i++) {
    long tmp;
    cin >> tmp;
    sum += tmp;
    if (tmp > max) max = tmp;
  }
  if (max < sum - max) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main(){
    int a[3];
    REP(i,3){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]+a[1]<<endl;
    }


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

struct MOVE
{
	int hurt, cost;
};

int h, n, ans;
MOVE minm, maxm;
MOVE moves[100005];
int dp[200005];

int main()
{	
	cin>>h>>n;
	minm.hurt = 0x3f;
	for(int i = 0; i < n; i ++)
	{
		cin>>moves[i].hurt>>moves[i].cost;
		if(moves[i].hurt < minm.hurt) 
			minm.hurt = moves[i].hurt, minm.cost = moves[i].cost;
		if(moves[i].hurt > maxm.hurt) 
			maxm.hurt = moves[i].hurt, maxm.cost = moves[i].cost;
	}
	memset(dp, 0x3f, sizeof(dp));
	//dp[minm.hurt] = minm.cost;
	dp[0] = 0;
	for(int i = 0; i <= h + maxm.hurt; i ++)
	{
		if(dp[i] >= dp[200004]) continue;
		//cout<<i<<' '<<dp[i]<<endl;
		for(int j = 0; j < n; j ++)
		{
			if(moves[j].hurt + i > h + maxm.hurt) 
				continue;
			dp[moves[j].hurt + i] = min(dp[moves[j].hurt + i], dp[i] + moves[j].cost);
		}
	}
	for(int i = h; i <= h + maxm.hurt; i ++)
		if(i == h || dp[i] < ans) ans = dp[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int N,k,a;
int ans=0;
bool check=true;
cin >> N;
vector<vector<int>> x(N,vector<int>(N));
vector<vector<int>> y(N,vector<int>(N));
vector<int> A(N);
for(int i=0;i<N;i++){cin >> A.at(i);for(int j=0;j<A.at(i);j++){cin >> x.at(i).at(j) >> y.at(i).at(j);}}
for(int bit=0;bit<(1 << N);bit++)
{
a=0;
check=true;
for(int i=0;i<N;i++)
{
if(!(bit&(1 << i)))continue;
for(int j=0;j<A.at(i);j++)
{
if(bit&(1 << x.at(i).at(j)-1))k=1;
else k=0;
if(k!=y.at(i).at(j)){check=false;break;}
}
if(!check){break;}
}
if(check){for(int m=0;m<N;m++){if(bit&(1 << m))a++;}ans=max(ans,a);}
}
cout << ans;
}


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

int main(void)
{
    double x1, y1, x2, y2;
    
    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
    
    printf("%lf\n", sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    
    return (0);
}


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

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a!=1&&b!=1) cout<<"1"<<endl;
    if(a!=2&&b!=2) cout<<"2"<<endl;
    if(a!=3&&b!=3) cout<<"3"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

ll N;

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n/i);
            }
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

int main() {
    cin >> N;

    vector<ll> div_N = divisor(N);
    vector<ll> div_N_1 = divisor(N-1);

    ll ans = 0;
    for (int i = 0; i < div_N.size(); i++) {
        ll tmp = N;
        
        while (div_N[i] != 1 && tmp % div_N[i] == 0) {
            tmp /= div_N[i];
        }
        if (tmp % div_N[i] == 1) {
            ans++;
        }
    }
    
    ans += div_N_1.size() - 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
n = int(input())
k = int(input())
s = str(n)
l = len(s)
dp0 = [[0]*(k+1) for _ in range(l+1)]
dp1 = [[0]*(k+1) for _ in range(l+1)]
dp1[0][0] = 1
for i in range(l):
  for j in range(k+1):
    dp1[i+1][j] += dp1[i][j]*(int(s[i]) == 0)
    dp0[i+1][j] += dp0[i][j]+dp1[i][j]*(int(s[i]) > 0)
    if j < k:
      dp1[i+1][j+1] += dp1[i][j]*(int(s[i]) > 0)
      dp0[i+1][j+1] += dp0[i][j]*9+dp1[i][j]*max(0,int(s[i])-1)
print(dp1[l][k]+dp0[l][k])

Measured memory_bytes: 3064
from collections import deque
n = int(input())
l = deque()
for i in range(n):
    command = input()
    if command == "deleteFirst":
        l.popleft()
    elif command == "deleteLast":
        l.pop()
    else:
        order, num = command.split()
        if order == "insert":
            l.appendleft(num)
        elif order == "delete":
            try:
                l.remove(num)
            except:
                pass

print(" ".join(l))


Measured memory_bytes: 69740
require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,r=gsmi
if n>=10
  puts r
else
  puts 100*(10-n)+r
end

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

int main() {
	char c;
	cin >> c;
	for(int i=0; i<26; i++){
		if(c=='a'+i){
			cout << 'a' << endl; return 0;
		}
	}
	cout << 'A' << endl;
	return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
#define pprint(a,m,n) rep(j,0,m){ print(a[j],n); }
const int mod = 1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int H,A,B;cin>>H>>A>>B;
	int cnt=0;
	rep(i,A,B+1){
		if(H%i==0) cnt++;
	}cout<<cnt<<endl;
	return 0;
}


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

ll mini(ll a, ll b){
    return (a<b)? a : b;
}


int main(){
    ll n; cin>> n;
    ll a[n], b[n]={0};
    for(ll i=0; i<n; i++) cin>> a[i];
    b[1]=abs(a[1]-a[0]);
    for(ll i=2; i<n; i++){
        b[i]=mini(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
    }
    cout<< b[n-1]<< endl;
}


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

namespace AtCoder
{
    class Program
    {
        static int h;
        static int w;
        static char[,] map;
        static int count;

        static void Main(string[] args)
        {
            //[summary]B - Minesweeper
            var line = ReadLine();
            h = line[0];
            w = line[1];

            //マップを描画
            GetMap();

            var ans = new string[h, w];
            
            for(int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {                  
                    if (map[y, x] == '.')
                    {
                        CountBombs(y, x);
                        ans[y, x] = count.ToString();
                    }
                    else
                    {
                        ans[y, x] = "#";
                    }
                }
            }

            for(int y = 0; y < h; y++)
            {
                string s = "";

                for(int x = 0; x < w; x++)
                {
                    s += ans[y, x];
                }

                Console.WriteLine(s);
            }
        }

        static void CountBombs(int y, int x)
        {
            count = 0;

            Judge(y - 1, x - 1);
            Judge(y - 1, x);
            Judge(y - 1, x + 1);

            Judge(y, x - 1);
            Judge(y, x + 1);

            Judge(y + 1, x - 1);
            Judge(y + 1, x);
            Judge(y + 1, x + 1);
        }

        static void Judge(int y, int x)
        {
            try
            {
                if (map[y, x] == '#')
                {
                    count++;
                }
            }
            catch
            {
            }
        }

        static void GetMap()
        {
            map = new char[h, w];

            for(int y = 0; y < h; y++)
            {
                string s = Console.ReadLine();

                for(int x = 0; x < w; x++)
                {
                    map[y, x] = s[x];
                }
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl; 
    }else if(s =="Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

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

int main() {
    int X, Y;
    cin >> X >> Y;

    cout << __gcd(X, Y) << endl;

    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
using namespace std;
typedef long long LL;
const LL mod=998244353;
LL dp[3100][3100];

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;

    for(int i=a+1;i<=c;i++)
    {
        dp[i][b]=b*dp[i-1][b]%mod;
    }
    for(int i=b+1;i<=d;i++)
    {
        dp[a][i]=a*dp[a][i-1]%mod;
    }

    for(int i=a;i<=c;i++)
        for(int j=b;j<=d;j++)
        {
            if(dp[i][j]!=0)    continue;
            else
            {
                dp[i][j]=(dp[i-1][j]*j%mod+dp[i][j-1]*i%mod-(i-1)*(j-1)*dp[i-1][j-1]%mod+10*mod)%mod;
            }
        }

        cout<<dp[c][d]<<endl;
}


Measured memory_bytes: 76096
#include <cstdio>
#include <vector>

using namespace std;

int main() {
    int n, cnt = 0;
    scanf("%d", &n);
    vector<int> p(n);
    for (int i = 0; i < n; ++i) scanf("%d", &p.at(i));
    for (int i = 1; i < n - 1; ++i) if ((p.at(i - 1) < p.at(i) && p.at(i) < p.at(i + 1)) || (p.at(i - 1) > p.at(i) && p.at(i) > p.at(i + 1))) ++cnt;
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> f(n+1,1);
    for(int i = 2; i <= n; i++) {
        for(int j = 1; i*j <= n; j++) {
            f[i*j] += 1;
        }
    }
    long long int ans = 0LL;
    for(int k = 1; k <= n; k++) {
        ans += k*f[k];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 41916
#include <iostream>

using namespace std;

int main()
{
    int n, r;
    int result = 0;
    cin >> n >> r;
    if(n >= 10) {
    	result  = r;
    }else {
       int res = 100 * (10 - n);
      result  = (res + r);
    }
    cout << result << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const double pi = 3.141592653589793;

#define INF 1000000000000


signed main(){
int k;
string s;
cin>>k>>s;
if(s.size()>k){
  rep(i,k){cout<<s[i];}
  cout<<"...";
  exit(0);
}
cout<<s;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

int main(void)
{
  int n, a, b, c = 0, d = 0, i;
  char s[100001];
  
  scanf("%d %d %d", &n, &a, &b);
  scanf("%s", s);

  for (i = 0; i < n; i++) {
    if (s[i] == 'a' && d + c < a + b) {
      s[i] = 'y';
      d++;
    } else if (s[i] == 'b' && d + c < a + b && c < b) {
      s[i] = 'y';
      c++;
    }
  }

  for (i = 0; i < n; i++) {
    if (s[i] == 'y') {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
  
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{ 

   public static void main(String args[]) {
	 
	   Scanner s=new Scanner(System.in);
	   String a=s.next();
	   String b=s.next();
	   
	   int dp[][]=new int[a.length()+1][b.length()+1];
	   dp[0][0]=1;
	   for(int i=1;i<=a.length();i++) {
		   for(int j=1;j<=b.length();j++) {
			   if(a.charAt(i-1)==b.charAt(j-1)) {
				   dp[i][j]=dp[i-1][j-1] + 1;
			   }
			   else {
				   dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
			   }
		   }
	   }
	   
	   int i=a.length();
	   int j=b.length();
	   String str="";
	   while(i>0 && j>0) {
		   if(a.charAt(i-1)==b.charAt(j-1)) {
			   str=a.charAt(i-1)+str;
			   i--;
			   j--;
		   }else {
			   if(dp[i-1][j]==dp[i][j]) {
				   i--;
			   }else {
				   j--;
			   }
		   }
	   }
	   System.out.println(str);
   	
   }
}

Measured memory_bytes: 88664
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

ll solve(ll h) {
	if (h==1) return 1;

	ll val = solve(h/2);

	return val*2 + 1;
}
void testcase() {
    ll h; cin >> h;

    cout << solve(h) << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	readc(a, b, n);
	cout << min(b-1, n)*a/b;
}











Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <iomanip>
#include <utility>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

class UnionFind {
private:
    vector<int> parents;

    int root(int A) {
        if (parents[A] < 0) return A;
        return parents[A] = root(parents[A]);
    }

public:
    UnionFind(int N)
    : parents(N, -1)  // -なら親
    {
    }

    bool merge(int A, int B) {
        int rA = root(A);
        int rB = root(B);
        if (rA == rB) return false;
        if (parents[rA] > parents[rB]) swap(rA, rB);
        parents[rA] += parents[rB];
        parents[rB] = rA;
        return true;
    }

    ll size(int A) {
        return -parents[root(A)];
    }
};

#define Max 110000
ll N, M;
int A[Max], B[Max];
ll ans[Max];

int main(int argc, const char * argv[]) {
    N = inputValue();
    M = inputValue();
    rep(i, M) {
        A[i] = inputValue() - 1;
        B[i] = inputValue() - 1;
    }

    UnionFind uf(N);
    ll count = N * (N-1)/2;
    for (auto i = M-1; i >= 0; --i) {
        ans[i] = count;
        ll diff = uf.size(A[i]) * uf.size(B[i]);
        bool res = uf.merge(A[i], B[i]);
        if (res) {
            count -= diff;
        }
    }

    rep(i, M) {
        output(ans[i]);
    }

    return 0;
}


Measured memory_bytes: 3328
N = int(input())
A_list = [int(item) for item in input().split()]

all_sum = sum(A_list)

F_sum_list = [A_list[0]]

for j in range(1,N):
    F_sum_list.append(F_sum_list[-1] + A_list[j])

delta_list = [abs(all_sum - 2* i) for i in F_sum_list]

print(min(delta_list))

Measured memory_bytes: 29420
N,M,C = map(int,input().split())
B_List =  list(map(int,input().split()))
Counter = 0
for i in range(N):
    Corrent_List = list(map(int,input().split()))
    Number = 0
    for j in range(M):
        Number += Corrent_List[j]*B_List[j]
    Number += C
    if Number > 0:
        Counter += 1

print(Counter)

Measured memory_bytes: 9164
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var X = sc.nextInt();
        var x = sc.ArrayInt(N);

        var xx = x.ToList();
        xx.Add(X);
        xx = xx.OrderBy(i => i).ToList();

        var sa = new List<int>();
        for (int i = 1; i < xx.Count; i++) {
            sa.Add(Math.Abs(xx[i - 1] - xx[i]));
        }

        var ans = sa[0];
        for (int i = 1; i < sa.Count; i++) {
            ans = Gcd(ans, sa[i]);
        }

        WriteLine(ans);
    }

    public static int Gcd(int a, int b) {
        return a > b ? GcdRecursive(a, b) : GcdRecursive(b, a);
    }

    private static int GcdRecursive(int a, int b) {
        return b == 0 ? a : GcdRecursive(b, a % b);
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {

        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 25312
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

char s[100005];
int n;
void init(){
    scanf("%s", s);
}
void solve(){
    n = strlen(s);
    int ans = 0;
    for (int i = 0, j; i < n; i = j){
        j = i;
        while (j < n && s[i] == s[j]) ++j;
        ++ans;
    }
    printf("%d\n", ans - 1);
}
int main(){
    int T = 1;
    while (T--){
        init();
        solve();
    }
    return 0;
}

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

using namespace std;

//#define FILE_IO

typedef long long LL;

struct Block
{
    int w, s, v;
}a[1005];

int N;
LL dp[20005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    #endif

    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> a[i].w >> a[i].s >> a[i].v;

    sort(a + 1, a + N + 1,
         [](Block x, Block y) { return (x.w + x.s) < (y.w + y.s); });

    for(int i = 1; i <= N; i++)
    {
        for(int j = a[i].s; j >= 0; j--)
            if(j + a[i].w <= 20000)
                dp[j + a[i].w] = max(dp[j + a[i].w], dp[j] + a[i].v);
    }

    LL ans = 0;
    for(int i = 0; i <= 20000; i++)
        ans = max(ans, dp[i]);
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int gcd(int n, int m) {
    return n == 0 ? m : gcd(m % n, n);
}

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int result = gcd(a, b);
    for (int i = 1; i <= result; ++i) {
        if (result % i == 0) {
            k--;
            if (k == 0) {
                cout << result / i << endl;
                break;
            }
        }
    }
}

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

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    if (n[i] == '1')
      n[i] = '9';
    else
      n[i] = '1';
  }
  cout << n << endl;
  }


Measured memory_bytes: 256
import collections
import itertools

n, c = map(int, input().split())
ds = [list(map(int, input().split())) for _ in range(c)]
colors = [collections.Counter() for _ in range(3)]
for i in range(n):
    for j, color in enumerate(map(int, input().split())):
        colors[(i + j) % 3][color - 1] += 1
res = float('inf')
for cs in itertools.permutations(range(c), 3):
    s = 0
    for i in range(3):
        for k, v in colors[i].items():
            s += ds[k][cs[i]] * v
    res = min(res, s)
print(res)

Measured memory_bytes: 3436
l = input()
n = len(l)
mod = 10 ** 9 + 7
dp = [[0 for i in range(2)] for j in range(n + 1)]
dp[0][1] = 1
for i in range(n):
    if l[i] == "1":
        dp[i + 1][0] = dp[i][0] * 3 + dp[i][1]
        dp[i + 1][0] %= mod
        dp[i + 1][1] = dp[i][1] * 2
        dp[i + 1][1] %= mod
    else:
        dp[i + 1][0] = dp[i][0] * 3
        dp[i + 1][0] %= mod
        dp[i + 1][1] = dp[i][1]
        dp[i + 1][1] %= mod
print((dp[n][0] + dp[n][1]) % mod)

Measured memory_bytes: 25596
N = int(input())
a = list(map(int, input().split()))
r_table = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
rate = [0]*8
god = 0
for x in a:
    for id, y in enumerate(r_table):
        if x >= y:
            if id == 8:
                god += 1
                break
        else:
            rate[id-1] = 1
            break
print(max(sum(rate), 1), sum(rate) + god)


Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int n = 0;
    for(n=0; n<B; n++){
    if(1+(A-1)*n>=B){
       break;
    }
}
    System.out.println(n);
 }
}


Measured memory_bytes: 35860
import numpy as np
N, L = map(int, input().split())

tastes = [L+i for i in range(N)]
original_sum = np.sum(tastes)
diff = float('inf')
for n in range(N):
    tmp = abs(tastes[n])
    if tmp < diff:
        diff = tmp
if original_sum < 0:
    print(original_sum+diff)
else:
    print(original_sum-diff)


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

long long calc(int n, const vector<int>& options, const vector<int>& cost,
               const vector<array<int, 26>>& s, int dd, int nt, int ot, int total) {
  //long long x(total);
  int before(dd-1), after(dd+1);
  while (before >= 0 && options[before] != nt) before--;
  while (after < n && options[after] != nt) after++;
  int a(dd - before - 1), b(after - dd - 1), c(after - before - 1);
  int diff = c * (c+1) / 2 - a * (a+1) / 2 - b * (b+1) / 2;
  int before2(dd-1), after2(dd+1);
  while (before2 >= 0 && options[before2] != ot) before2--;
  while (after2 < n && options[after2] != ot) after2++;
  int a2(dd - before2 - 1), b2(after2 - dd - 1), c2(after2 - before2 - 1);
  int diff2 = c2 * (c2+1) / 2 - a2 * (a2+1) / 2 - b2 * (b2+1) / 2;
  return total - (long long) diff * cost[nt] + (long long) diff2 * cost[ot] + s[dd][nt] - s[dd][ot];
}
int main() {
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) {
      neg -= c[j] * (i - last[j]);
    }
    //cout << neg << 'n' << endl;
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    //cout << test + 1 << endl;
    options[i] = test;
    //cout << test + 1 << ' ' << max_score << endl;
    last[test] = i;
  }
  //cout << total << endl;
  for (int t = 1; t <= 10; ++t) {
    for (int dd = 0; dd < n; ++dd) {
      for (int tt = 0; tt < 26; ++tt) {
        if (tt == options[dd]) continue;
        int ot = options[dd];
        long long ns = calc(n, options, c, s, dd, tt, ot, total);
        if (ns > total) {
      		total = ns;
    	} else {
      		options[dd] = ot;
    	}
      }
    }
    
  }
  for (const int& i: options) cout << i + 1 << endl;
  //cout << total << endl;
  return 0;
}

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

int main () {
  int N, K;
  cin >> N >> K;

  ll r ;
  r = N / K;
  r = r*r*r;
  if(K % 2 == 0) {
    ll r1 = (N / (K/2) + 1) / 2;
    r += r1*r1*r1;
  }
  cout << r << endl;
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
    
  int comb_N = 0;
  int comb_M = 0;

  // 偶数 + 偶数 nC2
  // 奇数 + 奇数 mC2
  
  int n_denominator = 1;
  for (int i = N; i > N - 2; i--) {
    n_denominator *= i;
  }
  int m_denominator = 1;
  for (int i = M; i > M - 2; i--) {
    m_denominator *= i;
  }
  
  cout << ((n_denominator + m_denominator) / 2) << endl;
  
  return 0;
}

Measured memory_bytes: 256
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($N,$M) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$ans = 0;
for($i=0;$i<$N;$i++) {
  //$j-$i == $A[$i]+$A[$j]
  //-1をかける
  //-$j+$i == -$A[$i]-$A[$j];
  //+$jを足す
  //$i== -$A[$i]-$A[$j]+$j;
  //+$A[$i]を足す
  //$i+$A[$i]=-$A[$j]+$j
  //でいいのか？
  //$i+$A[$i]=$j-$A[$j]
  //ここはよくわからんｗ
  // => Li = Rj
  $LK=$i+$A[$i];
  $RK=$i-$A[$i];
  //LK=RKの数を足していく
  if (isset($L[$RK])) {
    $ans += $L[$RK];
  }
  if (!isset($L[$LK])) {
    $L[$LK]=1;
  }
  else {
    $L[$LK]++;
  }

}
printf("%d\n",$ans);


Measured memory_bytes: 40464
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a, mi = mod, ma = 0;
    for(int i=0;i<n;i++){
        cin >> a;
        mi = min(mi, a);
        ma = max(ma, a);
    }
    cout << ma - mi << endl;
    return 0;
}


Measured memory_bytes: 3648
#import io, os
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import sys
input = sys.stdin.buffer.readline

def main():
    R, C, K = map(int, input().split())
    A = [[0]*C for _ in range(R)]
    for i in range(K):
        r, c, v = map(int, input().split())
        r, c = r-1, c-1
        A[r][c] = v

    dp0 = [[0]*(C+1) for i in range(R+1)]
    dp1 = [[0]*(C+1) for i in range(R+1)]
    dp2 = [[0]*(C+1) for i in range(R+1)]
    dp3 = [[0]*(C+1) for i in range(R+1)]
    for i in range(R):
        for j in range(C):
            dp3[i][j] = max(dp3[i][j], dp2[i][j]+A[i][j])
            dp2[i][j] = max(dp2[i][j], dp1[i][j]+A[i][j])
            dp1[i][j] = max(dp1[i][j], dp0[i][j]+A[i][j])

            dp3[i][j+1] = max(dp3[i][j+1], dp3[i][j])
            dp2[i][j+1] = max(dp2[i][j+1], dp2[i][j])
            dp1[i][j+1] = max(dp1[i][j+1], dp1[i][j])
            dp0[i][j+1] = max(dp0[i][j+1], dp0[i][j])

            dp0[i+1][j] = max(dp0[i+1][j], dp0[i][j])
            dp0[i+1][j] = max(dp0[i+1][j], dp1[i][j])
            dp0[i+1][j] = max(dp0[i+1][j], dp2[i][j])
            dp0[i+1][j] = max(dp0[i+1][j], dp3[i][j])
    #print(dp)
    print(max([dp0[R-1][C-1], dp1[R-1][C-1], dp2[R-1][C-1], dp3[R-1][C-1]]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 431472
/// 数、回数
let n, k = stdin.ReadLine().Split() |> Array.map int64 |> fun [|x1; x2|] -> x1, x2
/// 体力[番号]
let hs = stdin.ReadLine().Split() |> Array.map int64

// nlognまで
/// 上からkまでの値を0にし、他は足し算
hs |> Seq.sortDescending |> Seq.skip (min k n |> int) |> Seq.sum |> stdout.WriteLine

Measured memory_bytes: 39740
n = int(input())
mod = 10**9+7
fun = [1]*(n+1)
for i in range(1,n+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n+1)
rev[n] = pow(fun[n],mod-2,mod)
for i in range(n-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod

def nCr(n,r):
    if r > n:
        return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

l = list(map(int,input().split()))
db = sum(l) - n*(n+1)//2
idx = [i for i in range(n+1) if l[i] == db]
a,b,c = idx[0],idx[1]-idx[0]-1,n-idx[1]
print(n)
for k in range(2,n+2):
  print((nCr(a+b+c,k)+nCr(a+b+c,k-2)+nCr(a+b+c,k-1)*2-nCr(a+c,k-1))%mod)


Measured memory_bytes: 21748
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
//int a[100001];
int main(){
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    int ans=H*W;
    ans-=((h*W)+(H-h)*w);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 2005, mod = (int) 0;
struct data {
	int sum[N][N];
	data() {
		memset(sum, 0, sizeof sum);
	}
	int add(int x, int y, int z) { sum[1 + x][1 + y] += z; }
	void build(int n, int m) {
		for (int j = 1; j <= n; ++j)
			for (int i = 1; i <= m; ++i)
				sum[j][i] += sum[j - 1][i] + sum[j][i - 1] - sum[j - 1][i - 1];
	}
	int ask(int xl, int xr, int yl, int yr) {
		return sum[xr][yr] + sum[xl][yl] - sum[xr][yl] - sum[xl][yr];
	}
} a, b, c;
string mat[N];
int main() {
	ios_base::sync_with_stdio(0);
	int n, m, q;
	cin >> n >> m >> q;
	for (int j = 0; j < n; ++j)
		cin >> mat[j];
	for (int x = 0; x < n; ++x)
		for (int y = 0; y < m; ++y) {
			if (mat[x][y] == '1') {
				a.add(x, y, 1);
				if (x + 1 != n && mat[x + 1][y] == '1') b.add(x, y, 1);
				if (y + 1 != m && mat[x][y + 1] == '1') c.add(x, y, 1);
			}
		}
	a.build(n, m);
	b.build(n - 1, m);
	c.build(n, m - 1);
	while (q--) {
		int xl, yl, xr, yr;
		cin >> xl >> yl >> xr >> yr;
		if (xl > xr) swap(xl, xr);
		if (yl > yr) swap(yl, yr);
		--xl;
		--yl;
		cout << a.ask(xl, xr, yl, yr) - b.ask(xl, xr - 1, yl, yr) - c.ask(xl, xr, yl, yr - 1) << '\n';
	}
}




Measured memory_bytes: 53248