akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
using namespace std;

const int N=100005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,T y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,T y){if(x<y) x=y;}
inline void ch(int &x,int y){x+=y;if(x>=mod) x-=mod;}

int n,m,t,x[N],w[N],res[N];
vi L,R,nl,nr;

int calc(int i){
	if(w[i]==2) return ((x[i]-t)%m+m)%m;
	return (x[i]+t)%m;
}

int solve(){
//	debuge;
	L.clear();R.clear();
	nl.clear();nr.clear();
	int l=0,r=1e9,k,ret,xl=x[1],xr=-1;
//	debuge;
	for(int i=2;i<=n;i++)
		if(w[i]==w[1]){
			L.pb(x[i]-xl);
			xl=x[i];nl.pb(i);
		}
		else{
			if(~xr) R.pb(x[i]-xr);
			xr=x[i];nr.pb(i);
		}
//	debuge;
	if(w[1]==1){
		k=x[nr[0]]-x[1];
		xl=m;for(auto i:L) xl-=i;
		L.pb(xl);reverse(L.begin(),L.end());
		nl.pb(1);reverse(nl.begin(),nl.end());
		xr=m;for(auto i:R) xr-=i;
		R.pb(xr);
	}
	else{
		k=(x[1]+m-xr);
		xl=m;for(auto i:L) xl-=i;
		L.pb(xl);reverse(nl.begin(),nl.end());
		nl.pb(1);reverse(nl.begin(),nl.end());
		xr=m;for(auto i:R) xr-=i;
		reverse(R.begin(),R.end());R.pb(xr);
		reverse(nr.begin(),nr.end());
	}
//	debuge;
	if(k>t*2) return calc(1);
//	for(auto i:L)printf("%d ",i);puts("");
//	for(auto i:R) printf("%d ",i);puts("");
	ret=nr[0];
	while(l<r){
		int mid=l+r+1>>1,sl=(mid+1)/2,sr=mid/2;
		ll len=(ll)k+(ll)m*(ll)(sl/L.size()+sr/R.size());
		for(int i=0;i<sl%L.size();i++) len+=L[i];
		for(int i=0;i<sr%R.size();i++) len+=R[i];
		if(len<=t*2){
			l=mid;
			if(sl>sr) ret=nl[sl%L.size()]; else ret=nr[sr%R.size()];
		}else r=mid-1;
	}
	return calc(ret);
}

int main(){
	scanf("%d%d%d",&n,&m,&t);
	for(int i=1;i<=n;i++) scanf("%d%d",&x[i],&w[i]);
	for(int i=1;i<=n;i++)
		res[i]=calc(i);
	bool isok=0;
	for(int i=1;i<=n;i++) if(w[i]!=w[1]) isok=1;
	if(!isok){
		for(int i=1;i<=n;i++) printf("%d\n",res[i]);
		return 0;
	}
	sort(res+1,res+n+1);
	int a1=solve();
//	debug(a1);
	int xx=x[1],ww=w[1];
	for(int i=1;i<n;i++)x[i]=x[i+1],w[i]=w[i+1];
	x[n]=xx;w[n]=ww;
	int p=x[1];
	for(int i=1;i<=n;i++) x[i]=(x[i]-p+m)%m;
	int a2=(solve()+p)%m;
//	debug(a2);
	for(int i=1;i<=n;i++)
		if(res[i]==a1&&res[i%n+1]==a2){
			for(int j=i;j<=n;j++) printf("%d\n",res[j]);
			for(int j=1;j<i;j++) printf("%d\n",res[j]);
			return 0;
		}
	return 0;
}


Measured memory_bytes: 3316
S = input()
bre = 0
for i in range(len(S)):
	if i % 2 == 1:
		if S[i] == "R":
			bre = 1
	else:
		if S[i] == "L":
			bre = 1
if bre == 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
n, m = map(int, input().split())
ac = "AC"
ac_dic= {}
wa_dic = {}
wa_num = 0
for _ in range(m):
  p, s = input().split()
  if s == ac:
    ac_dic[p] = 1
  elif not (p in ac_dic):
    if p in wa_dic:
      wa_dic[p]+=1
    else:
      wa_dic[p] = 1
for key, value in wa_dic.items():
  if key in ac_dic:
    wa_num += value
ans = len(ac_dic)
print(ans, wa_num)

Measured memory_bytes: 17116
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveC();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int SL = S.length();
		int TL = T.length();
		for (int s_ind = SL - TL; s_ind >= 0; s_ind--) {
			int t_ind = 0;
			for (; t_ind < TL; t_ind++) {
				if (S.charAt(s_ind + t_ind) != '?' && S.charAt(s_ind + t_ind) != T.charAt(t_ind)) {
					break;
				}
			}
			if (t_ind == TL) {
				for (int o_ind = 0; o_ind < SL; o_ind++) {
					if (s_ind <= o_ind && o_ind < s_ind + TL) {
						System.out.print(T.charAt(o_ind - s_ind));
					} else {
						if (S.charAt(o_ind) == '?') {
							System.out.print('a');
						} else {
							System.out.print(S.charAt(o_ind));
						}
					}
				}
				System.out.println();
				return;
			}
		}
		System.out.println("UNRESTORABLE");
	}
}

