akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int n, p, ans;
  while (cin >> n, cin >> p, n && p) {
    vector<int> has(n, 0);
    int stone = p;
    while (true) {
      for (int i = 0; i < n; i++) {
        if (stone > 0) {
          stone--;
          has[i]++;
          if (has[i] == p) {
            ans = i;
            goto FIN;
          }
        } else {
          stone += has[i];
          has[i] = 0;
        }
        //cerr << has[i] << " ";
      }
      //cerr << endl;
    }
  FIN:
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3000
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int N;
double ans = 0.0;
std::vector<std::vector<double>> dp(3000, std::vector<double>(3000, -1.0));

double coins(vector<double>& v, int i, int tail_size)
{
  if (i == v.size())
  {
    return 1.0;
  }
  double& ans = dp[i][tail_size];
  if (ans != -1.0)
  {
    return ans;
  }
  ans = v[i] * coins(v, i+1, tail_size);
  if (tail_size < N/2)
  {
    ans += (1.0 - v[i]) * coins(v, i+1, tail_size+1);
  }
  return ans;
}

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

  std::cin >> N;

  vector<double> head(N, 0.0);

  for (auto& p : head)
  {
    std::cin >> p;
  }

  auto ans = coins(head, 0, 0);

  std::cout << std::setprecision(10) << ans;

  return 0;
} 

Measured memory_bytes: 70912
#include <stdio.h>

