akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC121cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select( long.Parse).ToArray();
            List< long[]> vs = new List< long[]>();
            for ( long i = 0; i < nm[0]; i++)
            {
                var ab = Console.ReadLine().Split(' ').Select( long.Parse).ToArray();
                vs.Add(ab);
            }
            var orderedvs = vs.OrderBy(x => x[0]);
             long result = 0;
             long hon = 0;
            foreach(var x in orderedvs)
            {
                if (nm[1] - hon >= x[1])
                {
                    hon += x[1];
                    result += x[1] * x[0];
                }
                else
                {
                    result += x[0] * (nm[1] - hon);
                    hon = nm[1];
                }
                if (hon == nm[1]) break;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28084
#include <stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[105];
int cnt[105];
int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		cnt[a[i]]++;
	}
	int flag=1;
	if(a[n]>n-1){flag=0;}
	for(int i=1;i<=a[n]/2+1;i++){
		int len=a[n]-(i-1);
		if(!(a[n]&1)){
			if(i==a[n]/2+1){
				cnt[len]--;
				if(cnt[len]<0){flag=0;break;}
			}
			else {
				cnt[len]-=2;
				if(cnt[len]<0){flag=0;break;}
			}
		}
		else {
			cnt[len]-=2;
			if(cnt[len]<0){
				flag=0;break;
			}
		}
	}
	if(flag){
		for(int i=1;i<=n;i++){
			if(cnt[i]){
				if(i<(a[n]+1)/2+1){flag=0;break;}
				else if(i>a[n]){flag=0;break;}
			}
		}
	}
	if(flag)puts("Possible");
	else puts("Impossible");
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int q, p, n;
    long long r;
    char c[2];
    scanf("%d", &q);
    r=0;
    while (q--) {
        scanf("%d%s%d", &p, c, &n);
        r+=(*c=='(')?n:-n;
        puts(r?"No":"Yes");
//        fflush(stdout);
    }
    return 0;
}

Measured memory_bytes: 588
#include <iostream>
using namespace std;
int main(){
	int p[31]={0};
	for(int i=0,n;i<28;++i){
		cin>>n;
		p[n]=1;
	}
	for(int i=1;i<31;++i)if(p[i]==0)cout<<i<<"\n";
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll x,ans=0;
int n,num[15];
inline void dfs(int pos,ll sum){
	if(pos==n+1){ans+=sum;return;}
	ll tmp=0;
	for(int i=pos;i<=n;++i)tmp=tmp*10+num[i],dfs(i+1,sum+tmp);
}
int main(){
	cin>>x;
	while(x)num[++n]=x%10,x/=10;
	reverse(num+1,num+n+1);
	dfs(1,0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
var input= require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split(" ");
var a=Arr[0]-0;
var b=Arr[1]-0;
var c=Arr[2]-0;
var tasu=0;
if(a<b)tasu++;
if(b<c)tasu++;
var str=(tasu==2)?"Yes":"No";
console.log(str);

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

using namespace std;

typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll ops = 0;
    for(ll i = 2; i * i <= n; i++){
        int cur = 0;
        if(n % i) continue;
        while(n % i == 0){
            n /= i;
            cur++;
        }
        for(int i = 1; ; i++){
            if(i <= cur){
                cur -= i;
                ops++;
            }else{
                break;
            }
        }
    }
    if(n != 1) ops++;
    cout << ops << '\n';
}

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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var p = int.Parse(line[1]);
            if (n == 0 && p == 0) break;
            var q = new Queue<int>();
            foreach (var x in Enumerable.Range(0, n)) q.Enqueue(x);
            Console.WriteLine(PlayGame(q, p));
        }
    }
    public static int PlayGame(Queue<int> q, int p)
    {
        var kouho = new int[q.Count()];
        while (true)
        {
            var t = q.Dequeue(); q.Enqueue(t);
            if (p == 0) { p += kouho[t]; kouho[t] = 0; }
            else if (p == 1 && kouho.Sum() == kouho[t]) { return t; }
            else { kouho[t]++; p--; }
        }
    }
}

