akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
using namespace std;
#define LATTE 10000
 
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A<B && B<C) puts("Yes");
    else puts("No");
    return 0;
}
/*

????????????????????????????????????????????????????????????????????????????????? ??? ??? ??? ??? ??? ??? ??? ??? 
??????????????????????????????????????????????????????????????????????????????????????????????????????????????? { 
??????????????????????????????????????????????????????????????????????????????,.-?????¬?????¬??§???l 
???????????????????????£?????????????????? l::::::::}????????????????????????l???l???-?????????_l_;:='?????? ', 
????????????????????????????????????????????°??´???'"?´????????????????????? l???l??????????????????????????????i 
?????????????????????????????????????????????????????????????????????????????? l???l???????????? ??? ??? ??? ??? l 
?????????????????????????????????????????????????????????????????????????????????l???l???????????????????????? ??? } 
????????????????????????????????????????????????????????????????????????????????? l???l???????????????????????? ??? l 
????????????????????????????????????????????????????????????????????????????????????l???l???????????????????????????,' 
?????????????????????????????????????????????????????? ??????????????????????????? ??? ????????????????????????,' 
???????????????????????????????????????????????? .???{??????????????????????????? ??? }???} ??? ??? ??? ??? ,' 
?????????????????????????????????????????????????????? ?????????????????????????????? ?????????????????????/ 
???????????????????????????????????????????????????????????????????¨?¨?¨???????????? ?´?????????????????? / 
????????????????????????????????????????????????????????????????????????/?????? l????????????????????????/ 
?????????????????????????????????????????????????????????????????????????????????j??? ??? ??? ??? ??? / 
?????????????????????????????????????????????????????? ??? ,. -???'"????????£???????????? ??? ??? /???????????? 
?????????????????????????????? ??? ??? ??? ???,.-???'" -?????¬?????¬?????¬?????????,,??? ??? /???????????????????????? ??????-??? 
???????????????????????? ??? ??? ??? ??? ??? ??? ??£ ????????´?????´??????'"?????£????????? /??????????????????????????????????????? ??£??????-??? 
??????????????????????????????????????????????????????????????????????????? ??? ??? ?????????/???????????????????????????????????????????????????????????????-???



*/

Measured memory_bytes: 3072
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

type bc struct {
	x int
	h int
}

type bcs []bc