int main(void){
    while(1){
        int n,x,i,j,k,cnt=0;
        scanf("%d %d",&n,&x);
        if(n==0&&x==0) break;

        for(i=1;i<=n-2;i++){
            for(j=i+1;j<=n-1;j++){
                for(k=j+1;k<=n;k++){
                    if(i+j+k==x) cnt++;
                }
            }
        }

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

    return 0;
}

Measured memory_bytes: 604
n,a,b = STDIN.gets.chomp.split(" ").map(&:to_i)
result = 0
 
(1..n).each do |i|
  j = i
  sum = 0
  while j > 0
    sum += j % 10
    j = j / 10
  end
  if sum >= a && sum <= b
    result += i
  end
end
 
puts result

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


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

    long long N,K;
    cin >> N  >>K;

    long long ans=0;
    for(long long i=K;i<=N+1;i++){
        ans=(ans+(i*N-i*(i-1)+1))%1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define END getchar();getchar();return 0
#define inf 1000000007

signed main() {
	int n, one = 1;
	cin >> n;
	vector<int>b,c;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		b.push_back(a);
	}
	boutarou:;
	for (int i = b.size() - 1; i >= 0; i--) {
		if (b[i] - 1 == i) {
			c.push_back(b[i]);
			b.erase(b.begin()+i);
			if (b.empty())goto finish;
			goto boutarou;
		}
	}
	cout << -1 << endl;
	END;
	finish:;
	reverse(c.begin(), c.end());
	for (int i = 0; i < n; i++) {
		cout << c[i] << endl;
	}

	END;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

int read()
{
	int x=0,f=1;char c=getchar();
	while(c==' '||c=='\n'||c=='-')
	{if(c=='-') f=-f;c=getchar();}
	while(c>='0'&&c<='9')
	{x=x*10+(c-'0');c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int main(void)
{

	//freopen("testdata.in","r",stdin);
	//freopen("testdata.out","w",stdout);

	char c;

	cin>>c;

	c=c+1;

	cout<<c<<endl;

	return 0;

}

Measured memory_bytes: 888
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

using pii = pair<int64_t, int64_t>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
// }}} End

constexpr int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t W, H, N; cin >> W >> H >> N;

    auto mat = make_v(true, H, W);

    for (size_t i = 0; i < N; ++i) {
        size_t X, Y, a; cin >> X >> Y >> a;

        if (a == 1) {
            for (size_t y = 0; y < H; ++y) {
                for (size_t x = 0; x < X; ++x) {
                    mat[y][x] = false;
                }
            }
        } else if (a == 2) {
            for (size_t y = 0; y < H; ++y) {
                for (size_t x = X; x < W; ++x) {
                    mat[y][x] = false;
                }
            }
        } else if (a == 3) {
            for (size_t y = 0; y < Y; ++y) {
                for (size_t x = 0; x < W; ++x) {
                    mat[y][x] = false;
                }
            }
        } else {
            for (size_t y = Y; y < H; ++y) {
                for (size_t x = 0; x < W; ++x) {
                    mat[y][x] = false;
                }
            }
        }
    }

    intmax_t res = 0;
    for (size_t i = 0; i < H; ++i) {
        for (size_t j = 0; j < W; ++j) {
            res += (mat[i][j]);
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
from math import cos, sin, pi
from itertools import combinations
N, L = map(int, input().split())
T = [int(input()) for _ in range(N)]
PI2oL = 2*pi/L

csum, ssum = 0, 0
count = 0
for i, j in combinations(range(N), 2):
    count += 1
    mid1, num2 = (T[i] + T[j]) / 2, j - i - 1
    mid2, num1 = (mid1 + L/2) % L, N - num2 - 2
    csum += cos(PI2oL*mid1) * num1 + cos(PI2oL*mid2) * num2
    ssum += sin(PI2oL*mid1) * num1 + sin(PI2oL*mid2) * num2

print(csum/count/(N-2)*3, ssum/count/(N-2)*3)


Measured memory_bytes: 46240
#include <iostream>
using namespace std;
int a[2005][2005];
void solve(int x)
{
 if(x==1)
 {
  a[1][1]=1;
  return;
 }
 solve(x-1);
 int l=(1<<(x-1));
 for(int i=1;i<l;i++)
  for(int j=1;j<l;j++)
   a[i+l][j]=a[i][j+l]=a[i+l][j+l]=a[i][j];
 a[l][l]=1;
}
int main()
{
 int n,m;
 cin>>n>>m;
 solve(max(n,m));
 for(int i=1;i<(1<<n);i++)
 {
  for(int j=1;j<(1<<m);j++)
   cout<<a[i][j];
  cout<<endl;
 }
 return 0;
}

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

const int DIM = 55;

char a[DIM][DIM], b[DIM][DIM];

int main( void ) {
    
    int n, m;
    cin >> n >> m;
    
    for( int i = 1; i <= n; i ++ )
        cin >> ( a[i] + 1 );
    for( int i = 1; i <= m; i ++ )
        cin >> ( b[i] + 1 );
    
    bool ans = false;
    for( int i = 1; i <= n - m + 1; i ++ ) {
    for( int j = 1; j <= n - m + 1; j ++ ) {
        bool ok = true;
        
        for( int ii = 1; ii <= m; ii ++ )
        for( int jj = 1; jj <= m; jj ++ )
            if( b[ii][jj] != a[i + ii - 1][j + jj - 1] )
                ok = false;
        
        ans |= ok;
    } }
    
    cout << ( ( ans == true ) ? "Yes" : "No" );
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n;
  long long t,f,a[100000]={},b[100000]={},tmp1,tmp2,result=0;
  
  cin>>t>>n;
  for(int i=0;i<n;i++) cin>>a[i]>>b[i];
  for(int i=0;i<n;i++) b[i]-=a[i];
  long long c[100000]={b[0]};
  for(int i=1;i<n;i++) c[i]=b[i]+c[i-1];

  for(int i=0;i<n;i++){
    //if(a[i]+t>a[n-1]+b[n-1]) break;
    int l=0,r=n,m;
    while(r>l){
      m=(l+r)/2;
      if(a[i]+t==a[m]){
	l=m;
	break;
      }
      if(a[i]+t>a[m]) l=m+1;
      else if(a[i]+t<a[m]) r=m;
    }
    l--;
    if(l<0) l=0;
    //    cout<<i<<"now: "<<l<<endl;
    long long add=min(a[i]+t-a[l],b[l]);
    if(i){
      if(l) result=max(result,c[l-1]-c[i-1]+add);
    } else {
      if(l) result=max(result,c[l-1]+add);
      else result=max(result,add);
    }
  }
  cout<<result<<endl;
  
  return 0;

}
      
    

Measured memory_bytes: 5440
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            ary[i] = a;
            sum += a;
        }
        int temp = 0;
        int ans = sum;
        for (int i = 0; i < n; i++) {
            temp += ary[i];
            ans = Math.min(ans, Math.abs(sum - temp - temp));
        }
        System.out.println(ans);
    }
}

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

int main(){
  int n, flag=0;
  long long max;
  cin >> n;
  vector<long long> h(n);
  for(int i; i<n; i++){
    cin >> h[i];
  }

  for(int i=n-1; i>1; i--){
    if(h[i-1]-1==h[i]){
      h[i-1] = h[i-1] - 1;
    }else if(h[i-1]-1>h[i]){
      flag=1;
    }
    if(flag) break;
  }

  if(flag) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

ll f(ll x, ll m) {
    return x % m;
}

ll sums[201010], vis[202020];

int main() {
    ll N, X, M;
    cin >> N >> X >> M;

    if (N <= 1000000) {
        ll sum = X;
        ll A = f(X * X, M);
        rep(i, N-1) {
            sum += A;
            A = f(A * A, M);
        }
        cout << sum << endl;
    }
    else {
        ll ans = 0, cnt = 0;
        fill(vis, vis+M, -1);
        while (N > 0) {
            if (vis[X] >= 0) {
                // 一度見たところ
                ll len = cnt - vis[X];
                ll tmpAns = ans;
                ans += (tmpAns - sums[vis[X]]) * (N / len);
                N %= len;
                break;
            }

            if (N > 0) {
                vis[X] = cnt++;
                ans += X;
                sums[cnt] = ans;
                X = f(X * X, M);
                N--;
            }
        }
        while (N > 0) {
            if (N > 0) {
                ans += X;
                X = f(X * X, M);
                N--;
            }
        }

        cout << ans << endl;
    }
}


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

int main()
{
    int n,m,w;
    cin>>n>>m>>w;
    vector<vector<int>>row(n),col(m);
    vector<int>cc(m,0),rr(n,0);
    for(int i=0;i<w;i++)
    {
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        row[x].push_back(y);
        col[y].push_back(x);
        rr[x]++;
        cc[y]++;
    }
    int val=0;
    int ind=-1;
    for(int i=0;i<n;i++)
    {
        int siz = row[i].size();
        if(siz>val)
        {
            val=row[i].size();
            ind=i;
        }
    }
    int ans = row[ind].size();
    for(int i=0;i<ans;i++)
    {
        cc[row[ind][i]]--;
    }
    val=0;
    for(int i=0;i<m;i++)
    {
        val = max(val,cc[i]);
    }
    int tot = ans+val;
    //column;
     val=0;
    ind=-1;
    for(int i=0;i<m;i++)
    {
        int siz = col[i].size();
        if(siz>val)
        {
            val=col[i].size();
            ind=i;
        }
    }
     ans = col[ind].size();
    for(int i=0;i<ans;i++)
    {
        rr[col[ind][i]]--;
    }
    val=0;
    for(int i=0;i<n;i++)
    {
        val = max(val,rr[i]);
    }
    int newtot = ans+val;
    cout<<max(newtot,tot)<<endl;


}


Measured memory_bytes: 38360
#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> bookPrice(n, 0);
    vector<vector<int>> skill(n, vector<int>(m, 0));
    rep(_n, 0, n) {
        cin >> bookPrice[_n];
        rep(_m, 0, m) { cin >> skill[_n][_m]; }
    }

    // int ans = -1;
    int maxPrice = 12 * 101001;
    int ans      = maxPrice;
    // 全列挙
    for (int bookBit = 0; bookBit < (1 << n); bookBit++) {
        // printf("search: ");
        // int hoge = bookBit;
        // cout << bitset<5>(hoge) << endl;

        int totalPrice = 0;
        vector<int> totalSkill(m, 0);
        // 各本について
        rep(bitIdx, 0, n) {
            // 本を買うなら
            if (bookBit & (1 << bitIdx)) {
                //
                totalPrice += bookPrice[bitIdx];
                rep(_m, 0, m) {
                    //
                    totalSkill[_m] += skill[bitIdx][_m];
                }
            }
        }
        // printf("  tot: %d", totalPrice);

        bool isOver = true;
        // ボーダを超えたか
        // rep(_m, 0, m) {
        for (int skl : totalSkill) {
            if (skl < x) {
                isOver = false;
                break;
            }
        }
        if (!isOver) {
            // printf("  -> under\n");
            continue;
        }
        // printf("  -> over");

        // 最安値段か
        ans = min(ans, totalPrice);
        // printf(" -> ans: %d\n", ans);
    }

    if (ans == maxPrice) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
/*
  AOJ 2130
  Title:Billion Million Thousand
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#include <limits.h>

#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
int sis,ret;
int n;

char usoexp[201];
struct dict_st
{
  char word[101];
  int  sisuu;
  int  len;
} dict[100];

int shortest_exp(int s)
{
  int i,j,min_,ss;
  int memo[20000];

  for(i=0;i<200;i++)
    memo[i]=-1;

  memo[s]=0;
  for(i=s-1;i>=0;i--)
    {
      min_=INT_MAX;
      for(j=0;j<n;j++)
	{
	  ss=INT_MAX;
	  if((i+dict[j].sisuu<=s) && 
	     (s-i>=dict[j].sisuu) && memo[i+dict[j].sisuu]!=INT_MAX)
	    {
	      //printf("::%d %d\n",j,dict[j].sisuu);
	      ss=memo[i+dict[j].sisuu]+dict[j].len;
	    }
	  min_=min(min_,ss);
	}
      //printf(":%d %d\n",i,min_);
      memo[i]=min_;
    }
  return(memo[0]);
}

int str2sisuu(char *uso,int len)
{
  int i,j,max_,ss;
  int memo[201];

  for(i=0;i<200;i++)
    memo[i]=-1;
  memo[len]=0;
  for(i=len-1;i>=0;i--)
    {
      max_=0;ss=0;
      for(j=0;j<n;j++)
	{
	  if((i+dict[j].len<=len) && 
	     0==strncmp(uso+i,&dict[j].word[0],dict[j].len)
	     && memo[i+dict[j].len]!=-1)
	    ss=memo[i+dict[j].len]+dict[j].sisuu;
	  max_=max(max_,ss);
	}
      memo[i]=max_;
    }
#ifdef DEBUG  
  for(i=0;i<=len;i++)
    if(memo[i])
      printf("[%d]%d",i,memo[i]);
#endif  
  return(memo[0]);
}
main()
{
  int i,cas;

  cas=0;
  while(scanf("%d",&n) && n)
    {
      memset(dict,0,sizeof(dict));
      for(i=0;i<n;i++)
	{
	  scanf("%s %d",&dict[i].word[0],&dict[i].sisuu);
	  dict[i].len=strlen(&dict[i].word[0]);
	}
      scanf("%s",usoexp);

      sis=str2sisuu(usoexp,strlen(&usoexp[0]));
#ifdef DEBUG
      printf("sisuu=%d\n",sis);
#endif
      ret=shortest_exp(sis);
      cas++;
      printf("Case %d: %d\n",cas,ret);
    }
  return(0);
}

Measured memory_bytes: 656
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n; cin >> n;
  int a[n]; int b[n]; int c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<int>> dp(n, vector<int>(3));
  dp[n-1][0] = max(b[n-1], c[n-1]);
  dp[n-1][1] = max(a[n-1], c[n-1]);
  dp[n-1][2] = max(a[n-1], b[n-1]);
  for (int i = n-2; i >= 0; i--) {
    dp[i][0] = max(b[i]+dp[i+1][1], c[i]+dp[i+1][2]);
    dp[i][1] = max(a[i]+dp[i+1][0], c[i]+dp[i+1][2]);
    dp[i][2] = max(a[i]+dp[i+1][0], b[i]+dp[i+1][1]);
  }
  cout << max(max(dp[0][0], dp[0][1]), dp[0][2]);
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
/*
created on: 19/4/2020
*/
void solve();
lli ans;
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
void solve(){
  int N, M;
  cin>>N>>M;
  lli t;
  lli sum = 0;
  while(M--){
    cin>>t;
    sum+=t;
  }
  if(sum<=N)
  cout<<N-sum<<Endl;
  else
  cout<<-1<<Endl;
}


Measured memory_bytes: 3612
import java.util.Scanner;

class Main{
       public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String number;
    	String change;
    	
    	char[] ca;
    	int[] count = new int[26];
    	int num;
    	char alphabet = 'a';
    	
    	while(scan.hasNext()){
    		number = scan.nextLine();
        	change = number.toLowerCase();
        	ca = change.toCharArray();
        	
	    	for(int i = 0; i < ca.length; i++){
	    		num = ca[i] - 'a';
	    		if(num >= 0 && num < 26){
	    			count[num]++;
	    		}
	    	}
     	}
     		
    	
    	for(int i = 0; i < 26; i++){;
    		System.out.println(alphabet + " : " + count[i]);
    		alphabet += 1;
    	}
     }
}

Measured memory_bytes: 25968
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int m=1e9+7;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%m;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans)%m;
    return (x*(ans*ans)%m)%m;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
int val(int q,int a[],int b[],int n,int k)
{
    int vis[n+1];
    for(int i=1;i<=n;i++) vis[i]=0;
    vector<int> chk;
    while(1)
    {
        if(vis[q]) break;
        chk.push_back(b[q]);
        vis[q]=chk.size();
        q=a[q];
    }
   // cout<<"nother1"<<endl;
    int e=chk.size();
   // for(int i=0;i<e;i++) cout<<chk[i]<<" ";
   // cout<<endl;
    int t=e-vis[q]+1;
   // cout<<t<<endl;
    int cys=0;
    for(int i=vis[q]-1;i<e;i++)
    {
        cys+=chk[i];
    }
   // cout<<cys<<endl;
    if(k>e)
    {
    //cout<<"hii"<<endl;
        if(cys<0)
        {
            int sum=0;
            int bcm=-1e12;
            for(int i=0;i<e;i++)
            {
                sum+=chk[i];
                bcm=max(bcm,sum);
            }
            return bcm;
        }
        int bcm=-1e12;
        int sum=0;
        for(int i=0;i<vis[q]-1;i++)
        {
            sum+=chk[i];
            bcm=max(bcm,sum);
        }
        //cout<<bcm<<endl;
        if(vis[q]==1) bcm=0;
        int acm=0;
        sum=0;
        int mxt[t+1];
        mxt[0]=0;
        for(int i=vis[q]-1;i<e;i++)
        {
            sum+=chk[i];
            acm=max(acm,sum);
            mxt[i-vis[q]+2]=acm;
        }
        int cc=k-vis[q]+1;
        int c=cc/t;
        if(cc%t==0)
        {
            return max(bcm+cys*(c-1)+mxt[t],bcm);
        }
        else
        {
            return max(bcm,bcm+cys*c+mxt[cc%t]);
        }
    }
    else
    {
        int bcm=-1e12;
        int sum=0;
        for(int i=0;i<k;i++)
        {
            sum+=chk[i];
            bcm=max(bcm,sum);
        }
        return bcm;
    }

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
   // cin>>t;
    // int tmp=t;
    while(t--)
    {
       int n,k;
       cin>>n>>k;
       int a[n],b[n];
       for(int i=1;i<=n;i++) cin>>a[i];
       for(int i=1;i<=n;i++) cin>>b[i];
       int mx=-1e12;
       for(int i=1;i<=n;i++)
       {
            mx=max(mx,val(i,a,b,n,k));
            //if(mx<0) cout<<i<<endl;
       }
       cout<<mx<<endl;
    }
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        if((a+b)%2==0)cout<<(a+b)/2<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int d;
  cin>>d;
  vector<int>c(26);
  for(int i=0;i<26;i++){
    cin>>c[i];
  }
  vector<vector<int>>s(d,vector<int>(26));
  for(int i=0;i<d;i++){
    for(int j=0;j<26;j++){
      cin>>s[i][j];
    }
  }
  vector<int>t(d);
  for(int i=0;i<d;i++){
    cin>>t[i];
  }
  int ans=0;
  vector<int>score(26);
  vector<int>last(26,-1);
  for(int i=0;i<d;i++){
      ans+=s[i][t[i]-1];last[t[i]-1]=i;
      for(int j=0;j<26;j++){
       ans-=(c[j]*(i-last[j]));
  }   cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 0 || ((b - a + 1) % 2 == 0 && b < 0))cout << "Positive" << endl;
	else if (a <= 0 && b >= 0)cout << "Zero" << endl;
	else cout << "Negative" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <map>
#include <assert.h>
 
using namespace std;

struct Edge {
    int to, cap, rev;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {
        assert(this->cap >= 0);
    }
};

// ?????§????????????O(F|E|)??§?§£???
class FordFulkerson {
public:
    unsigned int num_of_node = 0;   // ???????????°
    map<int, vector<Edge>> G;       // ??°???????????£??\???????????¨???
    vector<bool> used;              // DFS??§?????§??????????????????????????°

    FordFulkerson(unsigned int num_of_node) : num_of_node(num_of_node){
    }

    // from??????to??????????????????cap????????¨?????????????????°?????????????????????
    void add_edge(int from, int to, int cap) {
        this->G[from].push_back(Edge(to, cap, (int)this->G[to].size()));        // ???
        this->G[to].push_back(Edge(from, 0, (int)this->G[from].size() - 1));    // ??????
    }

    // s??????t???????????§???????±??????? O(F|E|)
    int max_flow(int s, int t) {
        int flow = 0;
        while (true) {
            this->used = vector<bool>(this->num_of_node, 0);
            int f = dfs(s, t, INT_MAX);
            if (f == 0) { return flow; }
            flow += f;
        }
    }

private:
    // v??????t???f???????????¨??????????????????
    int dfs(int v, int t, int f) {
        if (v == t) { return f; }
        used[v] = true;
        for (Edge &e : G[v]) {
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;                 // ???
                    G[e.to][e.rev].cap += d;    // ??????
                    return d;
                }
            }
        }
        return 0;
    }

};


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int V, E;
    cin >> V >> E;
    FordFulkerson ff(V);
    for (int i = 0; i < E; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        ff.add_edge(u, v, c);
    }
 
    cout << ff.max_flow(0, V - 1) << endl;
    return 0;
}

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