Measured memory_bytes: 10472
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [r]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    return `${r * r}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


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

const ll INF = 100000000000LL;
int main () {
  int A, B, Q;
  cin >> A >> B >> Q;

  vector<ll> s(A), t(B);

  rep(i,A) cin >> s[i];
  rep(i,B) cin >> t[i];

  rep(i,Q) {
    ll x;
    cin >> x;

    vector<ll>::iterator it;
    it = lower_bound(s.begin(), s.end(), x);
    ll sr = INF, sl = -INF;
    if(it != s.end()) sr = *it;
    if(it != s.begin()) sl = *(it -1);

    it = lower_bound(t.begin(), t.end(), x);
    ll tr = INF, tl = -INF;
    if(it != t.end()) tr = *it;
    if(it != t.begin()) tl = *(it -1);

    ll ans = INF;
    ans = min(ans, x - min(sl, tl));
    ans = min(ans, max(sr, tr) - x);
    ans = min(ans, 2*(x - sl) + tr - x);
    ans = min(ans, 2*(x - tl) + sr - x);
    ans = min(ans, 2*(sr - x) + x - tl);
    ans = min(ans, 2*(tr - x) + x - sl);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vi sum(n);
    rep(i,n-1)if(s[i] == 'A' && s[i+1] == 'C'){
        sum[i+1]++;
    }
    rep(i,n-1)sum[i+1] += sum[i];
    rep(i,q){
        int a,b;
        cin >> a >> b;
        a--,b--;
        int ans = sum[b] - sum[a];
        cout << ans << endl;
    }
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from itertools import accumulate
import copy


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline()[:-1] for _ in range(line)]


N = z()
ans = [0]*N
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            if(x**2+y**2+z**2+x*y+y*z+x*z <= N):
                ans[x**2+y**2+z**2+x*y+y*z+x*z - 1] += 1
for i in ans:
    print(i)


Measured memory_bytes: 27320
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

ll mod=998244353;

void solve()
{
   ll n,s;
   cin >> n >> s;
   vector<ll> v(n);
   vector<vector<ll>> dp(n+100,vector<ll>(s+100,0));
   ll p=1;
   for(int i=0;i<n;i++)
   {
        cin >> v[i];
        p*=2;
        p%=mod;
        dp[i][0]=p;
   }
   dp[0][v[0]]=1;
   for(int i=1;i<n;i++)
   {
       for(int j=1;j<=s;j++)
       {
           dp[i][j]=(2*dp[i-1][j])%mod;
           if(j>=v[i])
           {
               dp[i][j]+=dp[i-1][j-v[i]];
               dp[i][j]%=mod;
           }
       }
   }
   cout << dp[n-1][s] << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 78412
#include<iostream>
using namespace std;
int main(){
  int n,i,j;
  cin >> n;
  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   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;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
  lint  dp[2005][2005];
  int main(){
     lint n,m,r;
     cin>>n>>m>>r;
     lint f[r];
     rep(i,r)cin>>f[i];
     rep(i,2005){
         rep(j,2005){
             if(i==j)dp[i][j]=0;
             else dp[i][j]=INF;
         }
     }
     rep(i,m){
         lint a,b,c;
         cin>>a>>b>>c;
         dp[a][b]=c;
         dp[b][a]=c;
     }
     repp(k,1,n+1){
        repp(i,1,n+1){
            repp(j,1,n+1){
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
     }
    sort(f,f+r);
    lint ans=0;
    rep(i,r-1){
        ans+=dp[f[i]][f[i+1]];
    }
    while(next_permutation(f,f+r)){
        lint sum=0;
            rep(i,r-1){
                    sum+=dp[f[i]][f[i+1]];
            }
            ans=min(sum,ans);
    }
    cout<<ans;
  }
  
  
     
  

Measured memory_bytes: 33024
#include<cstdio>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<list>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;
typedef pair<P,double> C;

const double PI = acos(-1);

namespace std{
  bool operator<(const P &a,const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

//for vector
P unit(P p){return p / abs(p);}

pair<P,P> norm(P p){return make_pair(p*P(0,1),p*P(0,-1));}

double dot(P x,P y){return real(conj(x)*y);}

double cross(P x,P y){return imag(conj(x)*y);}

//rotate a point counter-clockwise on the origin
P rotate(P v,double s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

//for point set
vector<P> convex_hull(vector<P> v){
  int n = v.sz, k = 0;
  sort(v.begin(),v.end());
  vector<P> r(2*n);
  for(int i=0;i<n;i++){
    while(k>1 && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= EPS)k--;
    r[k++] = v[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= EPS)k--;
    r[k++] = v[i];
  }
  r.resize(k-1);
  return r;
}

//return seta A
double arg(P a,P b,P c){return acos(dot(b-a,c-a)/(abs(b-a)*abs(c-a)));}
double arg(double a,double b,double c){return acos( (b*b+c*c-a*a)/(2*b*c) );}


//for line(segment)
int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//for polygon

//all vertex is already sorted.
double area(Poly p){
  if(p.size()<3)return 0;
  double res = cross(p[p.size()-1],p[0]);
  for(int i=1;i<p.size();i++)res += cross(p[i-1],p[i]);
  return res/2;
}

Poly convex_cut(Poly p,L l){
  Poly res;
  int n = p.size();
  for(int i=0;i<n;i++){
    int nxt = (i+1)%n;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

double cut_area(Poly p, double seta){
  return area(convex_cut(p,L(P(0.0),rotate(P(100,0),seta))));
}

int main(){
  int n;
  double x,y,seta,eps;
  P po;
  Poly p;
  
  while(scanf("%d",&n),n){
    p.clear();
    for(int i=0;i<n;i++){
      scanf("%lf%lf",&x,&y);
      po.real() = x; po.imag() = y;
      p.pb(po);
    }

    double s = area(p)/2;
    double l = 0,r = PI;
    double a,b;
    for(int i=0;i<100;i++){
      double mid = (l+r)/2;
      a = cut_area(p,l), b = cut_area(p,mid);
      if( (s-a<EPS) && (s-b<EPS))l = mid;
      else if( (s-a>EPS) && (s-b>EPS))l = mid;
      else r = mid;
    }
    P res = rotate(P(100,0),l);
    printf("%.15lf %.15lf\n",res.real(),res.imag());
  }
}

Measured memory_bytes: 1128
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  replicateM_ n $ do
    solve <$> f <*> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> [Int] -> Int
solve [_, k] = sum . drop (k - 1) . sortBy (flip compare) . (tail >>= zipWith (-))



Measured memory_bytes: 34696
#include<stdio.h>

int main(void){
int a,b;

scanf("%d%d",&a,&b);

if (a < b){
	printf("a < b\n",a,b);
}else if(a > b){
	printf("a > b\n",a,b);
}else if(a == b){
	printf("a == b\n",a,b);
}

return 0 ;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<string.h>
 
#define M 1000000
#define NIL -1
#define L 14
 
char H[M][L];
 
int getChar(char ch){
  if(ch == 'A')return 1;
  else if(ch == 'C')return 2;
  else if(ch == 'G')return 3;
  else if(ch == 'T')return 4;
  else return 0;
}
 
long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M-1));}
 
int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
  return 0;
}
 
int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}
 
int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
 
    if(com[0]=='i'){
      insert(str);
    }else{
      if(find(str)){
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}
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; }

int ctoi(char c){return c - '0';}

const ll COM_MAX = (ll)(1e6+100);
vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);

void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%INF;
    inv[i]=INF-inv[INF%i]*(INF/i)%INF;
    finv[i]=finv[i-1]*inv[i]%INF;
  }
}
ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%INF)%INF;
}

template<typename T>  
bool isOk(T key,T value){
  return key <= value;
}
template<typename T>
T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;

  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }

  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}

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

int main() { 

  //cin.tie(0); ios::sync_with_stdio(0);
  ll x,y;cin>>x>>y;
  comb_init();

  if((x+y)%3 != 0){
    print(0);
    return 0;
  }

  ll n,m;
  n = (x+y)/3;
  m = max(x,y)-n;
  if(m < 0 || n < 0){
    print(0);
    return 0;
  }

  ll ans = comb(n,m);

  print(ans%INF);

  return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int n;
    cin >> n;
    set<int> st;
    for(int i=0; i<n; i++){
        int f;
        cin >> f;
        st.ins(f);
    }
    if(st.size() == n)  cout << "YES" << endl;
    else cout << "NO" << endl;
} 

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
//ll a[100001]={0};
int main()
{//ios_base::sync_with_stdio(false);
ll x;
cin>>x;
ll t=1;ll ans=101;
while(ans<x)
{
    ans+=ans/100;t++;
}
cout<<t;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
int desc(const void *a, const void *b){
    return *(int*)b-*(int*)a;
}
int main(void){
    int n,a[100],i,ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),desc);
    for(i=0;i<n;i++){
        if(i%2==0) ans+=a[i];
        else ans-=a[i];
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, a, b) for(int i=(a); i<(int)(b); i++)

typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}

int main(void){
	int n, q; cin >> n >> q;
	string str; cin >> str;
	vector<int> sum(str.length());
	rep2(i, 1, str.length()){
		if(str[i] == 'C' && str[i-1] == 'A') sum[i] = sum[i-1]+1;
		else sum[i] = sum[i-1];
	}

	rep(i, q){
		int l, r; cin >> l >> r;
		l--; r--;
		cout << sum[r] - sum[l] << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
fn main() {
    let v = read_vec::<i32>();
    let x = v[0];
    let a = v[1];
    let b = v[2];
    if a - b >= 0 {
        println!("delicious");
    } else if a + x >= b {
        println!("safe");
    } else {
        println!("dangerous");
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(nullptr)
#define INF (1LL<<62)-1
#define F first
#define S second
#define pb push_back

vector<ll> b(100005,INF),a(100005);
ll f(ll i, ll n, ll k)
{
    if(b[i]!=INF) return b[i];
    if(i>=n-1) return 0;

    for(ll j=1;j<=k;j++)
    {
        if(i+j<n)
        {
            ll minn=INF;
            minn = min(abs(a[i]-a[i+j]) + f(i+j,n,k) , minn);
            b[i]=min(minn,b[i]);
        }
    }
    
    return b[i];
}

int main()
{
    FASTIO;
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<n;i++) cin>>a[i];

    cout<<f(0,n,k);
}

Measured memory_bytes: 12668
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    char a;
    cout<<"2018";
    rep(i,4) cin>>a;
    rep(i,6){
        cin>>a;
        cout<<a;
    }
    cout<<endl;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <bitset>

using namespace std;
#define Rint register int
int qr(){Rint ret=0,f=1;register char ch = getchar();while(!isdigit(ch)) f=ch=='-'?-1:1,ch=getchar();while(isdigit(ch)) ret=ret*10+ch-'0',ch=getchar();return ret * f;}

int N;
#define maxN 2000*2000+10
#ifndef maxN
#define maxN 50
#define debug
#endif // maxN
bitset <maxN> f;
int sum,target;

int main(){
    N = qr();
    f[0]=1;
    for(Rint i = 1,t;i<=N;++i){
        t = qr();
        #ifdef debug
        cout << "     f " << f << endl;
        cout << "  f<<t " << (f<<t) << endl;;
        #endif // debug
        f|=(f<<t);
        sum += t;
    }
    #ifdef debug
    cout << f;
    #endif // debug
    for(Rint i = (sum+1)/2;;i++){
        if(f[i]) {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll dp[n];
    for (ll i = 0; i < n; i++) {
        dp[i] = INT_MAX;
    }
    // for (ll i = 0; i < n; i++) {
    //     cout << a[i] << " " << dp[i] << endl;
    // }
    dp[0] = 0;
    for (ll i = 1; i < n; i++) {
        if (i - 1 >= 0)
            dp[i] = min(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
        if (i - 2 >= 0)
            dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  char a;
  cin >> H >> W;
  //ヘッダー
  for (int i =0 ; i < W+2 ; i++){
    cout << "#"; 
  }
  cout << endl;
  
  
  //ピクチャー
  for (int i = 0 ; i<H ;++i){
    cout << "#";
    for (int j= 0 ; j < W ; ++j){
      cin >> a;
      cout << a;
    }
    cout << "#"<< endl;
  }
  
  //フッダー
  for (int i =0 ; i < W+2 ; i++){
    cout << "#"; 
  }
  cout << endl;
  
  
}

Measured memory_bytes: 3568
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (long long i = a; i < b; ++i)
#define FORR(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"

int modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

int fpow(int a, int n)
{
    int ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,w; cin >> h >> w;
    string matrix[h];
    FOR(i,0,h) cin >> matrix[i];
    int hor1[h][w], ver1[h][w];
    int hor2[h][w], ver2[h][w];
    FOR(i,0,h)
    {
        int cnt = 0;
        FOR(j,0,w)
        {
            if (matrix[i][j] == '.') ++cnt;
            else cnt = 0;
            hor1[i][j] = cnt;
        }
    }
    FOR(i,0,h)
    {
        int cnt = 0;
        FORR(j,w-1,-1)
        {
            if (matrix[i][j] == '.') ++cnt;
            else cnt = 0;
            hor2[i][j] = cnt;
        }
    }
    FOR(j,0,w)
    {
        int cnt = 0;
        FOR(i,0,h)
        {
            if (matrix[i][j] == '.') ++cnt;
            else cnt = 0;
            ver1[i][j] = cnt;
        }
    }
    FOR(j,0,w)
    {
        int cnt = 0;
        FORR(i,h-1,-1)
        {
            if (matrix[i][j] == '.') ++cnt;
            else cnt = 0;
            ver2[i][j] = cnt;
        }
    }
    int ans = 0;
    FOR(i,0,h)
    {
        FOR(j,0,w)
        {
            if (matrix[i][j] == '#') continue;
            ans = max(ans, hor1[i][j] + hor2[i][j] + ver1[i][j] + ver2[i][j] - 3);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 129536
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int x, y, z;
	cin>>x>>y>>z;

	cout<<z<<" "<<x<<" "<<y;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

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

int main(){
  int n;
  long long int cnt=0;
  string s;
  
  cin >> n >> s;
  
  char pre = '_';
  for(auto c : s){
    if(pre != c){
      cnt++;
    }
    pre = c;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 512
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2186
# ????£????20??????????????????
# ??????????????§??????
# ???????°????????????§????¬??????????????????????

def make1d(n)
  a = Array.new(n)
  for i in 0..(n-1)
    a[i] = 0
  end
  a
end
def make2d(height,width)
  a = Array.new(height)
  for i in 0..(height-1)
    a[i] = make1d(width)
  end
  a
end

dataset = gets.to_i
answers = []
dataset.times {
	gx, gy = gets.split(" ").map(&:to_i)
	gx, gy = gx+1, gy+1 
	#p [gx,gy]
	matatabi = gets.to_i
	# ???????????§????????° p ????????£?????????????????¨?????????????????? p ??¨??????????????????
	mat = {}
	(0..matatabi-1).each{|i|
		x1,y1, x2,y2= gets.split(" ").map(&:to_i)
		x1,y1, x2,y2= x1+1,y1+1, x2+1,y2+1
		ue_or_hidari = (x2-x1).abs==0 ? 1 : 2 #?????????1, ?????????2??¨??????
		key = x2+y2-x1-y1>0 ? x2.to_s+' '+y2.to_s : x1.to_s+' '+y1.to_s
		mat[key] = (mat[key] || 0)+ue_or_hidari
	}
	# ????????????array??????????????´????????????????????????????????¨??§???array[-1]??§??¨??????????????????????????????????????????
	array = make2d(gx+1,gy+1)
	array[1][1]=1
	x,y = 1,1
	(1..gx).each do |x|
		(1..gy).each do |y|
			unless x==1 && y==1
				if mat[x.to_s+' '+y.to_s] == nil
					array[x][y] = array[x-1][y]+array[x][y-1]
				elsif mat[x.to_s+' '+y.to_s] == 1
					array[x][y] = array[x-1][y]
				elsif mat[x.to_s+' '+y.to_s] == 2
					array[x][y] = array[x][y-1]
				elsif mat[x.to_s+' '+y.to_s] == 3
					array[x][y] = 0
				end
			end
		end
	end
	if array[gx][gy]==0
		answers.push('Miserable Hokusai!')
	else
		answers.push(array[gx][gy])
	end
}
answers.each do |answer|
	puts answer
end

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;
ll n, r;

signed main() {
	cin >> n;
	s = to_string(n);
	bool a9 = true;
	reprt(i,s.size()-1,1) if (s[i]!='9') a9 = false;
	if (a9) {
		each(i,s) r += i-'0';
		return cout << r << ln, 0;
	}
	cout << 9*(s.size()-1) + (s[0]-'1') << ln;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

	int n = 0, a = 0, n1, n2;

	cin >> n >> a;

	n1 = n / 500;

	n2 = n - (500 * n1);

	if (n2 <= a) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

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

void solve() 
{
    int n;cin>>n;
    int a[n];REP(i,n)cin>>a[i];
    int sum=0;REP(i,n)sum^=a[i];
    REP(i,n)cout<<(i?" ":"")<<(sum^a[i]);cout<<endl;
}

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

Measured memory_bytes: 4392
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

typedef tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 1e5 + 5;

vector<ll>adj[MAXN];
ll p[MAXN][22], parent[MAXN], level[MAXN], n, u, v, a, b, res;

void precom()                                        // for calculating 2^k th parent of every node
{
	for(int i = 0 ; i < n ; i++)
		for(int j = 0 ; (1ll << j) < n ; j++)
			p[i][j] = -1;
	for(int i = 0 ; i < n ; i++)
		p[i][0] = parent[i];
	for(int j = 1 ; (1ll << j) < n ; j++)
		for(int i = 0 ; i < n ; i++)
			if(p[i][j - 1] != -1)
				p[i][j] = p[p[i][j - 1]][j - 1];
}

ll lca(ll u, ll v)
{
	if(min(level[u], level[v]) == level[u]) swap(u, v);
	ll dist = level[u] - level[v];
	while(dist)
	{
		ll raise = log2(dist);
		u = p[u][raise];
		dist -= (1ll<<raise);
	}
	if(u == v) return u;
	for(int j = log2(MAXN) ; j >= 0 ; j--)
	{
		if(p[u][j] != -1 && p[u][j] != p[v][j])
		{
			u = p[u][j];
			v = p[v][j];
		}
	}
	return parent[u];
}

void dfs(ll node, ll par, ll lev)                              // dfs to set parent and calculate levels
{
	level[node] = lev;
	for(auto it : adj[node])
	{
		if(it == par) continue;
		parent[it] = node;
		dfs(it, node, lev + 1);
	}		
}

ll dist(ll x, ll y)
{
	return level[x] + level[y] - 2 * level[lca(x, y)];
}

void dfs1(ll node, ll par)
{
	for(auto it : adj[node])
	{
		if(it == par) continue;
		dfs1(it, node);
	}
	ll x1 = dist(u, node);
	ll x2 = dist(v, node);
	if(x1 < x2) res = max(res, x2 - 1);	
}

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

 	cin >> n >> u >> v;
 	u -= 1; v -= 1;
 	for(int i=0;i<n-1;i++)
 	{
 		cin >> a >> b;
 		adj[a - 1].pb(b - 1);	
 		adj[b - 1].pb(a - 1);	
 	}
 	dfs(0, -1, 0);
 	precom();
 	dfs1(0, -1);
 	cout << res << endl;
    return 0;
}

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

int main()
{
    std::string S;
    std::cin >> S;
    if (S.substr(0, 4) == "YAKI") {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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; }

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

    const int MAX_V_SUM = 2 * 1000 * 100;

    int N, W;
    cin >> N >> W;

    vi w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvll dp(N + 1, vll(MAX_V_SUM + 1, INF));
    dp[0][0] = 0;

    rep(i, N)
    {
        reple(j, 0, MAX_V_SUM)
        {
            chmin(dp[i + 1][j], dp[i][j]);

            if(j - v[i] >= 0) chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        }
    }

    revrep(i, MAX_V_SUM + 1)
    {
        if (dp[N][i] <= W)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;

// copied from betrue12
vector<pair<double, double>> crosspoint(double x1, double y1, double r2, double x2, double y2, double r1){
    x1 -= x2;
    y1 -= y2;
    double S = x1*x1 + y1*y1;
    double a = (S + r1*r1 - r2*r2) / 2;
    double D = S*r1*r1-a*a;
    if(D < 0) return {};

    double A1 = a * x1;
    double B1 = y1 * sqrt(D);
    double A2 = a * y1;
    double B2 = x1 * sqrt(D);
    return {
        {(A1+B1)/S+x2, (A2-B2)/S+y2},
        {(A1-B1)/S+x2, (A2+B2)/S+y2}
    };
}
// END

using pnt = pair<double,double>;
void solve() {
    int n,k;
    cin >> n >> k;
    vector<pnt> a(n);
    vector<double> coeff(n);
    for (int i = 0; i < n; i++) {
        int x,y,z;
        cin >> x >> y >> z;
        a[i] = {x,y};
        coeff[i] = z;
    }


    auto dist = [](pnt& p0, pnt& p1){
        double dx = p0.first - p1.first;
        double dy = p0.second - p1.second;
        return sqrt(dx*dx+dy*dy);
    };

    const double EPS = 1e-8;
    auto ck = [&](double T){
        auto candi = a;
        for (int i = 0; i < n; i++) {
            double x,y;
            tie(x,y) = a[i];
            double z = T/coeff[i];
            for (int j = 0; j < i; j++) {
                double u,v;
                tie(u,v) = a[j];
                double w = T/coeff[j];
                for (auto& p: crosspoint(x,y,z,u,v,w)) {
                    candi.push_back(p);
                }
            }
        }

        for (auto& p0: candi) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                pnt& p1 = a[i];
                if (dist(p0, p1) <= T/coeff[i] + EPS) cnt++;
            }
            if (cnt >= k) return true;
        }
        return false;
    };

    double lo = 0, hi = 1e9;
    while (hi - lo > EPS) {
        double mid = (hi+lo)/2;
        (ck(mid) ? hi : lo) = mid;
    }
    cout << fixed<<setprecision(10)<<lo;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<int> vec[4];
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	ll k,a,b;
  	cin>>k>>a>>b;
  	k-=a-1;
  	if(a+2>=b)cout<<a+k<<endl;
  	else
  	{
  		ll ans=a+(b-a)*(k/2);
  		ans+=k%2;
  		cout<<ans<<endl;
	}
  	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
bool already[1000001]={};
int main(){
	int s;
	scan(s);
	already[s]=1;
	rep1(i,INF){
		if(s%2==0) s/=2;
		else s=3*s+1;
		if(already[s]){
			prin(i+1);
			return 0;
		}
		else already[s]=1;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    double r;
    cin >> r;

    cout<< setprecision(10) << r*2.* M_PI <<endl;

    return 0;
}

Measured memory_bytes: 3780
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    N, Q = map(int, input().split())
    hen = [[int(i)-1 for i in input().split()] for _ in range(N-1)]
    sousa = [[int(i) for i in input().split()] for _ in range(Q)]
    ans = [0]*N
    hen.sort(key=lambda x: x[1])
    hen.sort(key=lambda x: x[0])

    for s in sousa:
        ans[s[0]-1] += s[1]
    for h in hen:
        ans[h[1]] += ans[h[0]]

    # print(hen, sousa)
    print(*ans)


if __name__ == '__main__':
    main()


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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    ans = n % 1000;
    if (ans != 0)
    {
        ans = 1000 - ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
N, P = map(int, input().split())
C = {}
x = 2
while x*x <= P:
    if P % x == 0:
        cnt = 0
        while P % x == 0:
            cnt += 1
            P //= x
        C[x] = cnt
    x += 1
if P > 1:
    C[P] = 1

ans = 1
for k, v in C.items():
    if v >= N:
        ans *= k**(v // N)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    int cnt_minus = 0;
    int mn = 1001001001;
    rep(i, n) {
        cin >> a[i];
        if (a[i] < 0) cnt_minus++;
        a[i] = abs(a[i]);
        chmin(mn, a[i]);
    }
    if (cnt_minus % 2 == 0) {
        cout << accumulate(a.begin(), a.end(), 0LL) << endl;
    } else {
        cout << accumulate(a.begin(), a.end(), 0LL) - 2*mn << endl;
    }

}

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

using namespace std;

const int Nmax = 3005;

int n, i, x, y, val[Nmax];
bool used[Nmax];
vector<int> v[Nmax];

bool dfs(int node)
{
    bool win = 0;
    used[node] = 1;
    for(auto son : v[node])
        if(!used[son] && val[node] > val[son] && !dfs(son))
            win = 1;
    return win;
}

bool solve(int node)
{
    memset(used, 0, sizeof(used));
    return dfs(node);
}

int main()
{
   /// freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=n; ++i) cin >> val[i];

    for(i=1; i<n; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    for(i=1; i<=n; ++i)
        if(solve(i)) cout << i << ' ';

    return 0;
}


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

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		long[] x = new long[3];
		for (int i = 0; i < 3; i++) {
			x[i] = sc.nextInt();
		}
		if (x[0] % 2 == 0 || x[1] % 2 == 0 || x[2] % 2 == 0) {
			System.out.println(0);
		} else {
			Arrays.sort(x);
			System.out.println(x[0] * x[1]);
		}
	}
}

Measured memory_bytes: 23764