akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
#define ttttyyyy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fo(i,n,m) for(int i=n;i<m;i++)
#define pb(x) push_back(x)
#define mk(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define ft first
#define se second
#define ci(x) int x; cin>>x
unsigned long long dp[200003]={0};
int main(){
    ttttyyyy
    fo(i,1,200003){
        dp[i]=dp[i-1]+i;
    }
    ci(n);
    ci(k);
    unsigned long long sum=0;
    for(int i=k;i<=n+1;i++){
        sum+=dp[n]-dp[n-i]-dp[i-1]+1;
    }
    cout<<sum%(1000000007)<<endl;
    return 0;
}



Measured memory_bytes: 5196
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node {
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};

typedef struct node* Node;
Node root;

void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node,int);

int main(){
  int n, i, x;
  char c[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", c);
    if ( c[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root,x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( c[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( c[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
     
 Node y = NIL;
 Node x = root;
 Node z;
 
 z = malloc(sizeof(struct node));
 z->key = k;
 z->left = NIL;
 z->right = NIL;
    
 while(x != NIL) {
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else {
      x = x->right;
    }
 }
 z->parent = y;
 
 if(y == NIL){
   root = z;
 }
 else if(z->key < y->key){
   y->left = z;
 }
 else{
   y->right = z;
 }
}

void inorder(Node u){
  
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL){
    preorder(u->left);
  }
  if(u->right != NIL){
    preorder(u->right);
  }
}


Node treeSearch(Node u, int k){
  if (u == NIL ||  k == u->key){
    return u;
  }
  else if (k < u->key){
    return treeSearch(u->left,k);
  }
  else return treeSearch(u->right,k);
}

Measured memory_bytes: 19364
using System;
using System.Linq;

namespace CCitySavers
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var monsters = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var savers = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long overflow = 0;
            long killCount = 0;
            for (var i = 0; i < n; i++)
            {
                var city = monsters[i];

                var overflowKills = Math.Min(city, overflow);
                city -= overflowKills;
                killCount += overflowKills;

                var saver = savers[i];
                var saverKills = Math.Min(city, saver);
                overflow = saver - saverKills;
                killCount += saverKills;
            }

            killCount += Math.Min(monsters[n], overflow);

            Console.WriteLine(killCount);
        }
    }
}


Measured memory_bytes: 37812
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))


int main()
{
	int ans = 0, last = 9;
	vector<int> a(5);
	vector<int> b(0);
	rep(i, 0, 4)cin >> a[i];
	rep(i, 0, 4)
	{
		ans += ((a[i] + 9) / 10) * 10;
		if (a[i] % 10 != 0)b.push_back(a[i] % 10);
	}
	if (b.size() != 0)
	{
		rep(i, 0, b.size() - 1)
		{
			last = min(last, b[i]);
		}
		ans = ans - 10 + last;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import bisect

n = int(input())
*l, = map(int, input().split())
l.sort()
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        c = bisect.bisect_left(l, l[i] + l[j], j+1)
        ans += c - j - 1

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
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;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 n;
  cin >> n;

  vi a(n);
  rep(i,n) cin >> a[i];

  sort(rng(a));

  rep(i,n-1){
    if(a[i]==a[i+1]){
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;

int main(){
    ll n,k;
    cin >> n >> k;
    if(n <= k){
        if(2*n >= k)
            cout << k-n << endl;
        else cout << n << endl;
    }
    else{
        cout << min(n % k,k - (n % k)) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(long long int i=1;i<=n;i++)
#define lli long long int
#define ll long long 
#define dd double
#define endl "\n"
#define mod 1000000007

const double pi=3.14159265358;

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string str1,str2;
	cin>>str1>>str2;
	string s=str2.substr(0,str2.length()-1);
	if(str1==s)cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;	
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 4010000;
int vis[N],ban[N],tag,n,D1,D2,col[N];
vector<int> e[3][N];
int g(int x,int y){return x*2*n+y;}
void add(int x,int y,int p1,int p2,int tag){
	if(x-p1>=0&&y-p2>=0) e[tag][g(x,y)].push_back(g(x-p1,y-p2));
	if(x-p1>=0&&y+p2<2*n) e[tag][g(x,y)].push_back(g(x-p1,y+p2));
	if(x+p1<2*n&&y-p2>=0) e[tag][g(x,y)].push_back(g(x+p1,y-p2));
	if(x+p1<2*n&&y+p2<2*n) e[tag][g(x,y)].push_back(g(x+p1,y+p2));
}
void dfs(int x,int tag,int now){
	col[x]=now;vis[x]=1;
	for(int v:e[tag][x])
		if(!vis[v]&&!ban[v]) dfs(v,tag,now^1);
}
void solve(int tag){
	memset(vis,0,sizeof(vis));
	for(int i=0;i<4*n*n;i++)
		if(!ban[i]&&!vis[i]) dfs(i,tag,0);
	int sum[2]={};
	for(int i=0;i<4*n*n;i++)
		if(!ban[i]) sum[col[i]]++;
	int flag=sum[0]>sum[1];
	for(int i=0;i<4*n*n;i++)
		if(col[i]==flag) ban[i]=1;
}
void print(int x){
	cout<<x/(2*n)<<' '<<x%(2*n)<<'\n';
}
int main(){
	read(n);read(D1);read(D2);
	for(int i=0;i<2*n;i++)
		for(int j=0;j<2*n;j++){
			for(int k=0;k<2*n;k++){
				int res=D1-k*k;
				if(res>=0){
					int p=sqrt(res);
					if(p*p==res) add(i,j,k,p,1);
				}
				res=D2-k*k;
				if(res>=0){
					int p=sqrt(res);
					if(p*p==res) add(i,j,k,p,2);
				}
			}
		}
	solve(1);
	solve(2);
	vector<int> V;
	for(int i=0;i<4*n*n;i++)
		if(!ban[i]) V.push_back(i);
	for(int i=0;i<n*n;i++)
		print(V[i]);
	return 0;
}


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

int main()
{
    long int a,b,c,ans=0;
    cin>>a>>b>>c;
    while(a%2==0&&b%2==0&&c%2==0)
    {
        if(a==b&&b==c)
        {
        cout<<-1;
        return 0;
        }
        ++ans;
        long int ta,tb,tc;
        ta=(b/2)+(c/2);
        tb=(a/2)+(c/2);
        tc=(b/2)+(a/2);
        a=ta;
        b=tb;
        c=tc;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3592
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

sum = 0
([0] + a_arr + [0]).each_cons(2) do |a1, a2|
  sum += (a1 - a2).abs
end

a_arr.each_with_index do |a, i|
  prev_a = i == 0 ? 0 : a_arr[i-1]
  next_a = i == a_arr.length - 1 ? 0 : a_arr[i+1]

  if (prev_a <= a && a <= next_a) || (next_a <= a && a <= prev_a) then
    puts sum
  else
    puts sum - (next_a - a).abs - (a - prev_a).abs + ((next_a - a).abs - (a - prev_a).abs).abs
  end
end


Measured memory_bytes: 13068
# 入力 : 数字2つ
N, Y = map(int, input().split())

ans_a = -1
ans_b = -1
ans_c = -1

# 全探索
for a in range(N+1) :
    for b in range(N-a+1) :
        total = 10000 * a + 5000 * b + 1000 * (N-a-b)
        if total == Y :
            ans_a = a
            ans_b = b
            ans_c = N-a-b


print("{} {} {}".format(ans_a, ans_b, ans_c))


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

int main(){
  int H, W, K; cin >> H >> W >> K;
  char cell[H][W];
  int black = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> cell[i][j];
      if(cell[i][j] == '#') black++;
    }
  }
  if(black < K) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for(int r = 0; r < (1<< H) ; r++){
    bitset<6> row(r);
    for(int c = 0; c < (1 << W ); c++){
      bitset<6> col(c);
      int tmp = black;
	  for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
          if(row.test(i) || col.test(j)){
             if(cell[i][j] == '#') tmp--;
          }
          if(tmp < K) break;
        }
      }
      if(tmp == K) ans++;
    }
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	s, w := nextInt(), nextInt()
	if s > w {
		fmt.Println("safe")
	} else {
		fmt.Println("unsafe")
	}

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
#define MOD 1000000007
using namespace std;
int main(){
    int n,ans=0,a=0,b=0,c=0;
    cin>>n;
    rep(i,0,n){
        string s;
        cin>>s;
        rep(j,0,(int)s.length()-1) if(s[j]=='A'&&s[j+1]=='B')ans++;
        if(s[0]=='B'){
            if(s[s.length()-1]=='A')c++;
            else b++;
        }
        else if(s[s.length()-1]=='A')a++;
    }
    if(a+b==0&&c>0)c--;
    cout<<ans+c+min(a,b)<<endl;
}

Measured memory_bytes: 256
n=int(input())
S=input()

L,R=0,0
l,r=0,0

for i in S:
    if i=="(":l +=1
    else:l -=1;L=min(L,l)

for i in S[::-1]:
    if i==")":r +=1
    else:r -=1;R=min(R,r)

print("("*-L+S+")"*-R)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int N,M;
void calc(int i);
LL moke();
LL ans=-LINF;
int mass[3];
V<V<LL>> vec(3);
LL moke(){
    V<LL> vecn;
        REP(a,N){
            LL hoge = 0;
            REP(n,3){
                if(mass[n]==0){
                    hoge+=(-vec.at(n).at(a));
                }else{
                    hoge+=vec.at(n).at(a);
                }
            }
             vecn.pb(hoge);
        }
    sort(ALL(vecn));
    reverse(ALL(vecn));
    LL kk = 0;
    REP(a,M){
        kk += vecn.at(a);
    }
    return kk;
}
void calc(int i){
    if(i == 3){
        LL M = moke();
        ans = max(M,ans);
        return;
    }
    mass[i]=0;calc(i+1);
    mass[i]=1;calc(i+1);
}
int main(){
    cin >> N >> M;
    REP(a,N){
        LL c,b,f;cin >>c >> b >> f;
        vec.at(0).pb(c);vec.at(1).pb(b);vec.at(2).pb(f);
    }
    calc(0);
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define INF 2000000000
#define EPS 0.00000000001
char s[MAX];
int main()
{
    int i,n;
    char c;
    for(i=0;;i++)
    {
        scanf("%c",&c);
        if(!(c>='a'&&c<='z')) break;
        s[i]=c;
    }
    printf("%c%c%c",s[0],s[1],s[2]);
    return 0;
}


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

  int n, m, a[1000], b;

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

  sort(a, a+m, greater<int>());

  int ans=0;
  for(int i=0;i<m-1;i++){
    if(a[i]<n) ans+=n-a[i];
  }

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

Measured memory_bytes: 3140
#import random
import numpy as np
d=int(input())
c=np.array(list(map(int,input().split())))
s=[None]*d
r0=[None]*d
r1=[None]*d
cm=np.array([0]*26)
cd=np.array([0]*26)
for i in range(d):
  s[i]=list(map(int,input().split()))
s=np.array(s)
for j in range(d):  
  #rand = np.random.randint(26, size = 10) 
  #print(np.argmax(s[j])+1)
  r_i=np.argmax(s[j])
  cd=c*cm
  if np.max(cd>s[i][r_i]):
    r_i=np.argmax(cd)
  r0[j]=r_i
  for k in range(26):
    cm[k]+=1
  cm[r_i]=0
  #r_i+=1
  #print(r_i)
cm=np.array([0]*26)
cd=np.array([0]*26)  
rand = np.random.randint(100, size = d) 
for j in range(d):  
  #print(np.argmax(s[j])+1)
  r_i=r0[j]
  cd=c*cm
  if rand[j]>80:
    r_i=np.argmax(cd)
  r1[j]=r_i
  for k in range(26):
    cm[k]+=1
  cm[r_i]=0
for j in range(d):
  print(r1[j]+1)

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

void func(int n){
    int cd[26];
    for( int i=0; i<26; ++i )cd[i]=0;
    bool sw = false;

    for( int i=0; i<n; ++i ){
        char s; std::cin >> s;
        if (sw)continue;
        int vote = s - 'A';
        ++cd[vote];
        int max1 , max2, max_index;
        max1 = max2 = max_index = 0;
        for( int i=0; i<26; ++i ){
            if ( max1 < cd[i] ){
                max2 = max1;
                max1 = cd[i]; max_index = i;
            } else {
                if ( max2 < cd[i] ){
                    max2 = cd[i];
                }
            }
        }
        if ( max2 + n - i - 1 < max1 ){
            std::cout << static_cast<char>('A'+max_index) << " " << (i+1) << std::endl;
            sw = true;
        }
    }
    if(!sw)puts("TIE");
}

int main(){
    int n;
    while(true){
        std::cin >> n;
        if (!n)return 0;
        func(n);
    }
}


Measured memory_bytes: 3076
import java.util.*;

public class Main {
    static int n, a;
    static int[] x;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        a = in.nextInt();
        int maxLim = 50*n;

        x = new int[n];
        for(int i = 0; i < n; i++) x[i] = in.nextInt();

        long[][][] dp = new long[n+1][n+1][maxLim+1];
        for(int i = 0; i < n+1; i++) {
           for(int j = 0; j < n+1; j++) {
               Arrays.fill(dp[i][j], 0);
           }
        }

        dp[0][0][0] = 1;
        for(int j = 1; j < n+1; j++) {
            for(int k = 0; k < n+1; k++) {
                for(int s = 0; s < maxLim+1; s++) {
                    if(k >= 1 && s >= x[j-1]) {
                        dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
                    }else if(s < x[j-1]){
                        dp[j][k][s] = dp[j-1][k][s];
                    }
                }
            }
        }

        long cnt = 0;
        for(int k = 1; k < n+1; k++) cnt += dp[n][k][k*a];

        System.out.println(cnt);
    }
}

Measured memory_bytes: 83148
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a = i_input()
    b = i_input()
    c = i_input()
    d = i_input()

    print(min(a,b) + min(c,d))

if __name__ == '__main__':
    main()


Measured memory_bytes: 77088
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long D,T,S;
    cin >> D >> T >> S;
    long time = D / T;
    if(D% T > 0) time++;
    if(time <= S) cout << "Yes" << endl;
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3648
#!/usr/local/bin/python3
# https://atcoder.jp/contests/abc121/tasks/abc121_b

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

ans = 0

for i in range(N):
    y = 0
    for j in range(M):
        y += A[i][j]*B[j]
    y += C

    if y > 0:
        ans += 1

print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}
int main(){
    ll H; cin >> H;
    ll tmp=1;
    ll cnt=0;
    ll out=0;
    while(H>0){
        H = H/2;
        out += tmp;
        tmp*=2;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
Height = list(map(int,input().split()))
ans = N
Data = [0]*(N+1)
for i in range(M):
    a,b = map(int,input().split())
    ha = Height[a-1]
    hb = Height[b-1]
    if ha <= hb:
        if Data[a] == 0:
            ans -= 1
            Data[a] = 1
    if ha >= hb:
        if Data[b] == 0:
            ans -= 1
            Data[b] = 1
print(ans)


Measured memory_bytes: 20032
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {

	int n, i, a[1000];

	scanf("%d", &n);

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

	for ( i = n - 1; i >= 0; i--){
		printf("%d", a[i]);
		if (i != 0){
			printf(" ");
		}

	}
	printf("\n");
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;
#define rep(i,n) for(long i=0; i<n; i++)


long long int gcd(long long int p, long long int q) {
  if(p<q) return gcd(q,p);
    if (q == 0)
        return p;

    return gcd(q, p % q);
}

long long int lcm(long long int p, long long int q){
   return p * q / gcd(p,q) ;
}



void solve(){
  long long int a,b,c,d;
  long long int x,y,z,gc;
  cin >> a >> b >> c >> d;
  x = b/c-(a-1)/c;
  y = b/d-(a-1)/d;
  gc = lcm(c,d);
  z = b/gc-(a-1)/gc;
  cout << b-a+1 - x - y + z << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	int mv = inf;
	int res = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		MIN(mv, a);
		res += mv == a;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	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 all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;


int main(){
	int n,m;
	std::cin >> n>>m;
	std::vector<std::vector<int> > dist(n,std::vector<int> (n)) ;
	rep(i,n)rep(j,n){{
			dist[i][j]=INF;
	}}
	rep(i,n)dist[i][i]=0;
	std::vector<int> a(m),b(m),c(m);
	rep(i,m){
		int aa,bb,cc;
		std::cin >> aa>>bb>>cc;
		aa--;bb--;
		dist[aa][bb]=cc;
		dist[bb][aa]=cc;
		a[i]=aa;b[i]=bb;c[i]=cc;
	}
	for (int i = 0; i < n; i++)      // 経由する頂点
     for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
        
    int counter=0;
    rep(i,m)if(c[i]>dist[a[i]][b[i]])counter++;
    std::cout << counter << std::endl;
}



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 long long INF = 1LL << 60;

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

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



int main() 
{
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
15 11
)");
#define cin input
#endif

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

	cout << n-i+1 << endl;
}

Measured memory_bytes: 764
import math
n, p = map(int ,input().split())
#引数　n, 返り値nまでの素数をリストで返す
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    #根号
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
ff = primes(int(math.sqrt(p) + 1))
ans = 1
factorized = dict(zip(ff, [0 for i in range(len(ff))]))
if n == 1:
    print(p)
    exit()
for i in factorized.keys():
    while p % i == 0:
        p /= i
        factorized[i] += 1
    
for i in factorized.keys():
    if factorized[i] >= n :
        ans *= i**(factorized[i] // n)
print(ans)


Measured memory_bytes: 60288
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;


int main() {
	vector<string> s = { "Sunny","Cloudy","Rainy" };

	string input;
	cin >> input;
	if (input == s[0]) cout << s[1] << endl;
	if (input == s[1]) cout << s[2] << endl;
	if (input == s[2]) cout << s[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#import sys; sys.stdin=open('input_file.txt')
#------------------------------------------
import numpy as np

N,K = map(int,input().split())
A = np.array(input().split(),dtype=np.int64)

A = np.sort(A)

pos = A[A>0]
neg = A[A<0]
zero = len(A[A==0])

hi = 10**18+1
lo = -10**18-1

while hi-lo > 1:
    mid = (hi+lo)//2
    under_mid = 0

    if mid > 0: under_mid += N*zero
    under_mid += np.searchsorted(A,-(-mid//pos),side='left').sum()
    under_mid += (N-np.searchsorted(A,mid//neg,side='right')).sum()
    under_mid -= np.count_nonzero(A*A < mid)
    under_mid //= 2

    if under_mid < K:
        lo = mid
    else:
        hi = mid

print(lo)


Measured memory_bytes: 34568
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long LL;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

const int maxn = (1 << 16) + 10, maxm = 18, mod = 1e9 + 7;
int inv[maxn], fac[maxn], ifac[maxn], A[maxm], f[maxm][maxn], bit[maxn];

void init(int N)
{
	inv[0] = inv[1] = fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
	for(int i = 2; i <= N; ++i)
	{
		fac[i] = (LL)fac[i - 1] * i % mod;
		inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
		ifac[i] = (LL)ifac[i - 1] * inv[i] % mod;
	}
}

int C(int N, int M)
{
	if(N < M) return 0;
	return (LL)fac[N] * ifac[N - M] % mod * ifac[M] % mod;
}

void add(int &x, int y)
{
	x += y;
	if(x < 0) x += mod;
	if(x >= mod) x -= mod;
}

int main()
{
	int n = read(), m = read();
	for(int i = 1; i <= m; ++i) A[i] = read();
	int ALL = (1 << n) - 1;
	init(ALL + 5);
	for(int i = 1; i <= ALL; ++i) bit[i] = bit[i ^ (i & (-i))] + 1;
	//for(int i = 1; i <= n; ++i) cout << i << ' ' << bit[i] << endl;
	sort(A + 1, A + m + 1, greater<int>());
	
	f[0][0] = 1;
	for(int i = 1; i <= m; ++i) 
		for(int j = 0; j <= ALL; ++j)
			if(f[i - 1][j])
			{
				add(f[i][j], f[i - 1][j]);
				int p = ALL - j;
				for(int k = 0; k < n; ++k)
					if(!(j & (1 << k)))
						add(f[i][j | (1 << k)], (LL)f[i - 1][j] * C(p - A[i] + 1, (1 << k) - 1) % mod * fac[1 << k] % mod);//, cout << (LL) f[i - 1][j] << ' ' << i - 1 << endl;
			}
	int ans = 0;
	for(int i = 0; i <= ALL; ++i)
	{
	//	cout << i << ' ' << bit[i] << endl;
		add(ans, (LL)f[m][i] * fac[ALL - i] % mod * ((bit[i]) & 1 ? -1 : 1));
	//	cout << ((n - bit[i]) & 1 ? -1 : 1)<< endl;
	}
	cout << (LL)ans * (ALL + 1) % mod << endl;

	return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<string>
//0001
#include<cstddef>
#include<queue>
#include<vector>
//0003
#include<algorithm>
#include<iomanip>
#include<math.h>
using namespace std;

int main() {
	//0000
	/*
	int i, j;

	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	*/
	//0001
	/*
	int i;
	const size_t MNum = 10;
	int MHeight[MNum];
	int MH1 = 0, MH2 = 0, MH3 = 0;
	for (i = 0; i < 10; i++) {
		cin >> MHeight[i];
		if (MHeight[i] > MH1) {
			MH3 = MH2;
			MH2 = MH1;
			MH1 = MHeight[i];
		}
		else if (MHeight[i] > MH2) {
			MH3 = MH2;
			MH2 = MHeight[i];
		}
		else if (MHeight[i] > MH3) {
			MH3 = MHeight[i];
		}
	}
	cout << MH1 << endl << MH2 << endl << MH3 << endl;
	*/
	/*
	priority_queue<int, vector<int>, less<int> > que;
	int MH;

	for (int i = 0; i < 10; i++) {
		cin >> MH;
		que.push(MH);
	}

	for (int j = 0; j < 3; j++) {
		cout << que.top() << endl;
		que.pop();
	}
	*/
	//0002
	/*
	int a, b;
	while (cin >> a >> b) {
		int sum = a + b;
		int count = 0;
		while (sum > 0) {
			sum = sum / 10;
			count++;
		}
		cout << count << endl;
	}
	*/
	//0003
	/*
	int a[3];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);
		if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	*/
	double a,b,c,d,e,f;
	double x, y;
	int xi, yi;
	//???????????£??¨?????????????????§???????????????
	while (
		cin >> a
		>> b
		>> c
		>> d
		>> e
		>> f
		) {
		x = (e*c - b*f) / (e*a - b*d);
		y = (a*f - c*d) / (e*a - b*d);
		xi = roundf(x * 1000);
		yi = roundf(y * 1000);
		x = xi;
		x = x / 1000;
		y = yi;
		y = y / 1000;
		cout << fixed
			<< setprecision(3)
			<< x
			<< " "
			<< y
			<< endl;
	}
	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}

struct mint{
    ll x;
    mint(ll x=0) : x ((x%big+big)%big){}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint &a){
        if((x+=a.x)>=big)x-=big;
        return *this;
    }
    mint& operator-=(const mint &a){
        if((x+=big-a.x)>=big)x-=big;
        return *this;
    }
    mint& operator*=(const mint &a){
        (x*=a.x)%=big;
        return *this;
    }
    mint& operator/=(mint &a){
        return (*this)*=a.inv();
    }

    mint operator+(const mint &a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint &a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint &a)const{
        mint res(*this);
        return res*=a;
    }
    mint operator/(mint &a)const{
        mint res(*this);
        return res/=a;
    }
    bool operator==(mint &a)const{
        if((*this).x==a.x)return true;
        else return false;
    }
    bool operator!=(mint &a)const{
        return !((*this)==a);
    }

    mint pow(ll t){
        if(t==0)return (mint)1;
        if(t%2==0){
            mint k=pow(t/2);
            return k*k;
        }else{
            if(t>0)return (*this)*pow(t-1);
            else return pow(t+1)/(*this);
        }
    }
    mint inv(){
        return pow(big-2);
    }

    friend ostream& operator<<(ostream &os,const mint &m){
        os << m.x;
        return os;
    }
    friend istream& operator>>(istream &is,mint &m){
        is >> m.x;
        m.x=(m.x%big+big)%big;
        return is;
    }
};

mint com(int x,int y){
    if(y>x||y<0)return 0;
    mint ans=1;
    rep(i,y){
        mint t=x-i,s=y-i;
        ans*=t/s;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    
    int x,y;cin >> x >> y;mint t;
    if((x+y)%3)cout << 0 << endl;
    
    /*
    a+2b=x
    2a+b=y
    a+b=(x+y)/3
    */
    else cout << com((x+y)/3,x-(x+y)/3) << endl;
}

Measured memory_bytes: 3684
n = int(input())
r = [int(input().strip()) for _ in range(n)]
maxv = -1e9
minv = r[0]
for i in range(1,n):
    maxv = maxv if maxv > r[i]-minv else r[i]-minv
    minv = minv if minv < r[i] else r[i]
print(maxv)


Measured memory_bytes: 13628
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>     
#include<algorithm>
#define ll long long
using namespace std;
#define hengheng main()
#define mem(a,b) memset(a,b,sizeof(a))
int main()
{
	int n,m,t,k,i,j; ll sum;
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	k=b/a;
	if(k>c)
	printf("%d\n",c);
	else
	printf("%d\n",k);
	
	return 0;
}

Measured memory_bytes: 256
a,b,c,t;
main(){
    for(scanf("%*d");~scanf("%d%d%d",&a,&b,&c);t=0){
        t+=a*=a;t+=b*=b;t+=c*=c;
      puts(t-2*a&&t-2*b&&t-2*c?"NO":"YES");
    }
}

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int c[256],e[256],m,n=0,k=0;
	for(int i=0;i<10;i++){c[i]=0;e[i]=0;}
	
	while(cin>>m){
		if(m==0){e[k]=c[n-1];k++;c[n-1]=0;n--;}
		else {c[n]=m;n++;}
	}
	
	for(int i=0;i<k;i++)cout<<e[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 0
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int k, a, b; cin >> k >> a >> b;
	forl(i, a, b+1) {
		if(i%k) continue;
		println("OK");
		return 0;
	}
	println("NG");
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    ll x,y;cin >> x >> y;
    int ans = 0;
    while(x<=y){
        x *= 2;
        ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
if k>x: a=a[:k]
if k>y: b=b[:k]
if k>z: c=c[:k]
d=[]
ans=[]
for i in a:
    for j in b:
        d.append(i+j)
d.sort(reverse=True)
if len(d)>k: d=d[:k]
for i in c:
    for j in d:
        ans.append(i+j)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Measured memory_bytes: 134408
#include<deque>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

void push(deque<int> &dq, int x) {
    while (!dq.empty() && dq.back() < x) dq.pop_back();
    dq.push_back(x);
}
void pop(deque<int> &dq, int x) {
    if (!dq.empty() && dq.front() == x) dq.pop_front();
}

int N, K;
int P[200011];

void MAIN() {
    scanf("%d%d", &N, &K);
    REP (i, N) scanf("%d", P+i);

    deque<int> A, B;
    REP (i, K) {
	push(A, P[i]);
	push(B, -P[i]);
    }

    int ans = N-K+1;

    int cnt = 0;
    REP (i, K-1) if (P[i] < P[i+1]) cnt++;
    int sorted = 0;

    REP (i, N-K+1) {
	pop(A, P[i]);
	push(A, P[i+K]);

	if (cnt == K-1) {
	    ans--;
	    sorted++;
	} else if (i+K < N && -B.front() == P[i] && A.front() == P[i+K]) {
	    ans--;
	}

	pop(B, -P[i]);
	push(B, -P[i+K]);
	if (P[i] < P[i+1]) cnt--;
	if (P[i+K-1] < P[i+K]) cnt++;
    }

    if (sorted) ans++;
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = int64_t;

constexpr int INF = (1 << 30);
constexpr ll INFL = (1LL << 62);
constexpr ll MOD = 1000000007;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};

//
// 重み付きUnion-Find Tree size version
//
// verify: AOJ DSL_1_B
//
template <typename T>
struct WeightedUnionFind {
    std::vector<int> data;
    std::vector<T> ws;
    const int n;
    WeightedUnionFind(int num) : data(num, -1), ws(num), n(num) {}
    int find(int k) {
        assert(0 <= k && k < n);
        if (data[k] < 0) return k;
        auto par = find(data[k]);
        ws[k] += ws[data[k]];
        return data[k] = par;
    }
    T weight(int k) {
        assert(0 <= k && k < n);
        find(k);
        return ws[k];
    }
    bool unite(int x, int y, T w) {
        assert(0 <= x && x < n);
        assert(0 <= y && y < n);
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) {
            std::swap(x, y);
            w *= -1;
        }
        data[x] += data[y];
        data[y] = x;
        ws[y] = w;
        return true;
    }
    int size(int k) {
        assert(0 <= k && k < n);
        return (-data[find(k)]);
    }
    T diff(int x, int y) {
        assert(0 <= x && x < n);
        assert(0 <= y && y < n);
        return weight(y) - weight(x);
    }
    bool same(int x, int y) {
        assert(0 <= x && x < n);
        assert(0 <= y && y < n);
        return find(x) == find(y);
    }
};

int main() {
    cout << std::fixed << std::setprecision(10);
    int n, m;
    cin >> n >> m;
    WeightedUnionFind<int> uf(n);
    rep(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        --l;
        --r;
        if (uf.same(l, r)) {
            if (d != uf.diff(l, r)) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            uf.unite(l, r, d);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1024
fn main() {
    proconio::input! {
        n: usize,
        q: usize,
        abs: [(usize, usize); n-1],
        pxs: [(usize, usize); q],
    }
    let mut tree = vec![(vec![], 0usize); n];
    for &(a, b) in &abs {
        tree[a - 1].0.push(b - 1);
        tree[b - 1].0.push(a - 1);
    }
    for &(p, x) in &pxs {
        tree[p - 1].1 += x;
    }
    let mut scores = vec![None; n];
    let mut deque = std::collections::VecDeque::new();
    deque.push_back((0, 0));
    while let Some((node, s)) = deque.pop_front() {
        tree[node].1 += s;
        scores[node] = Some(tree[node].1);
        for &item in &tree[node].0 {
            if scores[item].is_none() {
                deque.push_back((item, tree[node].1));
            }
        }
    }
    let ans = scores
        .iter()
        .map(|x| x.unwrap().to_string())
        .collect::<Vec<_>>()
        .join(" ");
    println!("{}", ans);
}


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

int main() {
  int m, n_mi, n_ma;
  while (cin >> m >> n_mi >> n_ma, m || n_mi || n_ma) {
    vector<int> p(m);
    for (int i = 0; i < m; ++i) {
      cin >> p[i];
    }
    int ma = -1;
    int res;
    for (int i = n_mi; i <= n_ma; ++i) {
      if (ma <= abs(p[i - 1] - p[i])) {
        ma = p[i - 1] - p[i];
        res = i;
      }
    }
    cout << res << endl;
  }
}



Measured memory_bytes: 3092
def c(a, b)
    Rational(((a - b + 1) .. a).inject(1, :*), (1 .. b).inject(1, :*)).to_i
end

N, A, B = gets.split.map{|i|i.to_i}
V = gets.split.map{|i|i.to_i}.sort_by!{|i|-i}
a = V[0, A]
ave = Rational(a.inject{|r, i|r + i}, A)
puts "%f" % ave

if a[0] == a[-1]
    n = V.count{|i|i == a[0]}
    r = 0
    (A .. [B, n].min).each{|i|
        r += c(n, i)
    }
    puts r
else
    r = a.count{|i|i == a[-1]}
    n = V.count{|i|i == a[-1]}
    puts c(n, r)
end


Measured memory_bytes: 1788
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n;
        int roop=0;
        StringBuilder[] ans=new StringBuilder[1000];
        String tmpData;
        while((n=sc.nextInt())!=0){
            String[][] str=new String[n][2];
            for(int j=0;j<n;j++){
                str[j][0]=sc.next();
                str[j][1]=sc.next();
            }
            int dn=sc.nextInt();
            for(int j=0;j<dn;j++){
                tmpData=sc.next();
                for(int k=0;k<n;k++){
                    if(tmpData.equals(str[k][0])){
                        tmpData=str[k][1];
                        break;
                    }
                }
                if(j==0){
                    ans[roop]=new StringBuilder(tmpData);
                }else{
                    ans[roop].append(tmpData);
                }
            }
            roop++;
        }
        sc.close();
        for(int i=0;i<roop;i++){
            System.out.println(ans[i].toString());
        }
    }
}

Measured memory_bytes: 67404