int main(){
	int n,t,ans=1005;
	cin>>n>>t;
	for(int i=0; i<n; i++){
		int a,b;
		cin>>a>>b;
		if(b<=t)ans=min(ans,a);
	}
	if(ans==1005)puts("TLE");
	else cout<<ans<<endl;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
  	string x, y;
  	cin >> x >> y;
  	if(x==y) cout << "=" << endl;
	else if(x<y) cout << "<" << endl;
  	else cout << ">" << endl;
	return;
}

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


Measured memory_bytes: 256
from collections import deque
N = int(input())
A = [int(input()) for _ in range(N)] 

A.sort()
q = deque(A)

#小さいの中心
B = [0] * N


center = N // 2
minimum = q.popleft()
B[center] = minimum
left = center - 1
right = center + 1
cnt = 0
while q:
    if cnt % 4 == 0:
        num = q.pop()
        B[left] = num
        left -= 1
    elif cnt % 4 == 1:
        num = q.pop()
        B[right] = num
        right += 1
    elif cnt % 4 == 2:
        num = q.popleft()
        B[left] = num
        left -= 1
    elif cnt % 4 == 3:
        num = q.popleft()
        B[right] = num
        right += 1
    
    cnt += 1

ans_b = 0
for a,b in zip(B, B[1:]):
    ans_b += abs(a-b)