Measured memory_bytes: 20948
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */

#include <iostream>
#include <fstream>

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

class BKleeneInversion {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n,k;
	    in >> n >> k;
	    vector<int> a(n);
	    rep(i,n){
	        in >> a[i];
	    }
	    ll mo=1e+9+7;
	    vector<int> cnt(2001,0);
	    rep(i,n){
	        cnt[a[i]]++;
	    }
	    for(int i=0;i<2000;i++){
	        cnt[i+1]+=cnt[i];
	    }
	    ll t=(ll)k*(k-1)/2%mo;
	    ll ans=0L;
	    rep(i,n){
	        ans+=cnt[a[i]-1]*t%mo;
	        ans%=mo;
	    }
	    rep(i,n){
	        for(int j=i+1;j<n;j++){
	            if(a[i]>a[j]){
	                ans+=k;
	                ans%=mo;
	            }
	        }
	    }
	    ans%=mo;
	    out << ans << endl;
	}
};


int main() {
	BKleeneInversion solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<vi> vii;
typedef map<int, int> mp;
typedef multiset<int> mset;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int64> vi64;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define form(i,j,k,l) for(int i=j;i<int(k);i+=l)
#define rform(i,j,k,l) for(int i=int(j);i>int(l);i-=l)
#define rep(i, j) for(int i=0;i<int(j);i++)
#define rrep(i, j) for(int i=int(j);i>=0;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define forc(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define INF (int)1e9
#define INF64 (int64)1e18
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define F first
#define S  second
const double pie = acos(-1.0);
template <typename T>
T Max(T x, T y)
{
  return (x > y) ? x : y;
}
template <typename T>
T Min(T x, T y)
{
  return (x > y) ? y : x;
}
int gcd(int n1, int n2)
{
  if (n2 != 0) return gcd(n2, n1 % n2);
  else return n1;
}
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
clock_t time_p = clock();
void rtime() { time_p = clock() - time_p; cerr << "Time Taken : " << (float)1000 * (time_p) / CLOCKS_PER_SEC << "\n";}
int64 binpow(int64 a, int64 b, int64 m) {
  a %= m;
  int64 res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
int main()
{ fast;
  int64 n, k, d;
  cin >> n >> k >> d;
  n = abs(n);
  int64  t = n / d;
  int64 r = n % d;
  if (t > k)
  {
    cout << n - (d * k);
  }
  else
  { int64 ans1 = r;
    int64 ans2 = abs(r - d);
    int64 moves = k - t;
    if (moves % 2 == 0)
      cout << ans1;
    else
      cout << ans2;

  }

}




Measured memory_bytes: 3632
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, M;
	LL ans = 0;
	cin >> N >> M;

	vector<LL>X(M);

	for (int i = 0; i < M; i++) {
		cin >> X.at(i);
	}

	sort(X.begin(), X.end());

	vector<LL>A(M, 0);
	for (int i = 1; i < M; i++) {
		A[i] = X[i] - X[i - 1];
	}

	sort(A.begin(), A.end());

	for (int i = 0; i < M - N + 1; i++) {
		ans += A[i];
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll a,s;
  cin>>a>>s;
  cout<<(a+s)/2+(a+s)%2<<endl;
}


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

int main() {
  int a,b;cin >> a >> b;
  if(a>b && b!=1){
    cout << "Alice" << endl;
  }else if(a<b && a!=1){
    cout << "Bob" << endl;
  }else if(a==1 && b!=1){
    cout << "Alice" << endl;
  }else if(b==1 && a!=1){
    cout << "Bob" << endl;
  }else{
    cout << "Draw" << endl;
  }
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int xa = min(k, a);
    k -= xa;
    int xb = min(k, b);
    k -= xb;
    int xc = k;
    int ans = xa - xc;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    X = int(input())
    for a in range(-120, 120):
        a5 = a ** 5
        for b in range(-120, 120):
            if a5 - b ** 5 == X:
                print(a, b)
                exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 63472
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ccomplex>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>


#define SZ(X) ((X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (LL I = 0; I < N; ++I)
#define REPP(I, A, B) for (LL I = (A); I < (B); ++I)
#define RI(X) scanf("%lld", &(X))
#define RII(X, Y) scanf("%lld%lld", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%lld%lld%lld", &(X), &(Y), &(Z))
#define DRI(X) LL (X); scanf("%lld", &X)
#define DRII(X, Y) LL X, Y; scanf("%lld%lld", &X, &Y)
#define DRIII(X, Y, Z) LL X, Y, Z; scanf("%lld%lld%lld", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long LL;
typedef unsigned long long ull;
using namespace std;

LL A[1000000];
int main(){
    DRIII(N,A,B);
    if(B<A)return 0*puts("0");
    if(N==1 && B!=A)return 0*puts("0");
    cout<<(B*N-B+A-(A*N-A+B))+1<<'\n';
    
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sumi=sum(B)
for i in range(N-1):
    if A[i+1]==A[i]+1:
        sumi+=C[A[i]-1]
print(sumi)

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
    int a,b,c,d;
 
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>b)
    a=b;
    if(c>d)
    c=d;
 printf("%d",a+c);
 
return 0;
}
 

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(a>0&&b>0){
		cout<<"Positive";
	}else if(a<0&&b>0){
		cout<<"Zero";
	}else if(a<0&&b<0){
		if((b-a)%2==0){
			cout<<"Negative";
		}else{
			cout<<"Positive";
		}
	}else{
		cout<<"Positive";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int H, W, a[11][10009], z[10009];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin >> H >> W, H) {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) cin >> a[i][j];
		}
		int ret = 0;
		for(int i = 0; i < (1 << (H - 1)); i++) {
			fill(z, z + W, 0);
			for(int j = 0; j < H; j++) {
				for(int k = 0; k < W; k++) {
					if(i & (1 << j)) z[k] += 1 - a[j][k];
					else z[k] += a[j][k];
				}
			}
			int res = 0;
			for(int j = 0; j < W; j++) {
				res += max(z[j], H - z[j]);
			}
			ret = max(ret, res);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n;
LL a[N], b[N];

int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]), read(b[i]);
	LL tag = 0;
	for (int i = n; i >= 1; i--) {
		LL tmp = b[i] - ((a[i] + tag) % b[i]);
		if (tmp == b[i]) tmp = 0;
		tag += tmp;
	}
	printf("%lld\n", tag);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;cin>>n;
   int a[n+1];memset(a,0,sizeof(a));
   for(int i=2;i<=n;i++)
   {
       int x;cin>>x;
       a[x]++;
   }
   for(int i=1;i<=n;i++)cout<<a[i]<<endl;
}


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