func (b bcs) Len() int           { return len(b) }
func (b bcs) Less(i, j int) bool { return b[i].x < b[j].x }
func (b bcs) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInt()
	a := nextInt()
	s := make([]bc, n)

	for i := range s {
		s[i].x = nextInt()
		s[i].h = nextInt()
	}
	sort.Sort(bcs(s))

	ans := 0

	bm := make([][]int, 0, n)

	admg := 0
	debugf("%v\n", s)
	for l := range s {
		if s[l].h <= 0 {
			continue
		}

		// proceed r
		//for r < n && s[r].x <= s[l].x+2*d {
		//	r++
		//}
		for len(bm) > 0 && bm[0][1] < s[l].x-2*d {
			admg -= bm[0][0]
			bm = bm[1:]
		}

		// drop bomb
		s[l].h -= admg
		if s[l].h > 0 {
			count := (s[l].h + a - 1) / a
			ans += count
			dmg := a * count
			admg += dmg
			s[l].h -= dmg
			bm = append(bm, []int{dmg, s[l].x})
		}
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 12544
def main():
    n,w=map(int,input().split())
    wv=[]
    for _ in range(n):
        wv.append(list(map(int,input().split())))
    dp=[]
    temp=[]
    for i in range(0,w+1):
        if i < wv[0][0]:
            temp.append(0)
        else:
            temp.append(wv[0][1])
    # print(temp)
    dp.append(temp)
    # print(dp)

    for i in range(1,n):
        temp=[]
        for j in range(0,w+1):
            if j < wv[i][0]:
                temp.append(dp[i-1][j])
            else:
                if j-wv[i][0] >=0:
                    temp.append(max(dp[i-1][j],dp[i-1][j-wv[i][0]] + wv[i][1]))
                else:
                    temp.append(dp[i-1][j])
        # print('temp')
        # print(temp)
        dp.append(temp)
        # print('dp')
        # print(dp)
    print(dp[n-1][w])

if __name__=='__main__':
    main()


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

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

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int a, b;
  cin >> a >> b;
  cout << (b%a ? b-a : a+b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;
ll const MAX = 1005;

ll sqr(ll x) {
	ll s, t;
	s = 0; t = 1000000001;
	while (t - s > 1) {
		ll mid = (s + t) / 2;
		if (mid*mid <= x) {
			s = mid;
		}
		else {
			t = mid;
		}
	}
	return s;
}

int main() {
	ll q;
	cin >> q;
	REP(iii, 1, q) {
		ll a, b;
		cin >> a >> b;
		ll t = a * b;
		ll x = sqr(t);
		if (x*x < t) {
			if ((x + 1)*x < t) {
				cout << 2 * x - 1 << endl;
			}
			else {
				cout << 2 * x - 2 << endl;
			}
		}
		else {
			if (a == x) {
				cout << 2 * x - 2 << endl;
			}
			else {
				cout << 2 * x - 3 << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f
#include<ext/rope>
using namespace __gnu_cxx;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
ll a[25],b[25],c[25],n;
int main()
{
  IOS;
    while(cin>>n)
    {
        rep1(i,n) cin>>a[i];
        rep1(i,n) cin>>b[i];
        rep1(i,n-1) cin>>c[i];
        ll sum=0;
        rep1(i,n)
        {
            sum+=b[a[i]];
            if(i!=1&&a[i]==a[i-1]+1)
            {
                sum+=c[a[i-1]];
            }
        }
        cout<<sum<<'\n';
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, M;
    cin >> N >> M;
    vll A(N), B(M), C(M);
    vector<pair<ll, ll>> CB(M);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (size_t i = 0; i < M; i++)
    {
        cin >> B[i] >> C[i];
        CB[i] = {C[i], B[i]};
    }
    sort(all(CB), greater<pair<ll, ll>>());
    sort(all(A));
    bool flag = true;
    int idx = 0, idx2 = 0;
    while (flag)
    {
        flag = false;
        for (; idx2 < N and CB[idx].second > 0; idx2++)
        {
            if (A[idx2] < CB[idx].first)
            {
                A[idx2] = CB[idx].first;
                CB[idx].second--;
                flag = true;
            }
        }
        idx++;
    }
    cout << accumulate(all(A), 0LL);
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
//Run with 'Ctrl + Alt + N'


int main(void){
    
    int i,x[5];

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

    for(i=0; i<5; i++){
        if (x[i]==0){
            printf("%d",i+1);
        }
    }




    return (0);
}

Measured memory_bytes: 1732
import sys
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))

def main():
    n = getN()
    ans = 0

    for i in range(n + 1):
        if (i % 3) != 0 and (i % 5) != 0:
            ans += i
    print(ans)

if __name__ == "__main__":
    main()

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

#define XMAX 1000000000

int main(){
  int n, i, j, k, x, q;
  char buf[32];
  unsigned int *a;
  a = (unsigned int *)malloc(XMAX/8);
  for (i=0; i<XMAX/8/sizeof(int); i++)
    a[i] = 0;
  
  int count=0;
  unsigned int bit[32];
  unsigned int u = 1;
  for (i=0; i<32; i++) {
    bit[i] = u;
    u *= 2;
  }
  
  fgets(buf, 32, stdin);
  n = atoi(buf);
  for (i = 0; i < n; i++){
    fgets(buf, 32, stdin);
    char *p = buf;
    q = atoi(p);
    p=strchr(p, ' ');
    x = atoi(p);
    
    if (q==0) {
      if ((a[x/32] & bit[x%32]) == 0) {
	a[x/32] |= bit[x%32];
	count++;
      }
      
      k = count;
      if (k==0) {
	putc_unlocked('0', stdout);
      } else {
	if (k<0) {
	  putc_unlocked('-', stdout);
	  k=-k;
	}
	for (j=1; j*10<=k; j*=10);
	for (;j>0; j/=10) {
	  putc_unlocked('0'+k/j, stdout);
	  k %= j;
	}
      }
      putc_unlocked('\n', stdout);
      
    } else if (q==1){
      if ((a[x/32] & bit[x%32]) == 0)
	putc_unlocked('0', stdout);
      else
	putc_unlocked('1', stdout);
      putc_unlocked('\n', stdout);
    } else if (q==2) {
      if (a[x/32] & bit[x%32]) {
	count--;
	a[x/32] &= ~bit[x%32];
      }
    } else { //q==3
      int r = atoi(strchr(p+1, ' '));
      for (int v=x; v<=r; v++) {
	while (a[v/32]==0 && v<=r) v+= 32-v%32;
	
	if (a[v/32] & bit[v%32]) {
	  k = v;
	  if (k==0) {
	    putc_unlocked('0', stdout);
	  } else {
	    if (k<0) {
	      putc_unlocked('-', stdout);
	      k=-k;
	    }
	    for (j=1; j*10<=k; j*=10);
	    for (;j>0; j/=10) {
	      putc_unlocked('0'+k/j, stdout);
	      k %= j;
	    }
	  }
	  putc_unlocked('\n', stdout);
	}
      }
    }
  }
  return 0;
}



Measured memory_bytes: 123732
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
const int maxn=360;
const long long INF=1e18+10;
void chkmin(long long &x,long long y){
	x=x<y?x:y;
}
void chkmax(long long &x,long long y){
	x=x>y?x:y;
}
long long Max(long long x,long long y){
	return x>y?x:y;
}
struct node{
	long long v,r;
}b[maxn];
struct Range{
	long long l,r;
};
bool cmp(const node &A,const node &B){
	return A.r<B.r;
}
bool cmpl(const Range &A,const Range &B){
	return A.l<B.l;
}
long long a[maxn];
int num;
map<vector<long long>,vector<Range> > mp;
map<vector<long long>,vector<Range> >::iterator it;
long long getmnv(long long l,long long r){
	if(l>r) return INF;
	int mnv=0;
	for(int j=59;j>=0;j--){
		if((l&(1LL<<j))==(r&(1LL<<j))) mnv+=(l>>j)&1;
		else{
			if(l&((1LL<<j)-1)) mnv++;
			break;
		}
	}
	return mnv;
}
void Add(int n,int p,long long K){
	if(K<0) return;
	long long Mn=b[1].v-(1<=p);
	vector<long long> vec;
	vec.resize(n);
	for(int i=1;i<=n;i++){
		vec[i-1]=b[i].v-(i<=p);
		chkmin(Mn,vec[i-1]);
	}
	if(Mn<0) return;
	for(int i=1;i<=n;i++)
		vec[i-1]-=Mn;
	Range st=(Range){Max(Mn-K,0),Mn};
	sort(vec.begin(),vec.end());
	mp[vec].push_back(st);
	vector<Range> Vec=mp[vec];
}
int main(){
	int T,n;
	long long K;
	int nxt;
	long long l,r;
	long long ans;
		mp.clear();
		scanf("%d%lld",&n,&K);
		for(int i=1;i<=n;i++)
			scanf("%lld",&a[i]);
		for(int k=0;k<=60;k++){
			for(int i=1;i<=n;i++){
				b[i].v=a[i]>>k;
				b[i].r=a[i]&((1LL<<k)-1);
			}
			sort(b+1,b+n+1,cmp);
			l=0;
			for(int i=1;i<=n;i=nxt+1,l=r+1){
				nxt=i;
				while(nxt<n&&b[nxt+1].r==b[i].r) nxt++;
				r=b[i].r;
				Add(n,i-1,K-getmnv(l,r)-k);
			}
		}
		ans=0;
		vector<Range> vec;
		vector<long long> Vec;
		for(it=mp.begin();it!=mp.end();it++){
			vec=it->second;
			l=0,r=-1;
			sort(vec.begin(),vec.end(),cmpl);
			for(int j=0;j<(int)vec.size();j++){
				if(vec[j].l>r){
					ans=(ans+((r-l+1)%md))%md;
					l=vec[j].l,r=vec[j].r;
				}
				else chkmax(r,vec[j].r);
			}
			ans=(ans+((r-l+1)%md))%md;
		}
		printf("%lld\n",ans);
	return 0;
}

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

void solve(){
    ll l, r;
    cin >> l >> r;

    if(r-l >= 2019){
        cout << 0 << endl;
    }
    else{
        ll tmpmin = 1000000009;
        for(ll i=l; i<r; i++){
            for(ll j=i+1; j<=r; j++){
                tmpmin = min(tmpmin, (i*j)%2019);
            }
        }
        cout << tmpmin << endl;
    }

    
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll calcKnapsack(vector<vector<int>> &weights, vector<vector<ll>> &dp, int n, int capacity){
	ll result = 0;
	if(n<0 || capacity<=0)return 0;
	if(dp[n][capacity] != -1)return dp[n][capacity];
	else if(weights[n][0]>capacity)result = calcKnapsack(weights, dp, n-1, capacity);
	else{
		// exclude the current W, V
		ll tmp1 = calcKnapsack(weights, dp, n-1, capacity);
		// include the current W, V
		ll tmp2 = weights[n][1] + calcKnapsack(weights, dp, n-1, capacity - weights[n][0]);
		result = max(tmp1, tmp2);
	}
	dp[n][capacity] = result;
	return result;
}


int main() {
	// your code goes here
	int N = 0, capacity = 0;;
	cin>>N>>capacity;
	vector<vector<int>> weights;
	while(N--){
		int W, V;
		cin>>W>>V;
		weights.push_back(vector<int>{W,V});
	}
	vector<vector<ll>> dp(weights.size(), vector<ll>(capacity+1, -1));
	cout<<calcKnapsack(weights, dp, weights.size()-1, capacity)<<endl;
	return 0;
}

Measured memory_bytes: 81800
/**
 *  author: nayakashutosh9
 *	[2020-09-22 19:29]
**/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define inf 1e18
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> pbds;
const int N = 300005;
/*******************************************************/


void solve() {
	int n, m; cin >> n >> m;
	vi a(m);
	int s = 0;
	for (int i = 0; i < m; i++) cin >> a[i], s += a[i];
	if (s > n) cout << "-1\n";
	else cout << (n - s) << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T = 1;
	// cin >> T; cin.ignore();
	for (int i = 1; i <= T; i++) {
		// cout << "Case #" << i << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

const double PI = acos(-1.0);
const int N = 501;
const int MOD = 1e9 + 7;
typedef long long ll;

int a[55];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  	int n;
  cin>>n;
  for(int i = 1; i <= n; i++)
    cin>>a[i];
  
  for(int i = 1; i <= n; i++)
  {
    if(a[i] != i){
      swap(a[i], a[a[i]]);
    	break;
    }
  }
  for(int i = 1; i <= n; i++)
      {
        if(a[i] != i)
        {
          cout<<"NO";
          return 0;
        }
     }
     cout<<"YES";


}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(void) {
    int n,m,i;
    int x[100001];
    int y[100001];

    int ans = 0;
    scanf("%d %d", &n, &m);

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

    sort(x, x+m);
    for(i=0; i<m-1; i++) {
        y[i] = x[i+1] - x[i];
        ans += y[i];
//        printf("%d ", y[i]);
    }

    sort(y, y+(m-1), greater<int>());
/*
    for(i=0; i<=m; i++) {
        printf("%d ", y[i]);
    }
*/

    for(i=1; i<=n-1; i++) {
        ans -= y[i-1];
    }

    if (n >=m ){
        printf("%d\n", 0);
    } else {
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	char s[200];
	int sum=0;
	int ans=0;
	int i;
	int n;
	scanf("%d", &n);
	scanf("%s",s);
	for( i = 0 ; i < n; i ++)
	{
		if(s[i]=='I')
		{
			sum=sum+1;
		}
		else
		{
			sum=sum-1;
		}
		if(ans<sum)
			ans=sum;
	}
	printf("%d",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#define DEBUG 1
#define lli long long int

using namespace std;

int main(){

	int n;
	lli T;
	lli *t;
	cin>>n;
	cin>>T;

	t = new lli[n];
	for(int i=0;i<n;i++){
		cin>>t[i];
	}
	lli ans =0;

	for(int i=0;i<n;i++){
		if(i!=n-1 && t[i+1]-t[i]<=T){
			ans+=(t[i+1]-t[i]);
		}else{
			ans+=T;
		}
	}
	cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 1792
n,q=gets.split.map(&:to_i)
arr=[]
n.times do |i|
  name,time=gets.split
  arr.push [name,time.to_i]
end
total=0
while !arr.empty?
  p,t=arr.shift
  if t<=q
    total+=t
    puts "#{p} #{total}"
  else
    t-=q
    total+=q
    arr.push [p,t]
  end
end

Measured memory_bytes: 13308
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        mut s: Chars,
    }
    if s[s.len() - 1] != 's' {
        s.push('s');
    } else {
        s.push('e');
        s.push('s');
    }
    for i in s.iter() {
        print!("{}", i);
    }
}


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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	vector<int> cnt(3);
	for(int i=0;i<n;i++){
		if(s[i]=='a')cnt[0]++;
		else if(s[i]=='b')cnt[1]++;
		else if(s[i]=='c')cnt[2]++;
	}
	sort(cnt.rbegin(),cnt.rend());
	cnt[0]-=cnt[2];
	cnt[1]-=cnt[2];
	if(cnt[0]>=2||cnt[1]>=2)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 512
N, M = list(map(int, input().split()))
dic = {}
for e in map(int, input().split()):
    if e in dic:
        dic[e] += 1
    else:
        dic[e] = 1

for i in range(M):
    B, C = map(int, input().split())
    if C in dic:
        dic[C] += B
    else:
        dic[C] = B
keys = list(dic.keys())
keys.sort(reverse=True)

res = 0

for key in keys:
    n = dic[key]
    if n < N:
        res += key*n
        N -= n
    else:
        res += key*N
        break

print(res)

Measured memory_bytes: 32060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) {}
	ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;


int main() {
	int N; int M;
	while(~scanf("%d%d", &N, &M)) {
		vector<vector<mint>> dp, ndp(N + 1, vector<mint>(N + 1));
		ndp[1][1] = 1;
		rep(k, M) {
			dp.swap(ndp);
			ndp.assign(N + 1, vector<mint>(N + 1));
			rer(i, 1, N) rer(j, 1, i) {
				mint x = dp[i][j];
				if(x.x == 0) continue;
				//行ってない場所
				if(i < N)
					ndp[i + 1][j] += x * (N - i);
				//頂点1を含む強連結成分中
				ndp[i][i] += x * j;
				//それ以外
				ndp[i][j] += x * (i - j);
			}
		}
		mint ans = ndp[N][N];
		printf("%d\n", ans.get());
	}
	return 0;
}


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

int main(){
    int n;
    long a[10002];
    long long suma;

    while(true){
        cin >> n;
        suma = 0;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            cin >> a[i];
            suma += a[i];
        }
        double average = (double)suma / (double)n;
        int count = 0;
        for(int i=0;i<n;i++){
            if(a[i] <= average) count++;
        }

        cout << count << "\n";
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


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

    cout<<a*b;
}

Measured memory_bytes: 3676
/**

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*/

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

long long gcd(long long a,long long b){
    return b?gcd(b,a%b):a;
}

long long primechk[10000];

void preprocess(long long N){
    long long i,j;
    for(i=2;i<=N;i++){
        primechk[i]=1;
    }
    for(i=2;i<=N;i++){
        if(primechk[i]==1){
            for(j=2;i*j<=N;j++){primechk[i*j]=0;}
        }
    }
}

bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}

long long Binexpo(long long a,long long b){
    if(b==0)
        return 1;
    long long res=Binexpo(a,b/2);
    if(b%2){return res*res*a;}
    else{return res*res;}
}
long long Pwr(long long a,long long b,long long m){
    a%=m;
    long long res=1;
    while(b>0){
        if(b%2){res=res*a%m;}
        a=a*a%m;
        b>>=1;
    }
    return res;
}
long long dp[1000000];
int main()
{   long long wt,q,b,c,d,e,f,g,h,i,j,k,x,y,z,sum=0,cnt=0,n,l,r,hi,lo,t,val=1;
    cin>>n>>wt;
    long long w[n],v[n];
    for(i=0;i<n;i++){cin>>w[i]>>v[i];}
    for(i=0;i<n;i++){
        for(j=wt;j>=w[i];j--){dp[j]=max(dp[j-w[i]]+v[i],dp[j]);}
    }
    for(i=0;i<=wt;i++){val=max(val,dp[i]);}
    cout<<val;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    std::reverse(ret.begin(), ret.end());

    return ret;
}

int upf(double num){
    if(num-(int)num>0)return (int)num+1;
    else return num;
}

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

struct Chara{
    int hp;
    int sp;
};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string str;
    cin>>str;
    if(str=="ABC")printm("ARC");
    else printm("ABC");
    return 0;
}


Measured memory_bytes: 3644
/*---> 20 January 2020 <--- > 01:59:54 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
//template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=1e5+5;

int32_t main(){__
	int n;
	cin>>n;
	int cnt=0;
	int x,mn=inf;
	for(int i=1;i<=n;i++){
		cin>>x;
		mn=min(mn,x);
		if(x==mn)
			cnt++;
	}
	cout<<cnt<<"\n";
return 0;
}

Measured memory_bytes: 764
#include <stdlib.h>
#include <stdio.h>

void draw_line(int width, int is_middle)
{
	for (int i = 0; i < width; i++)
	{
		if (is_middle && (i != 0 && i != width - 1))
		{
			printf(".");
		}
		else
		{
			printf("#");
		}
	}
	printf("\n");
}

void draw_regtangle(int height, int width)
{
	for (int i = 0; i < height; i++)
	{
		int is_middle = (i != 0 && i != height - 1);
		draw_line(width, is_middle);
	}
	printf("\n");
}

int main(void)
{
	int height;
	int width;

	while (1)
	{
		scanf("%d %d", &height, &width);
		if (!height && !width)
		{
			break;
		}
		draw_regtangle(height, width);
	}
	return (0);
}



Measured memory_bytes: 1992
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);

  auto g = GraphW!(int, long)(n);
  foreach (_; 0..n-1) {
    int a, b, c; readV(a, b, c); --a; --b;
    g.addEdgeB(a, b, c);
  }

  int q, k; readV(q, k); --k;

  auto d = new long[](n), vst = new bool[](n);

  struct VD { int v; long d; }
  auto qu = DList!int(k);
  vst[k] = true;

  while (!qu.empty) {
    auto v = qu.front; qu.removeFront();
    foreach (e; g[v].filter!(e => !vst[e.dst])) {
      d[e.dst] = d[v] + e.wt;
      vst[e.dst] = true;
      qu.insertBack(e.dst);
    }
  }

  foreach (_; 0..q) {
    int x, y; readV(x, y); --x; --y;
    writeln(d[x]+d[y]);
  }
}

struct GraphW(N = int, W = int, W i = 10^^9)
{
  alias Node = N, Wt = W, inf = i;
  struct Edge { Node src, dst; Wt wt; alias cap = wt; }
  Node n;
  Edge[][] g;
  alias g this;
  this(Node n) { this.n = n; g = new Edge[][](n); }
  void addEdge(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); }
  void addEdgeB(Node u, Node v, Wt w) { g[u] ~= Edge(u, v, w); g[v] ~= Edge(v, u, w); }
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	string s,t;
	cin >> s;
	cin >> t;
	
	t.pop_back();

	if (s == t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;



}

Measured memory_bytes: 3624
n, k = map(int,input().split())
a = [int(i) for i in input().split()]
a.reverse()
lists = []

for i in range(n - k):
    if a[i] <= a[i + k]:
        lists.append(0)
    else:
        lists.append(1)
lists.reverse()

for i in range(n - k):
    if lists[i] == 1:
        print("Yes")
    else:
        print("No")


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

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

int main(){
  int N;
  cin>>N;
  std::vector<int> x(N),y(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i];
  typedef pair<int,int> P;
  std::vector<P> vx(N),vy(N);
  for(int i=0;i<N;i++){
    vx[i]=P(x[i],i);
    vy[i]=P(y[i],i);
  }
  sort(vx.begin(),vx.end());
  sort(vy.begin(),vy.end());
  typedef tuple<int,int,int> T;
  std::vector<T> w(N*2-2);
  for(int i=1;i<N;i++){
    w[i-1]=T(vx[i].first-vx[i-1].first,vx[i].second,vx[i-1].second);
    w[i-1+N-1]=T(vy[i].first-vy[i-1].first,vy[i].second,vy[i-1].second);
  }
  sort(w.begin(),w.end());
  UnionFind uf(N);
  int ans=0;
  for(int i=0;i<2*N-2;i++){
    int ww,ss,tt;
    tie(ww,ss,tt)=w[i];
    if(!uf.same(ss,tt)){
      ans+=ww;
      uf.unite(ss,tt);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5760
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [0] * N
    for i in range(N):
        S[i] = readline().strip()
    M = int(readline())
    T = [0] * M
    for i in range(M):
        T[i] = readline().strip()

    c1 = Counter(S)
    c2 = Counter(T)

    ans = 0
    for k, v in c1.items():
        if ans < v - c2[k]:
            ans = v - c2[k]

    print(ans)
    return


if __name__ == '__main__':
    main()


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

typedef struct {
	char tango[33];
	int kaisuu;
} tlistone;

int comphindo(void*,void*);
int complength(void*,void*);
void tolow(char*);

int main(void) {
	tlistone tlist[1000];
	int tlistmax=0;
	char nowtango[32];
	int i;
	while(1) {
		if(scanf("%s",nowtango)==-1)break;
		tolow(nowtango);
		for(i=0;i<tlistmax;i++) {
			if(strcmp(tlist[i].tango,nowtango)==0) {
				tlist[i].kaisuu++;
				break;
			}
		}
		if(i>=tlistmax) {
			strcpy(tlist[tlistmax].tango,nowtango);
			tlist[tlistmax].kaisuu=1;
			tlistmax++;
		}
	}
	qsort(tlist,tlistmax,sizeof(tlistone),comphindo);
	printf("%s ",tlist[0].tango);
	qsort(tlist,tlistmax,sizeof(tlistone),complength);
	printf("%s\n",tlist[0].tango);
	return 0;
}

void tolow(char* data) {
	int i;
	for(i=0;data[i]!=0;i++) {
		if(data[i]>='A' && data[i]<='Z') {
			data[i]=data[i]-'A'+'a';
		}
	}
}

int comphindo(void* a,void* b) {
	if(((tlistone*)a)->kaisuu<((tlistone*)b)->kaisuu)
		return 1;
	else if(((tlistone*)a)->kaisuu>((tlistone*)b)->kaisuu)
		return -1;
	else return 0;
}

int complength(void* a,void* b) {
	if(strlen(((tlistone*)a)->tango)<
			strlen(((tlistone*)b)->tango))
		return 1;
	else if(strlen(((tlistone*)a)->tango)>
			strlen(((tlistone*)b)->tango))
		return -1;
	else return 0;
}

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

using namespace std;

set<vector<int>> res;

int n,k,s;
void search(vector<int> now, int m) {
    if(now.size() == k) {
        int sum=0;
        for(auto &e : now)
            sum += e;
        if(sum==s) res.insert(now);
        return;
    }
    for(int i=m+1; i<=n; i++) {
        vector<int> t(now);
        t.push_back(i);
        search(t, i);
    }
}

int main(void) {
    while(1) {
        cin>>n>>k>>s;
        if(!n) break;
        res.clear();
        search(vector<int>(), 0);
        cout<<res.size()<<endl;
    }
    return 0;
}

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

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

    int m,n;
    cin >> n >> m;
    int cont = 0;
    vector<int> a(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    
    double treashold = (1 / (double) (4*m)) * (double) sum;
    for(int i=0;i<n;i++){
        if(a[i] >= treashold) cont++;
    }

    if(cont >= m) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int a,b,cnt=0;
	string s;
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3])cnt++;
	}
	cout << cnt << endl;
} 


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

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

	if(a[0] == a[1] && a[1] == a[2])
		printf("Yes\n");
	else if( a[1] == a[2] && a[2] == a[3]) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

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

    long long n;
    cin >> n;
    long long ret = LONG_LONG_MAX;
    for (long long i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret = min(ret, i - 1 + n / i - 1);
        }
    }
    cout << ret << '\n';

    return 0;
}

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

int main()
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k)
        cout<<k<<endl;
    else
    {
        if(b>=(k-a))
        {
            cout<<a<<endl;
        }
        else
        {
            cout<<a-(k-a-b)<<endl;
        }
    }

}



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

int main(){
    int n, l;
    cin >> n >> l;
    
    int tastes [n];
    for (int i=0;i<n;i++){
        tastes[i] = l + (i + 1) - 1;
    }

    int smallest;
    int smallest_index;
    for (int i=0;i<n;i++){
        if (i == 0){
            smallest = abs(tastes[i]);
            smallest_index = i;
        } else {
        if (smallest>=abs(tastes[i])){
            smallest = abs(tastes[i]);
            smallest_index = i;
        }
        }
    }

    int taste_sum = 0;
    for (int i=0;i<n;i++){
        if (i == smallest_index){
            continue;
        }
        taste_sum += tastes[i];
    }
    cout << taste_sum << endl;
    return 0;
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    int ss[26] = {},tt[26] = {},flag = 0;
    for(int i = 0; i < s.length(); i++){
        ss[s[i]-'a']++;
        tt[t[i]-'a']++;
    }

    sort(ss,ss+26),sort(tt,tt+26);
    for(int i = 0; i < 26; i++)
        if(ss[i] != tt[i]) flag = 1;
    
    cout << (flag == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 776
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
A.append(0)

S = np.sum(np.abs(np.diff(A)))
for i in range(1, N+1):
    print(int(S+np.abs(A[i-1]-A[i+1])-(np.abs(A[i-1]-A[i])+np.abs(A[i]-A[i+1]))))

Measured memory_bytes: 32028
//Author : Ayush Jain

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;


int main()
{
	ios_base::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	if(a%b==0) cout<<-1<<endl;
	else cout<<a<<endl;
		
	
		
	return 0;
}

Measured memory_bytes: 256
MOD = pow(10, 9)+7

def combi(n, k, MOD):
    numer = 1
    for i in range(n, n-k, -1):
        numer *= i
        numer %= MOD
    denom = 1
    for j in range(k, 0, -1):
        denom *= j
        denom %= MOD
    return (numer*(pow(denom, MOD-2, MOD)))%MOD

def main():
    n, a, b = map(int, input().split())
    allsum = pow(2, n, MOD)
    s1 = combi(n, a, MOD)
    s2 = combi(n, b, MOD)
    ans = (allsum - s1 - s2 - 1)%MOD
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
s = input()
x, y = map(int, input().split())
totalx = 0
totaly = 0
shift_x = []
shift_y = []
index = 0
while s[index] != "T" and index +1< len(s):
    totalx += 1
    index += 1
flag = 1
count = 0
for i in range(index, len(s)):
    if s[i] == "T":
        if flag == 1:
            shift_x.append(count)
        else:
            shift_y.append(count)
        flag *= -1
        count = 0
    else:
        count += 1
if flag == 1:
    shift_x.append(count)
else:
    shift_y.append(count)
shift_x.sort()
shift_x.reverse()
shift_y.sort()
shift_y.reverse()
for i in range(len(shift_x)):
    if totalx < x:
        totalx += shift_x[i]
    else:
        totalx -= shift_x[i]
for i in range(len(shift_y)):
    if totaly < y:
        totaly += shift_y[i]
    else:
        totaly -= shift_y[i]
if totalx == x and totaly == y:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3188
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i64,
        k: i64,
    }
    println!("{}", std::cmp::min(n % k, k - n % k));
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;

    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,A,B,C=map(int,input().split())
S=[input().strip() for i in range(N)]

ANS=[]
for i in range(N):
    s=S[i]
    if s=="AB":
        if A==B==1 and i<N-1:
            if S[i+1]=="AC":
                A+=1
                B-=1
                ANS.append("A")
            else:
                B+=1
                A-=1
                ANS.append("B")

        else:
            if min(A,B)==A:
                A+=1
                B-=1
                ANS.append("A")
            else:
                B+=1
                A-=1
                ANS.append("B")

    elif s=="BC":
        if B==C==1 and i<N-1:
            if S[i+1]=="AC":
                C+=1
                B-=1
                ANS.append("C")
            else:
                B+=1
                C-=1
                ANS.append("B")

        else:
            if min(B,C)==B:
                B+=1
                C-=1
                ANS.append("B")
            else:
                C+=1
                B-=1
                ANS.append("C")

    else:
        if A==C==1 and i<N-1:
            if S[i+1]=="AB":
                A+=1
                C-=1
                ANS.append("A")
            else:
                C+=1
                A-=1
                ANS.append("C")

        else:
            if min(A,C)==A:
                A+=1
                C-=1
                ANS.append("A")
            else:
                C+=1
                A-=1
                ANS.append("C")

    if min(A,B,C)<0:
        print("No")
        sys.exit()

print("Yes")
print("\n".join(ANS))
        
                
                
            


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

int main()
{
	int n, ans = 1;
	cin >> n;
	string s[200010];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] != s[i + 1])
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9864
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#define P_MAX 3
using namespace std;

int main(){
	int n, i, j, p;
	vector<int> x, y;
	double d, xy_sum, max=0, tmp;
	cin >> n;
	x.reserve(n);
	y.reserve(n);
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	for(i=0;i<n;i++){
		cin >> y[i];
	}
	for(p=1;p<=P_MAX;p++){
		xy_sum = 0;
		for(i=0;i<n;i++){
			tmp = 1;
			for(j=0;j<p;j++){
				tmp *= abs(x[i] - y[i]);
			}
			xy_sum += tmp;
		}
		d = pow(xy_sum, 1.0/(double)p);
		printf("%.6f\n", d);
	}
	//////////////p==???///////////////
	for(i=0;i<n;i++){
		tmp = abs(x[i]-y[i]);
		if(max < tmp) max = tmp;
	}
	printf("%.6f\n", max);
	return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct t{
  ll h,m;
  bool operator<(const t&key)const{
    if(this->h==key.h)return this->m<key.m;
    return this->h<key.h;
  };
  bool operator==(const t&key)const{
   return this->h==key.h&&this->m==key.m;   
  }
};
t ts(ll h,ll m){
 t gen; gen.h=h,gen.m=m;
 return gen;
}
vector<t> v;
int main(){
    ll n,m;
    cin>>n;for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        v.push_back(ts(a,b));
    }
    cin>>m;for(int i=0;i<m;i++){
        ll a,b;cin>>a>>b;
        v.push_back(ts(a,b));
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=0;i<v.size();i++){
        if(i>0)cout<<" ";
     cout<<v[i].h<<":";
     if(v[i].m<10)cout<<"0";
     cout<<v[i].m;
    }cout<<endl;
 return 0;   
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,ans;
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
        ans+=i*(n/i)*(n/i+1)/2;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 3824
/*
  AOJ 0277
  Title: 
  @kankichi573
*/
#include <stdio.h>


int price_table[]={6000,4000,3000,2000};
int shurui,maisuu;

main()
{
        int i;

        for(i=0;i<4;i++)
        {
                scanf("%d %d",&shurui,&maisuu);
                printf("%d\n",price_table[shurui-1]*maisuu);
        }

  return(0);
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
  	ci(n)
  ll ans=0;
  vpll A(n);
  vpll B(n);
  FOR(i,0,n){
	ci(A[i].fi)
    ci(A[i].se)
    B[i].fi=(A[i].fi+A[i].se);
    B[i].se=i;
  }
  SORT(B);
  REV(B);
  FOR(i,0,n){
    if(i%2==0){
      ll I=B[i].se;
      ans+=(B[i].fi-A[I].se);
    }
    else{
      ll I=B[i].se;
      ans-=(B[i].fi-A[I].fi);
                     }
  }
      co(ans) 
}

Measured memory_bytes: 3328