# 大きいの中心
q = deque(A)

B = [0] * N

center = N // 2
maximum = q.pop()
B[center] = maximum

left = center - 1
right = center + 1
cnt = 0
while q:
    if cnt % 4 == 2:
        num = q.pop()
        B[left] = num
        left -= 1
    elif cnt % 4 == 3:
        num = q.pop()
        B[right] = num
        right += 1
    elif cnt % 4 == 0:
        num = q.popleft()
        B[left] = num
        left -= 1
    elif cnt % 4 == 1:
        num = q.popleft()
        B[right] = num
        right += 1
    
    cnt += 1
#print("--", B, center)

ans_c = 0
for a,b in zip(B, B[1:]):
    ans_c += abs(a-b)




print(max(ans_b, ans_c))

Measured memory_bytes: 9720
#include<iostream>
#include<iomanip>
#include<complex>
using namespace std;
typedef complex<int> xy_t;

xy_t P[101];

double cross(xy_t p,xy_t q){
    return (conj(p)*q).imag();
}

int main(){
    int n;
    cin>>n;
    int x,y;
    for(int i=0;i<n;++i){
        cin>>x>>y;
        P[i]=xy_t(x,y);
    }

    double S=0.0;
    for(int i=0;i<n-2;++i){
        S+=cross(P[i+1]-P[0],P[i+2]-P[0])/2;
    }
    cout<<fixed<<setprecision(1)<<S<<"\n";
}

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

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var line = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var a = line[0];
        var b = line[1];

        var ans = a < b ? a : b;
        var notans = a < b ? b : a;

        System.Console.WriteLine(string.Join("",Enumerable.Repeat(ans, notans).ToList()));
    }
}