int t[110][110];

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  for (int i = 0; i < N; i++){
    int x, y, a;
    cin >> x >> y >> a;

    if (a == 1) {
      for (int j = 0; j < x; j++) {
        for (int k = 0; k < H; k++) {
          t[j][k] = 1;
        }
      }
    }

    if (a == 2) {
      for (int j = x; j < W; j++) {
        for (int k = 0; k < H; k++) {
          t[j][k] = 1;
        }
      }
    }

    if (a == 3) {
      for (int j = 0; j < W; j++) {
        for (int k = 0; k < y; k++) {
          t[j][k] = 1;
        }
      }
    }

    if (a == 4) {
      for (int j = 0; j < W; j++) {
        for (int k = y; k < H; k++) {
          t[j][k] = 1;
        }
      }
    }
  }
  
  int ret=0;
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (t[i][j] == 0) {
        ret++;
      }
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

ll arr[100000];
int main() {
    cin >> N >> A >> B;
    rep(i, N){
        cin >> arr[i];
    }
    ll sum = 0;
    rep(i, N-1){
        sum += min(B, A*(arr[i+1] - arr[i]));
    }
    cout << sum;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	long long n;
	cin>>n;
	vector<char>res;
	while(n!=0)
	{
		--n;
		res.push_back(n%26+'a');
		n/=26;
	}
	for(int i=res.size()-1;~i;--i)
		cout<<res[i];
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N, K;
    cin >> N >> K;
    vll A(N);
    for(auto &e : A)
        cin >> e;

    for(i = K; i < N; i++) {
        if(A[i] > A[i - K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define INF 2e8
#define all(a) a.begin(), a.end()
#define maxel max_element
#define minel min_element
#define Bit(i) pow(2, i)

int main() {
  int nOfDivi, n;
  scanf("%d %d", &nOfDivi, &n);
  printf("%d\n", n != 100 ? n * (int)pow(10, 2 * nOfDivi)
                          : 101 * (int)pow(10, 2 * nOfDivi));
}


Measured memory_bytes: 384
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab_l = sorted(ab)
ans = 0

count = [0]*(n+1)
for i in range(n):
    count[i+1] = count[i] + ab_l[i][1]

for i in range(n+1):
    if count[i] >= m:
        to_here = i
        minus_count = count[to_here] - m
        break

all_money = [0]*n
for i in range(to_here):
    all_money[i] = ab_l[i][0] * ab_l[i][1]

ans = sum(all_money) - ab_l[to_here-1][0] * minus_count

print(ans)

Measured memory_bytes: 33644
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define f first
#define s second
#define pb push_back

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;cin>>n;
	int ans=0;
	for(int i=1; i<=n; i++){
		int x;
		cin>>x;
		if(i%2==1 && x%2==1){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

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


int main(void)
{
	//変数の宣言
	long long int n,x;
	long long int a,b;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	long long int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int min;
	//データの読み込み
	scanf("%lld %lld",&n,&x);
	
	/*for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}*/
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	ans=n;
	a=x;
	b=n-x;
	
	while(flag==0){
		if(a==b){
			ans=ans+a;
			flag=1;
		}else if(a<b){
			if(b%a!=0){
				ans=ans+(b/a)*a*2;
				b=b%a;
			}else{
				ans=ans+(b/a-1)*a*2;
				b=a;
			}
		}else{
			if(a%b!=0){
				ans=ans+(a/b)*b*2;
				a=a%b;
			}else{
				ans=ans+(a/b-1)*b*2;
				a=b;
			}
		}
	}
	
//	printf("計算部分終了\n");
	//出力
	
	printf("%lld",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

const int N = 100010;

std::vector <int> e[N];
int sg[N], cnt[N];
int n;

void dfs(int u, int fa){
	for (auto v : e[u]){
		if (v == fa){
			continue;
		}
		dfs(v, u);
		sg[u] ^= 1 + sg[v];
	}
}

int main(){
	scanf("%d", &n);
	for (int i = 0, u, v; i < n - 1; ++ i){
		scanf("%d%d", &u, &v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1, 0);
	return printf(sg[1] ? "Alice\n" : "Bob\n"), 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;

struct segtree{
	static const int N=1<<18;
	int seg[N*2];
	segtree(){
		rep(i,N*2) seg[i]=0;
	}
	void update(int x,int v){
		x+=N;
		seg[x]=v;
		x/=2;
		while(x){
			seg[x]=max(seg[x*2],seg[x*2+1]);
			x/=2;
		}
	}
	int getmax(int a,int b,int l=0,int r=N,int k=1){
		if(b<=l||r<=a) return 0;
		if(a<=l&&r<=b) return seg[k];
		return max(getmax(a,b,l,(l+r)/2,k*2),getmax(a,b,(l+r)/2,r,k*2+1));
	}
}seg;


double pi = acos(-1);
const int MN = 200010;
ll sx,sy,tx,ty;
ll N;
ll x[MN],y[MN];

void input(){
	bool swapped = 0;
	cin>>sx>>sy>>tx>>ty;
	if(sy==ty){
		swapped = 1;
		swap(sx,sy);
		swap(tx,ty);
	}
	cin>>N;
	rep(i,N){
		cin>>x[i]>>y[i];
		if(swapped) swap(x[i],y[i]);
	}
}
int main(){
	input();

	if(sx==tx){
		bool is = 0;
		if(sy>ty) swap(sy,ty);
		rep(i,N){
			if(x[i] == sx && sy<y[i] && y[i]<ty) is = 1;
		}
		double ans = (ty-sy)*100;
		if(is)  ans += -20 + 10*pi;
		printf("%.12f\n",ans);
		return 0;
	}

	if(sx>tx){
		swap(sx,tx);swap(sy,ty);
	}
	if(sy>ty){
		int X = 1e8;
		sy = X - sy;
		ty = X - ty;
		rep(i,N) y[i] = X - y[i];
	}

	using P = pair<int,int>;
	vector<P> ps;
	rep(i,N){
		if(sx<=x[i]&&x[i]<=tx&&sy<=y[i]&&y[i]<=ty) ps.pb(P(x[i],y[i]));
	}
	sort(all(ps));
	N = ps.size();
	vector<int> xs,ys;
	for(P p:ps){
		ys.pb(p.sc);
	}
	sort(all(ys));
	rep(i,N){
		y[i] = lower_bound(all(ys),ps[i].sc) - ys.begin();
	}
	int is = 0;
	rep(i,N){
		int v = seg.getmax(0,y[i])+1;
		seg.update(y[i],v);
		chmax(is,v);
	}
	double ans = ((tx-sx) + (ty-sy))*100 - is*(20-5*pi);
	if(is == min(tx-sx,ty-sy)+1){
		ans = ((tx-sx) + (ty-sy))*100 - (is-1)*(20-5*pi) + (-20 + 10*pi);
	}
	printf("%.12f\n",ans);
}


Measured memory_bytes: 8816
function main()
    # スペース区切りの整数の入力
    S = replace(readline(),"\n","")
    T = readline()

    alph   = "abcdefghijklmnopqrstuvwxyz"
    d = Dict{Any,Any}([c=>'0' for c in alph])
    l = length(S)
    for i in 1:l
        if d[S[i]] =='0'
            d[S[i]] = T[i]
            continue
        end
        if d[S[i]] == T[i]
            continue
        end
        if d[S[i]] != T[i]
            print("No")
            exit()
        end
    end

    dd = Dict{Any,Any}([c=>0 for c in alph])
    for l in d
        if l[2] =='0'
           continue
        end
        dd[l[2]] = dd[l[2]] +1
    end
    m= maximum([k[2] for k in dd])
    if m >1
       print("No")
       exit()
    end
       
    #print(d)
    #R = ""
    #for i in 1:l
    #    R = string(R,d[S[i]])
    #end
    print("Yes")
end
main()


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> a(n), v(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> v[i];
    }
    vector<ll> val(n);
    ll sum = 0;
    multiset<ll, greater<ll>> kek;
    for (int i = n - 1; i >= 0; --i) {
        sum += v[i];
        val[i] = sum - (c - a[i]);
        kek.insert(val[i]);
    }
    ll ans = 0;
    sum = 0;
    for (int i = 0; i < n; ++i) {
        kek.erase(kek.find(val[i]));
        sum += v[i];
        ll tmp = sum - a[i];
        if (i != n - 1 && *kek.begin() - a[i] > 0) {
            tmp += *kek.begin() - a[i];
        }
        ans = max(ans, tmp);
    }
    reverse(a.begin(), a.end());
    reverse(v.begin(), v.end());
    for (int i = 0; i < n; ++i) {
        a[i] = c - a[i];
    }
    sum = 0;
    for (int i = n - 1; i >= 0; --i) {
        sum += v[i];
        val[i] = sum - (c - a[i]);
        kek.insert(val[i]);
    }
    sum = 0;
    for (int i = 0; i < n; ++i) {
        kek.erase(kek.find(val[i]));
        sum += v[i];
        ll tmp = sum - a[i];
        if (i != n - 1 && *kek.begin() - a[i] > 0) {
            tmp += *kek.begin() - a[i];
        }
        ans = max(ans, tmp);
    }
    cout << ans;
    return 0;
}

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

#define fread_siz 1024

inline int get_c(void)
{
	static char buf[fread_siz];
	static char *head = buf + fread_siz;
	static char *tail = buf + fread_siz;

	if (head == tail)
		fread(head = buf, 1, fread_siz, stdin);

	return *head++;
}

inline int get_i(void)
{
	register int ret = 0;
	register int neg = false;
	register int bit = get_c();

	for (; bit < 48; bit = get_c())
		if (bit == '-')neg ^= true;

	for (; bit > 47; bit = get_c())
		ret = ret * 10 + bit - 48;

	return neg ? -ret : ret;
}

template <class T>
inline T min(T a, T b)
{
	return a < b ? a : b;
}

const int inf = 2e9;
const int maxn = 20005;

int n, m;
int s, t;

int edges;
int hd[maxn];
int to[maxn];
int nt[maxn];
int fl[maxn];

inline void add(int u, int v, int f)
{
	nt[edges] = hd[u]; to[edges] = v; fl[edges] = f; hd[u] = edges++;
	nt[edges] = hd[v]; to[edges] = u; fl[edges] = 0; hd[v] = edges++;
}

int dep[maxn];

inline bool bfs(void)
{
	static int que[maxn];
	static int head, tail;
	
	memset(dep, 0, sizeof(dep));
	head = 0, tail = 0;
	que[tail++] = s;
	dep[s] = 1;
	
	while (head != tail)
	{
		int u = que[head++], v;
		for (int i = hd[u]; ~i; i = nt[i])
			if (!dep[v = to[i]] && fl[i])
				dep[v] = dep[u] + 1, que[tail++] = v;
	}
	
	return dep[t];
}

inline int dfs(int u, int f)
{
	if (u == t || !f)
		return f;
	
	int used = 0, flow, v;
	
	for (int i = hd[u]; ~i; i = nt[i])
		if (dep[v = to[i]] == dep[u] + 1 && fl[i])
		{
			flow = dfs(v, min(f - used, fl[i]));
			
			used += flow;
			fl[i] -= flow;
			fl[i^1] += flow;
			
			if (used == f)
				return f;
		}
		
	if (!used)
		dep[u] = 0;
		
	return used;
}

inline int dinic(void)
{
	int maxFlow = 0, newFlow;
	
	while (bfs())
		while (newFlow = dfs(s, inf))
			maxFlow += newFlow;
			
	return maxFlow;
}

signed main(void)
{
	n = get_i();
	m = get_i();
	
	memset(hd, -1, sizeof(hd));
	
	for (int i = 1; i <= m; ++i)
	{
		int u = get_i();
		int v = get_i();
		int f = get_i();
		add(u, v, f);
	}
	
	s = 0, t = n - 1;
	
	printf("%d\n", dinic());
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    double middle = 0;
    vector<int> pos(n);
    for (int i = 0; i < n; i++) {
        cin >> pos.at(i);
        middle += pos.at(i);
    }
 
    // get middle pos
    // cout << middle << ", " << middle / pos.size() << endl;
    int middle_pos = 0;
    if (((int)(middle * 10 / pos.size())) % 10 >= 5) {
        middle_pos = middle / pos.size() + 1;
    } else {
        middle_pos = middle = middle / pos.size();
    }
    // cout << middle_pos << endl;
 
    long ans = 0;
    for (size_t i = 0; i < pos.size(); i++) {
        ans += pow((pos.at(i) - middle_pos), 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (a+b+c == 17) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 9940
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int main()
{
	int nN = 0;
	int nA = 0;

	cin >> nN >> nA;
	int nMod = nN % 500;
	if (nMod <= nA)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
S = input()
a,b = int(S[:2]),int(S[2:])
if (1<=a and a<=12) or (1<=b and b<=12):
    if (1<=a and a<=12) and (1<=b and b<=12): 
        print("AMBIGUOUS")
    elif (1<=b and b<=12):
        print("YYMM")
    elif  (1<=a and a<=12): 
        print("MMYY")
  
else:
    print("NA")






Measured memory_bytes: 9084
#include<stdio.h>

int bubblesort( int a[] , int n );

int main( void ){
	
	int n;
	scanf( "%d" , &n );
	
	int a[n];
	int i;
	int c;
	
	for( i = 0; i < n; i++ ){
		scanf( "%d" , &a[i] );
	}
	
	c = bubblesort( a , n );
	
	for( i = 0; i < n; i++ ){
		if( i > 0 ){ printf( " " ); } 
		printf( "%d" , a[i] );
	}
	
	printf( "\n" );
	printf( "%d\n" , c );
	
	return 0;
}

int bubblesort( int a[] , int n ){
	
	int temp , flag = 1;
	int i , j;
	int c = 0;
	
	for( i = 0; flag == 1; i++ ){
		
		flag = 0;
		
		for( j = n - 1; j >= i + 1; j-- ){
			
			if( a[j] < a[ j - 1 ] ){
				temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
				flag = 1;
				c++;
			}
		}
	}
	
	return c;
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m;
    cin>>n;
    map<string,int> m1,m2;
    rep(i,n){
        string s;
        cin>>s;
        m1[s]++;
    }
    cin>>m;
    rep(i,m){
        string t;
        cin>>t;
        m2[t]++;
    }
    int ans=0;
    for(auto p : m1){
        int tmp=p.second-m2[p.first];
        ans=max(ans,tmp);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int arr1[20];
int arr2[20];
vector<int> adj[100005];
vector<int> sz(100005);
int ans = 0;

void dfs(int v, int par = 0)
{
    sz[v] = 1;
    for (auto x : adj[v])
    {
        if (x == par) continue;
        dfs(x, v);
        sz[v] += sz[x];
    }
    if (sz[v] % 2 == 0) ans++;
}

int32_t main()
{
    c_p_c();
    int n;
    cin >> n;
    vector<int> c(n + 1);

    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                int res = x * x + y * y + z * z + x * y + y * z + x * z;
                if (res <= n)
                    c[res]++;
            }
        }
    }

    for (int i = 1; i <= n; i++)
    {
        cout << c[i] << endl;
    }

}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll MOD = ll(1e8) + 9;

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int K, X;
    cin >> K >> X;

    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int h,w,k;cin >>h>>w>>k;
    vector<string>c(h);
    for (int i = 0; i < h; ++i) {
        cin >>c[i];
    }
    int ans=0;
    for (int i = 0; i < (1 << (h + w)); ++i) {
        vector<bool>ci(h,false);
        vector<bool>cj(w,false);
        for (int j = 0; j < h + w; ++j) {
            if(j<h){
                if(i>>j&1)ci[j]=true;
            }
            else {
                if(i>>j&1)cj[j-h]=true;
            }
        }
        int now=0;
        for (int l = 0; l < h; ++l) {
            for (int j = 0; j < w; ++j) {
                if(ci[l]||cj[j])continue;
                if(c[l][j]=='#')now++;
            }
        }
//        cout <<now<<endl;
        if(now==k)ans++;
    }
    cout <<ans <<endl;
}


Measured memory_bytes: 3628
INF = 10 ** 12
def main():
    N, M, X = (int(_) for _ in input().split())
    C = [[int(_) for _ in input().split()] for _ in range(N)]
    out = INF
    for bit in range(1<<N):
        rikai = [0] * M
        cc = 0
        for i in range(N):
            if (bit >> i) & 1:
                cc += C[i][0]
                for j in range(1, M+1):
                    rikai[j-1] += C[i][j]
        if all([rikai[i] >= X for i in range(M)]):
            out = min(out, cc)
    print(out if out != INF else -1)
    return
if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
package main
import (
  "fmt"
  //"math"
)
 
func main(){
  var s string
  fmt.Scan(&s)
  price := 700
  for i:= 0; i < 3; i++ {
    if s[i:i + 1] == "o" {
      price += 100
    }
  }
  fmt.Printf("%d\n", price)
}

Measured memory_bytes: 1832
n=int(input())
koma=list(map(int,input().split()))
koma.append(2020)
m=int(input())
mi=list(map(int,input().split()))
for i in mi:
    if koma[i]>koma[i-1]+1:
        koma[i-1]+=1
koma.remove(2020)
for i in koma:
    print(i)


Measured memory_bytes: 5604
n=gets.to_i
d=gets.split.map(&:to_i)
sum = 0
d.each_with_index do |i, index1|
  d.each_with_index do |j, index2|
   if index1 == index2 then
    sum += 0
  elsif index1 != index2 then
    sum += i * j
  end
 end
end
print sum/2


Measured memory_bytes: 1788
main = do
  col  <- readLn
  lineA <- getLine >>= (\xs -> return (map read (words xs) :: [Int]))
  lineB <- getLine >>= (\xs -> return (map read (words xs) :: [Int]))

  print $ maximum $ map (\i -> sum (take i lineA) + sum (drop (i - 1) lineB)) [1..col]

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> C(H, vector<char>(W, '@'));
  rep(h,H) { rep(w,W) { cin >> C[h][w]; } }
  int ans = 0;
  for(int h=0; h < (1<<H); ++h) {
    for(int w=0; w<(1<<W); ++w) {
      vector<int> hvec;
      vector<int> wvec;
      rep(i, H) {if(h & (1<<i)) { hvec.push_back(i);} }
      rep(i, W) {if(w & (1<<i)) { wvec.push_back(i);} }
      int cnt = 0;
      rep(i, H) {
        rep(j, W) {
          for(auto n:hvec) {
            if(n == i) {
              for(auto m:wvec) {
                if(m == j) {
                  if(C[i][j] == '#') ++cnt;
                }
              }
            }
          }
        }
      }
      if(cnt == K) ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, m;
	while (cin >> n >> m, n){
		vector<int> h(n), w(m);
		for (auto &i : h) cin >> i;
		for (auto &i : w) cin >> i;
		vector<int> hl(n*1000), wl(m*1000);
		for (int i = 0; i < n; i++){
			int sum = 0;
			for (int j = i; j < n; j++){
				sum += h[j];
				hl[sum]++;
			}
		}
		for (int i = 0; i < m; i++){
			int sum = 0;
			for (int j = i; j < m; j++){
				sum += w[j];
				wl[sum]++;
			}
		}
		int ret = 0;
		for (int i = 0; i < min(n, m)*1000; i++){
			ret += hl[i] * wl[i];
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 12992
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;
ll n, k;
ll c[2005][2005];

int main()
{
    scanf("%lld%lld", &n, &k);
    c[0][0] = 1;
    for(ll i = 1; i <= 2000; i++)
    {
        c[i][0] = 1;
        for(ll j = 1; j <= i - 1; j++)
        {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % M;
        }
        c[i][i] = 1;
    }
    for(ll i = 1; i <= k; i++)
    {
        printf("%lld\n", c[k - 1][i - 1] * c[n - k + 1][i] % M);
    }
    return 0;
}


Measured memory_bytes: 30080
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string s;
    cin >> s;
    ll N = s.size();
    ll dp[20][2];
    rep(i, N+1) {
        rep(j, 2) {
            dp[i][j] = 0;
        }
    }
    dp[1][0] = s[0] - '0';
    dp[1][1] = s[0] - '0' - 1;
    for(int i = 1; i < N; i++) {
        ll D = s[i] - '0';
        rep(j, 2) {
            dp[i+1][0] = dp[i][0] + D;
            dp[i+1][1] = max(dp[i][0] + D-1, dp[i][1] + 9);
        }
    }
    print(max(dp[N][0], dp[N][1]));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define nec cout<<"\n";continue; 
#define test int t;cin>>t;while(t--)
#define first ff
#define second ss
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1e9+7;

int main() 
{
    io();
    li p=1;
    li x,n,a;
    	cin>>n>>x>>a;
    	li c=n/x;
    	if(n%x)
    	c++;
    	cout<<a*c;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int D;
	cin >> D;
	int c[26];
	int s[D][26];
	int t[D];
	int ok[26];
	rep(i,26) ok[i] = -1;
	rep(i,26) cin >> c[i];
	rep(i,D){
		rep(j,26){
			cin >> s[i][j];
		}
	}
	rep(i,D){
		cin >> t[i];
		--t[i];
	}
	int ans = 0;
	rep(i,D){
		ans += s[i][t[i]];
		ok[t[i]] = i;
		rep(j,26){
			ans -= c[j] * (i-ok[j]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3720
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		String W = in.readLine();
		String[] Ws = W.split(" ");
		int[] Wi = {Integer.parseInt(Ws[0]),Integer.parseInt(Ws[1])};


		int coin =0;
			for(int i=0;i<2;i++){
			if(Wi[0]<=Wi[1]){
				coin += Wi[1];
				Wi[1]--;
			}else{
				coin += Wi[0];
				Wi[0]--;
			}
		}

		System.out.print(coin);

	}


}


Measured memory_bytes: 22612
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] arr = new int[n + 1];
		for (int i = 0; i < q; i++) {
			arr[sc.nextInt()]++;
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
			if (arr[i] + k - q > 0) {
				sb.append("Yes");
			} else {
				sb.append("No");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 50952
package main

import "fmt"

func main() {
	var a, b, c, d, r int
	fmt.Scan(&a, &b, &c, &d)
	if b <= c || d <= a {
		fmt.Println(0)
		return
	}
	if a <= c {
		r = min(b, d) - c
	} else {
		r = min(b, d) - a
	}
	fmt.Println(r)
}
func min(a, b int) int {
	if b < a {
		return b
	}
	return a
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,i,j;
  cin >> k >> i >> j;
  bool t=true;
  for(int d=i;d<=j;d++){
    if(d%k==0){
      t=false;
      cout << "OK" <<endl;
      break;
    }
  }
  if(t)cout << "NG" << endl;
}
  


Measured memory_bytes: 3656
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2)
	{
		int cnt = 0;
		for (int j = 1; j <= i; j++)
		{
			if (i % j == 0)
				cnt++;
		}
		if (cnt == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll MOD = 1e9+7;

int n, m;
ll dp[100010];
bool broken[100010];

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int index;
        cin >> index;
        broken[index] = true;
    }

    dp[0] = 1;
    if(!broken[1])  dp[1] = 1;
    for(int i = 2; i <= n; i++) {
        dp[i] = (ll)!broken[i-1] * dp[i-1] + (ll)!broken[i-2] * dp[i-2];
        dp[i] %= MOD;
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
class Edge
{
	public:
	int to;
	ll dist;
	int company;
	Edge(int t,ll d,int c)
	{
		to=t;
		dist=d;
		company=c;
	}
};

vector<Edge> g[100];
vector<int> q[100];
vector<int> r[100];
vector<Edge> syuku[100];//同一会社の道をマージしたグラフ
ll wf[100][100];//単一会社に使う全点対最短経路

//comにおける距離distの運賃を計算
ll calcfee(int com,int dist)
{
	ll ret=0;
	int ind=-1;
	int pre=0;
	for(int i=0;i<q[com].size();i++)
	{
		if(dist<q[com][i])
		{
			ind=i;
			break;
		}
		ret+=r[com][i]*(q[com][i]-pre);
		pre=q[com][i];
	}
	if(ind!=-1)
		ret+=r[com][ind]*(dist-pre);
	else
		ret+=r[com][q[com].size()]*(dist-pre);
	return ret;
}

//comのみの路線を使った場合の最小運賃（全点対）
void monowf(int com,int n)
{
	fill(wf[0],wf[100],1e12-1);
	for(int i=0;i<100;i++)
		wf[i][i]=0;
	//初期値入力（ここでは距離のみを求める）
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<g[i].size();j++)
		{
			Edge e=g[i][j];
			if(e.company==com)
			{
				wf[i][e.to]=min(wf[i][e.to],e.dist);
				wf[e.to][i]=min(wf[e.to][i],e.dist);
			}
		}
	}

	//ワーシャルフロイド
	for(int k=0;k<n;k++)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
				wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
		}
	}
	return;
}


int main()
{
	while(1)
	{
		int n,m,c,s,gg;
		cin>>n>>m>>c>>s>>gg;
		s--;gg--;
		if(n==0)
			break;
		for(int i=0;i<100;i++)
		{
			g[i].clear();
			q[i].clear();
			r[i].clear();
			syuku[i].clear();
		}
		for(int i=0;i<m;i++)
		{
			int x,y,a,b;
			cin>>x>>y>>a>>b;
			x--;y--;b--;
			g[x].push_back(Edge(y,a,b));
			g[y].push_back(Edge(x,a,b));
		}
		int p[50];
		for(int i=0;i<c;i++)
			cin>>p[i];
		for(int i=0;i<c;i++)
		{
			for(int j=0;j<p[i]-1;j++)
			{
				int qq;
				cin>>qq;
				q[i].push_back(qq);
			}
			for(int j=0;j<p[i];j++)
			{
				int rr;
				cin>>rr;
				r[i].push_back(rr);
			}
		}
		//ここまで入力
		//各会社ごとのワーシャルフロイド結果を料金グラフに入れる
		for(int i=0;i<c;i++)
		{
			//cerr<<i<<endl;
			monowf(i,n);
			for(int j=0;j<n;j++)
			{
				for(int k=0;k<n;k++)
				{
					//cerr<<wf[j][k]<<" ";
					if(wf[j][k]<1e12-1 && j!=k)
						syuku[j].push_back(Edge(k,calcfee(i,wf[j][k]),0));
				}
				//cerr<<endl;
			}
		}
		
		//ダイクストラ
		priority_queue<P,vector<P>,greater<P>> que;
		ll d[100];
		fill(d,d+100,1e12-1);
		d[s]=0;
		que.push(P(0,s));
		while(!que.empty())
		{
			P p=que.top();
			que.pop();
			if(p.first>d[p.second])
				continue;
			for(int i=0;i<syuku[p.second].size();i++)
			{
				Edge e=syuku[p.second][i];
				if(d[e.to]>p.first+e.dist)
				{
					d[e.to]=p.first+e.dist;
					que.push(P(d[e.to],e.to));
				}
			}
		}

		if(d[gg]==1e12-1)
			d[gg]=-1;
		cout<<d[gg]<<endl;
	}
}


Measured memory_bytes: 9240
N,M = map(int,input().split())
H = list(map(int,input().split()))
"""
G = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    if b-1 not in G[a-1]:
        G[a-1].append(b-1)
    if a-1 not in G[b-1]:
        G[b-1].append(a-1)
print(G)
"""
# 1ならいい展望台
G = [1]*N
for _ in range(M):
    a,b = map(int,input().split())
    if H[a-1] > H[b-1]:
        G[b-1] = 0
    elif H[a-1] < H[b-1]:
        G[a-1] = 0
    else:
        G[a-1] = 0
        G[b-1] = 0
    # print(G)
print(sum(G))

Measured memory_bytes: 20264