Measured memory_bytes: 13396
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
struct P{double x,y;};

void k(int n,P a,P b){
  if(n==0)return;
  P s,t,u;
  double th=M_PI*60.0/180.0;
  s.x=(2.0*a.x+1.0*b.x)/3;
  s.y=(2.0*a.y+1.0*b.y)/3;
  t.x=(1.0*a.x+2.0*b.x)/3;
  t.y=(1.0*a.y+2.0*b.y)/3;
  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;
  k(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  k(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  k(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  k(n-1,t,b);
} 

int main(){
  int n;
  P a,b;
  a.x=0,a.y=0,b.x=100,b.y=0;
  cin>>n;
  printf("%.8f %.8f\n",a.x,a.y);
  k(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}

Measured memory_bytes: 3196
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=pow(10,18);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  ll n;cin>>n;
  vector<ll>count(5,0);
  rep(i,n){
    string s;cin>>s;
    if(s[0]=='M')count[0]++;
    if(s[0]=='A')count[1]++;
    if(s[0]=='R')count[2]++;
    if(s[0]=='C')count[3]++;
    if(s[0]=='H')count[4]++;
  }
  ll ans=0;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      for(int k=j+1;k<5;k++)ans+=count[i]*count[j]*count[k];
    }
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed;
  cout<<setprecision(30);
  return solve();
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Average Length
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 8;
const int NBITS = 1 << MAX_N;

/* typedef */

/* global variables */

int xs[MAX_N], ys[MAX_N];
double ds[MAX_N][MAX_N];
double dp0[NBITS][MAX_N];
int dp1[NBITS][MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);

  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int dx = xs[j] - xs[i], dy = ys[j] - ys[i];
      ds[i][j] = ds[j][i] = sqrt(dx * dx + dy * dy);
    }

  for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
    dp0[bi][i] = 0.0, dp1[bi][i] = 1;

  int nbits = 1 << n;
  for (int bits = 1; bits < nbits; bits++)
    for (int i = 0; i < n; i++)
      for (int j = 0, bj = 1; j < n; j++, bj <<= 1)
	if (! (bits & bj)) {
	  dp0[bits | bj][j] += dp0[bits][i] + ds[i][j] * dp1[bits][i];
	  dp1[bits | bj][j] += dp1[bits][i];
	}
  
  double sum = 0.0;
  for (int i = 0; i < n; i++) sum += dp0[nbits - 1][i];

  int f = 1;
  for (int i = 1; i <= n; i++) f *= i;

  printf("%.10lf\n", sum / f);
  return 0;
}


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

int main() {
	string s; cin >> s;
	string ans = "AC";
	int L = s.size();

	if (s[0] != 'A') ans = "WA";

	int cnt = 0;
	for (int i = 1; i < L; i++) {
		if (isupper(s[i])) {
			if (i == 1 || i == L - 1 || s[i] != 'C') {
				ans = "WA";
			}
			cnt++;
		}
	}

	if (cnt != 1) ans = "WA";

	cout << ans << endl;

	return 0;
}


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

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

	cout << max(0, c-(a-b)) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    if(n % 3 == 0){
        map<int, int> mp;
        rep(i, n)mp[a[i]]++;
        if(mp.size() > 3){
            cout << "No" << endl;
            return 0;
        }
        int m = 0;
        for(auto p : mp){
            int cnt = p.second;
            if(cnt % (n/3) != 0){
                cout << "No" << endl;
                return 0;
            }
            m ^= p.first;
        }
        if(m == 0){
            cout << "Yes" << endl;
            return 0;
        }else{
            if(mp.size() == 2 && mp[0] == n/3){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }
    }else{
        set<int> s;
        rep(i, n)s.insert(a[i]);
        if(s.size() == 1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 7152
N, Ma, Mb = map(int, input().split())
a = [0 for _ in range(N)]
b = [0 for _ in range(N)]
c = [0 for _ in range(N)]
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
inf = 1000000
nmax = 40
abmax = 10
dp = [[[inf for _ in range(nmax * abmax + 1)] for _ in range(nmax * abmax + 1)] for _ in range(nmax + 1)]
dp[0][0][0] = 0
for i in range(N):
    for ca in range(nmax * abmax + 1):
        for cb in range(nmax * abmax + 1):
            if(dp[i][ca][cb] == inf):
                continue
            dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb])
            dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i])
ans = inf
for ca in range(1, nmax * abmax + 1):
    for cb in range(1, nmax * abmax + 1):
        if ca * Mb == cb * Ma:
            ans = min(ans, dp[N][ca][cb])
print(-1 if ans == inf else ans)

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

int N;

int main(){
	cin >> N;
	int num = (N % 2 == 1 ? N : N + 1);
	vector<pair<int, int>> res;
	for(int i = 1; i <= N; i++){
		for(int j = i + 1; j <= N; j++){
			if(i + j == num) continue;
			res.push_back(make_pair(i, j));
		}
	}
	cout << res.size() << endl;
	for(int i = 0; i < res.size(); i++) cout << res[i].first << ' ' << res[i].second << endl;
	return 0;
}

Measured memory_bytes: 384
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == t[i])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    int H, W;
    int N;
    Color[] cs;
    int[][] ans;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        N = sc.nextInt();
        cs = new Color[N];
        for (int i = 0; i < N; i++) {
            cs[i] = new Color(i+1, sc.nextInt());
        }
        ans = new int[H][W];
    }

    private void solve() {
        PriorityQueue<Color> queue =
                new PriorityQueue<>((c1, c2) -> Integer.compare(c2.num, c1.num));
        for (Color c: cs)
            queue.add(c);
        boolean flip = false;
        Color c = queue.poll();
        for (int i = 0; i < H; i++) {
            if (flip) {
                for (int j = W - 1; j >= 0; j--) {
                    if (c.num == 0)
                        c = queue.poll();
                    ans[i][j] = c.color;
                    c.num--;
                }
                flip = false;
            }
            else {
                for (int j = 0; j < W; j++) {
                    if (c.num == 0)
                        c = queue.poll();
                    ans[i][j] = c.color;
                    c.num--;
                }
                flip = true;
            }
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W-1; j++) {
                sb.append(ans[i][j]);
                sb.append(" ");
            }
            sb.append(ans[i][W-1]);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }

    private class Color {
        int color;
        int num;
        Color(int c, int n) {
            color = c;
            num = n;
        }
    }
}


Measured memory_bytes: 35280
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

static void ABC120A_FavoriteSound();
static void ABC120D_DecayedBridges();
static void ABC119C_SyntheticKadomatsu();

#if 1
int main()
{
	//ABC120D_DecayedBridges();
	//ABC119C_SyntheticKadomatsu();
	ABC120A_FavoriteSound();

	fflush(stdout);
	return 0;
}
#endif

static void ABC120A_FavoriteSound()
{
	int A = 0, B = 0, C = 0;

	scanf(" %d %d %d", &A, &B, &C);

	printf("%d\n", (B / A) > C ? C : B / A);
}


Measured memory_bytes: 256
def main():
    N,K = map(int, input().split())
    p = list(map(int, input().split()))
    if N>K:
        esum = [0]*N
        psum = [0]*(N-K)
        esum[0] = p[1]
        for i in range(1,K):
            esum[i] = esum[i-1]+p[i]
        for i in range(K,N):
            esum[i] = esum[i-1]+p[i]
            psum[i-K] = esum[i]-esum[i-K]
        ans = (max(psum)+K)*0.5
    else:
        ans = (sum(p)+K)*0.5

    print(ans)
    return

if __name__=="__main__":
    main()

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

int main(){
    ll a;
    char b_[8];
    float c;
    cin >> a >> c;
    int b=(c*100+0.5);
    /*if(b_[0] != '.') b+=(b_[0]-'0')*100;
    if(b_[1] != '\0'){
        if(b_[2] != '\0'){
            b+=(b_[2]-'0')*10;
            if(b_[3] != '\0'){
                b+=(b_[3]-'0');
            }
        }
    }*/
    ll ans;
    ans = a*b;
    ans /=100;
    cout << ans << endl;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef long double LD;
typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1 << 30;

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

	int A, B;
	cin >> A >> B;
	if (B != 1 && (A == 1 || A > B)) {
		cout << "Alice" << endl;
	} else if (A != 1 && (B == 1 || B > A)) {
		cout << "Bob" << endl;
	} else {
		cout << "Draw" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define per(i,n) for(long long i = (long long)(n-1);i >= 0;--i)
#define REP(i,s,t) for(long long i=s;i<t;i++)
#define PER(i,s,t) for(long long i=s;i>t;--i)
#define all(x) x.begin(),x.end()
#define sp(n) setprecision(n)
typedef long long ll;
using namespace std;
int main(){
  ll N,W;
  cin>>N>>W;
  ll dp[110][100010],w[110],v[110];
  rep(i,N){cin>>w[i]>>v[i];}
  rep(i,N){rep(j,W+1){
    if(i==0){if(w[0]>j){dp[i][j]=0;}
             else dp[i][j]=v[0];}
    else if(w[i]>j){dp[i][j]=dp[i-1][j];}
    else{dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);}
  }}
  cout<<dp[N-1][W]<<endl;
}

Measured memory_bytes: 79872
n, m = map(int, input().split())
ship_1 = [False]*(n+1)
ship_n = [False]*(n+1)
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ship_1[b] = True
    elif b == n:
        ship_n[a] = True

for i in range(len(ship_1)):
    if ship_1[i] and ship_n[i]:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

long long stint(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve() {
	ll x;
	cin >> x;
	for (int i = 1; i <= x;i++) {
		ll num = (i*(i + 1)) / 2;
		if (num >= x) {
			P(i);
			return;
		}
	}
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

char s[7];
int main(void){
	int x=nextpint();
	int a=x/500;
	x-=a*500;
	int ans=a*1000+x/5*5;
	printf("%d\n", ans);
}


Measured memory_bytes: 128
import numpy as np
N, M, C = map(int, input().split()) 
B = np.array(list(map(int, input().split())))
A = np.array([list(map(int,list(input().split()))) for i in range(N)])
 
ans = 0
for i in range(N):
    val = np.sum(A[i, :] * B) + C
    if val > 0:
        ans += 1
print(ans)

Measured memory_bytes: 12480
inputa = input().split()

inputb = input()


a = int(inputa[0])
b = int(inputa[1])
# c = int(input[2])

inputList = list(inputb)

inputList[b-1] = inputList[b-1].lower()

ans = "".join(inputList)

print(ans)

# inputList.sort()
#
# list = [a+b, b+c ,c+a]
#
# ans = min(list)
# print(ans)



# flg = 1
# for i in range(0, len(inputList)-1):
#     if inputList[i] == inputList[i + 1]:
#         flg = 0
#         break
#
# if flg == 0:
#     print("Bad")
# else:
#     print("Good")


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

// A ... 0
// C ... 1
// G ... 2
// T ... 3
// に置き換えて考える

// [文字数][最後から1文字目][最後から2文字目][最後から3文字目]:=文字列のパターン数
int dp[101][4][4][4];

// 10^9 + 7
int mod = 1000000007;

int main() {

  int N;
  cin >> N;
  
  // スタート
  dp[0][3][3][3] = 1;

  // 文字列の文字数
  for (int length = 0; length < N; length++) {

    // 最後から1文字目
    for (int s1 = 0; s1 < 4; s1++) {

      // 最後から2文字目
      for (int s2 = 0; s2 < 4; s2++) {

        // 最後から3文字目
        for (int s3 = 0; s3 < 4; s3++) {

          // 条件に当てはまるものがない場合は次へ
          if (dp[length][s1][s2][s3] == 0) {
            continue;
          }

          // 新しく追加する文字
          for (int a = 0; a < 4; a++) {

            // ダメな場合(1) A ? G + C
            if (a == 1 && s1 == 2 && s3 == 0) {
              continue;
            }
            // ダメな場合(2) A G ? + C
            if (a == 1 && s2 == 2 && s3 == 0) {
              continue;
            }
            // ダメな場合(3) A G + C
            if (a == 1 && s1 == 2 && s2 == 0) {
              continue;
            }
            // ダメな場合(4) G A + C
            if (a == 1 && s1 == 0 && s2 == 2) {
              continue;
            }
            // ダメな場合(5) A C + G
            if (a == 2 && s1 == 1 && s2 == 0) {
              continue;
            }

            // a を追加した文字列を作る
            dp[length+1][a][s1][s2] += dp[length][s1][s2][s3];
            dp[length+1][a][s1][s2] %= mod;

          }

        }

      }

    }

  }

  // 答えを集計する
  int answer = 0;

  // 最後から1文字目
  for (int s1 = 0; s1 < 4; s1++) {

    // 最後から2文字目
    for (int s2 = 0; s2 < 4; s2++) {

      // 最後から3文字目
      for (int s3 = 0; s3 < 4; s3++) {

        answer += dp[N][s1][s2][s3];
        answer %= mod;

      }
    
    }
  
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

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

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll p=(b/c)-(a-1)/c;
    ll q=(b/d)-(a-1)/d;
    ll g=gcd(c,d);
    g=(c*(d/g));
    ll r=(b/g)-(a-1)/g;
    ll t=(b-a+1);
    //cout<<p<<" "<<q<<" "<<r;
    cout<<(t-p-q+r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans = 0;
    if(x >= b - 1){
        ans = (b - 1) * a / b;
    }else{
        ans = x * a / b;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3636