akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int ,int > P;
typedef long long ll;

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(A <= C && B >= C){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> A >> B >> C;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int n ,l;
  cin >> n >> l;
  vector<string> ss(n);
  REP(i,n) {
    string s;
    cin >> s;
    ss[i]=s;
  }
  sort(ALL(ss));
  REP(i,n) {
    cout << ss[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 9223372036854775801

#define MAX 1000005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,low,high,mid,sum=0,ans=0,temp,t;
    cin >> a;
    cout<<fixed<<setprecision(20);
    cout<<2*pi*a;
	
    
}














int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 3768
S = input()
NWSE = [0, 0, 0, 0]
for c in S:
    if c=="N":
        NWSE[0]=1
    elif c=="W":
        NWSE[1]=1
    elif c=="S":
        NWSE[2]=1
    else:
        NWSE[3]=1

if (NWSE[0] and not NWSE[1] and NWSE[2] and not NWSE[3]) or (not NWSE[0] and NWSE[1] and not NWSE[2] and NWSE[3]) or (NWSE[0] and NWSE[1] and NWSE[2] and NWSE[3]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define    mod      1000000007
#define    speed    ios_base::sync_with_stdio(false);
#define    up       cin.tie(NULL);
#define    pb       push_back
#define    mp       make_pair
#define    T        int t; cin >> t; while(t--)

int main(){
    speed up
    int n; cin >> n;
    int arr[n+5] , dp[n+5];
    cin >> arr[1]; dp[0] = dp[1] = 0;
    arr[0] = 100000;
    for(int i = 2; i <= n; ++i){
        cin >> arr[i];
        dp[i] = min(abs(arr[i]-arr[i-1]) + dp[i-1] , abs(arr[i]-arr[i-2]) + dp[i-2]);
    }
    cout << dp[n] << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
long long gcd(long long a, long long b){
  if(a%b==0) return b;
  else return gcd(b, a%b);
}
long long lcm(long long a, long long b){
  return a*b/gcd(a, b);
}
int main(){
  long long a, b, c, d, cc=0, cd=0, ccd=0;
  cin >> a >> b >> c >> d;
  
  long long n1 = b - b/c - b/d + b/lcm(c, d);
  long long n2 = (a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c, d);
  
  cout << (n1-n2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    int N,i;cin>>N>>i;
    cout<<N-i+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());




int32_t main(){
int n,k;cin>>n>>k;
vi v(n),vv(n);
int mx=1000*(n);
for(int i=0;i<n;i++){
   cin>>v[i]>>vv[i];
}
vector<vi>dp(n+1,vi(mx+1,inf));
dp[0][0]=1;
dp[1][0]=0;
// for(int i=0;i<n;i++){
   dp[1][vv[0]]=v[0];
// }

for(int i=2;i<=n;i++){
   for(int j=0;j<=mx;j++){
      dp[i][j]=dp[i-1][j];
     if(vv[i-1]<=j)dp[i][j]=min({dp[i][j],dp[i-1][j],v[i-1]+dp[i-1][j-vv[i-1]]});
   
   }
}
int x=0;
int ans=0;
for(int i=0;i<=mx;i++){
//   cout<<dp[n][i]<<" ";
   if(dp[n][i]<=k){x=i;ans=dp[n][i];}
}
// cout<<endl;
// cout<<ans<<endl;
cout<<x<<endl;

}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include "atcoder/all"
using namespace std;

int main(){
    int n, m;
    string s[100];
    cin >> n >> m;
    for(int i=0;i<n;++i) cin >> s[i];

    atcoder::mf_graph<int> G{2 + n*m};
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(s[i][j] == '.'){
                if(i+j & 1) G.add_edge(0, 2 + i*m+j, 1);
                else        G.add_edge(2 + i*m+j, 1, 1);
            }
        }
        for(int j=0;j+1<m;++j){
            if(s[i][j] == '#' || s[i][j+1] == '#') continue;
            if(i+j & 1) G.add_edge(2 + i*m+(j+0), 2 + i*m+(j+1), 1);
            else        G.add_edge(2 + i*m+(j+1), 2 + i*m+(j+0), 1);
        }
    }
    for(int i=0;i+1<n;++i){
        for(int j=0;j<m;++j){
            if(s[i][j] == '#' || s[i+1][j] == '#') continue;
            if(i+j & 1) G.add_edge(2 + (i+0)*m+j, 2 + (i+1)*m+j, 1);
            else        G.add_edge(2 + (i+1)*m+j, 2 + (i+0)*m+j, 1);
        }
    }
    auto ans = G.flow(0, 1);
    auto edges = G.edges();

    for(auto e: edges){
        if(e.flow == 0) continue;
        if(e.from == 0 || e.to == 1) continue;
        e.from -= 2; e.to -= 2;
        if(e.to < e.from) swap(e.to, e.from);

        if(e.from + 1 == e.to && m > 1){ s[e.from/m][e.from%m] = '>'; s[e.from/m][e.from%m+1] = '<'; }
        else{ s[e.from/m][e.from%m] = 'v'; s[e.from/m+1][e.from%m] = '^'; }
    }

    cout << ans << endl;
    for(int i=0;i<n;++i) cout << s[i] << endl;

    return 0;
}

Measured memory_bytes: 5620
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    a, b = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    if a < b:
        print(str(a) * b)
    else:
        print(str(b) * a)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 3"""
        output = """3333"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """7 7"""
        output = """7777777"""
        self.assertIO(input, output)


Measured memory_bytes: 6412
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();

function main(){
  var localInput = input;
  var f = [
    [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ,[0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    ];
  
  var len = localInput.length - 1;
  for(;len--;){
    var l = localInput[len];
    var ix = parseInt(l[0]) + 2;
    var iy = parseInt(l[2]) + 2;
    switch(l[4]){
    case '3': // no-break case;
      f[iy+2][ix]++;
      f[iy-2][ix]++;
      f[iy][ix-2]++;
      f[iy][ix+2]++;
    case '2':
      f[iy+1][ix-1]++;
      f[iy+1][ix+1]++;
      f[iy-1][ix-1]++;
      f[iy-1][ix+1]++;
    case '1':
      f[iy+1][ix]++;
      f[iy][ix-1]++;
      f[iy][ix]++;
      f[iy][ix+1]++;
      f[iy-1][ix]++;
      break;
    }
  }
  
  var nd=0;//not dropped
  var md=0;//most dropped
  var y = 10;
  for(;y--;){
    var x = 10;
    for(;x--;){
      nd += !(f[y+2][x+2]);
      md = mx(f[y+2][x+2], md);
    }
  }
  
  console.log(nd);
  console.log(md);
}
   
function mx(a, b){
 return a - ((a-b) & ((a-b) >> 31));
}

Measured memory_bytes: 7648
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

int n;
int a[120000];
int fl[100];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	int xr = 0;
	for (int i = 0; i < n; ++i) {
		xr ^= a[i];
		int c = 0;
		int x = a[i];
		while (x % 2 == 0)
			x /= 2, ++c;
		fl[c] = 1;
	}
	int ans = 0;
	for (int i = 30; i >= 0; --i) {
		if ((xr >> i) & 1) {
			if (!fl[i]) {
				cout << -1 << "\n";
				return 0;
			}
			xr ^= (1ll << (i + 1)) - 1;
			++ans;
		}
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 640
/*input
15
13 76 46 15 50 98 93 77 31 43 84 90 6 24 14
*/
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		ans += (a & 1) && (i & 1);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#define MAX (int)1e5

int A[MAX];

void swap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; }

int partition(int p, int r) {
    int i, j;
    i = p - 1;
    for (j = p; j <= r; j++) {
        if (A[j] <= A[r]) {
            i++;
            swap(&A[i], &A[j]);
        }
    }
    return i;
}

int main() {
    int i, q, n;

    scanf("%d", &n);

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

    q = partition(0, n - 1);

    for (i = 0; i < n; i++) {
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
        printf( (i == n - 1) ? "\n" : " ");
    }

    return 0;
}

Measured memory_bytes: 2128
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

int main() {
  int switchNum, lightNum;
  cin >> switchNum >> lightNum;
  vector<vector<int>> lights(lightNum);
  for(int i=0; i<lightNum; i++){
    int switchsOfLight;
    cin >> switchsOfLight;
    for(int j=0; j<switchsOfLight; j++){
      int switchIndex;
      cin >> switchIndex;
      lights[i].push_back(switchIndex);
    }
  }
  for(int i=0; i<lightNum; i++){
    int evenOrOdd;
    cin >> evenOrOdd;
    lights[i].push_back(evenOrOdd);
  }
  
  int checkerBit;
  int bitMax = pow(2, switchNum);
  int counter = 0;
  for(checkerBit=0; checkerBit<bitMax; checkerBit++){
    int onLight = 0;
    for(int j=0; j<lightNum; j++){
      int onswitch = 0;
      for(int k=0; k<lights[j].size()-1; k++){
        if(checkerBit & (1 << lights[j][k] - 1)) onswitch++;
      }
      if(onswitch % 2 == lights[j].back()){
        onLight++;
      }
    }
    if(onLight == lightNum) counter++;
  }
  cout << counter;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1
if p[n-1] == n:
    ans += 1
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S,T;
    cin >> S >> T;
    
    int s = S.size();
    int t = T.size();
    int diff = s - t;
    int ans = 100000;
    for(int i = 0; i < diff + 1; i ++){
        int count = 0;
        for(int j = 0; j < t; j ++){
            if(S.at(i+j) != T.at(j)){
                count ++;
            }
        }
        if(ans > count){
            ans = count;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n,f[100],p,a,b;
string s;
int main()
{
  cin>>n>>s;
  for(int i=0;i<n;i++)
  {
    p=0;
    if(s[i]==')')
    {
      for(int j=i-1;j>=0;j--)
        if(s[j]=='('&&f[j]<1){f[j]=p=1;break;}
      if(p<1)a++;
    }
    else
    {
      for(int j=i+1;j<n;j++)
        if(s[j]==')'&&f[j]<1){f[j]=p=1;break;}
      if(p<1)b++;
    }
  }
  for(int i=0;i<a;i++)cout<<'(';
  for(int i=0;i<n;i++)cout<<s[i];
  for(int i=0;i<b;i++)cout<<')';
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
const int MOD = 1000000007;
int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xx = x2 - x1;
    int yy = y2 - y1;
    cout << x2 - yy << " " << y2 + xx << " " << x1 - yy << " " << y1 + xx
         << endl;
}

Measured memory_bytes: 256
y, m, d = map(int, input().split("/"))
hy, hm, hd = 2019, 4, 30
# print(y, m, d)

h = "Heisei"
t = "TBD"

if y < hy:
    print(h)
elif y > hy:
    print(t)
elif m < hm:
    print(h)
elif m > hm:
    print(t)
elif d < hd:
    print(h)
elif d > hd:
    print(t)
else:
    print(h)
    


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

using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int h, m, s;
	while(cin >> h >> m >> s && (h != -1 || m != -1 || s != -1)) {
		int second = 2 * 60 * 60 - h * 60 * 60 - m * 60 - s;
		int tsecond = second * 3;
		int hour = second / (60 * 60);
		second -= hour * 60 * 60;
		int minute = second / 60;
		second -= minute * 60;
		int thour = tsecond / (60 * 60);
		tsecond -= thour * 60 * 60;
		int tminute = tsecond / 60;
		tsecond -= tminute * 60;
		printf("%02d:%02d:%02d\n%02d:%02d:%02d\n", hour, minute, second, thour, tminute, tsecond);
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

// 未完

int A[100001];
int m[100001]; // m[i] : A[0]～A[i]の最小値

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

	int N, T; cin >> N >> T;
	cin >> A[0];
	m[0] = A[0];
	int dif = 0;
	for (int i = 1; i < N; i++) {
		cin >> A[i];
		m[i] = min(m[i - 1], A[i]);
		dif = max(dif, A[i] - m[i]);
	}

	// 差がdifになる組み合わせがいくつあるか

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] - m[i] == dif) ans++;
	}

	cout << ans << endl;

	return 0;
}

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


int main() {
  long int a, b, x;
  cin >> a >> b >> x;
  long int n_a = a / x;
  if(a % x == 0) --n_a;
  long int n_b = b / x;
  long int answer = n_b - n_a;
  cout << answer << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Equals | diff Equals.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Equals.cpp && ./a.out

/*
 
 3/29/2020
 
 14:40-
 
 */

const int MAX_N=1e6+1;
int P[MAX_N];
int N,M;

struct UF {
public:
  int N,G/* # of disjoint sets */;
  UF(int N): N(N) { init(N); }
  void init(int N) {
    par=vector<int>(N),sz=vector<int>(N,1);
    for(int i=0; i<N; ++i) par[i]=i,sz[i]=1;
    G=N;
  }
  int find(int x) { return par[x]==x?x:par[x]=find(par[x]); }
  int size(int x) { return sz[find(x)]; }
  bool sameset(int x, int y) { return find(x)==find(y); }
  int unite(int x, int y) {
    x=find(x),y=find(y);
    if(x==y) return x;
    int p=x,c=y;
    if(sz[p]<sz[c]) swap(p,c);
    G--,sz[p]=sz[c]=sz[p]+sz[c];
    par[c]=p;
    return p;
  }
private:
  vector<int> par,sz;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  VI pos(N);
  REP(i,N) {
    cin>>P[i];
    P[i]--;
    pos[P[i]]=i;
  }
  UF uf(N);
  REP(i,M) {
    int a,b; cin>>a>>b;
    --a,--b;
    uf.unite(a,b);
  }
  int res=0;
  REP(i,N) if(uf.find(i)==uf.find(pos[i])) ++res;
  cout<<res<<endl;
  
  return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  string s, t, tt;
  char c;
  ll count, minv=LLONG_MAX;
  vecll alpha(26, 0);
  cin >> s;
  forll(i, 0, s.size())
	alpha[s[i] - 'a']++;

  forll(i, 0, 26){
	if (alpha[i] == 0)
	  continue;
	c = i + 'a';
	t = s;
	tt = t;

	count = 0;
	while (t != string(t.size(), c)){
	  forll(j, 0, t.size() - 1){
		if(tt[j] == c || tt[j + 1] == c)
		  t[j] = c;
	  }
	  count++;
	  tt = t;
	  t.pop_back();
	  if(t == "")
		break;
	}
	minv = min(minv, count);
  }
  cout << minv << endl;
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
e = [list(map(int, input().split())) for i in range(q)]

w = [0]*n
res = 0
def dfs(x, y):
    global w, res
    if x == n:
        tmp = 0
        for a, b, c, d in e:
            if w[b-1]-w[a-1] == c: tmp += d
        res = max(res, tmp)
        return
    for i in range(y, m+1):
        w[x] = i
        dfs(x+1, i)

dfs(0, 1)
print(res)

Measured memory_bytes: 76140
// AOJ 1056: Ben Toh
// 2017.12.15 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

double dp[100001][21];
double s[100001];

int main()
{
	int i, j;
	double t;

	dp[1][1] = 1;
	for (i = 1; i <= 100000; i++) for (j = 0; j <= 20; j++) {
		dp[i+1][j+1] = dp[i][j] * pow(0.5, j);
		dp[i+1][0]  += dp[i][j] * (1.0 - pow(0.5, j));
	}

	for (i = 0; i <= 100000; i++) {
		t = 0;
		for (j = 1; j <= 20; j++) t += dp[i+1][j];
		s[i+1] = t + s[i];
	}
  
	while (scanf("%d", &i) && i > 0) printf("%.8lf\n", s[i]);
	return 0;
}

Measured memory_bytes: 19172
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1 << 30;
const ll MOD = 1000000007LL;

struct Elem {
    int town, cnt, cost;
    Elem() {}
    Elem(int a, int b, int c) : town(a), cnt(b), cost(c) {}
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    }
};

int rec[5010][5010], C[5010], R[5010];
vector<int> G[5010];

signed main() {
    int N, K; cin >> N >> K;
    for(int i=0; i<N; i++) {
        cin >> C[i] >> R[i];
    }
    for(int i=0; i<K; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    fill(rec[0], rec[N], INF);
    rec[0][R[0]] = C[0];
    priority_queue<Elem> que;
    que.push(Elem(0, R[0], C[0]));

    while(que.size()) {
        Elem cur = que.top(); que.pop();
        if(cur.cost > rec[cur.town][cur.cnt]) continue;
        // fprintf(stderr, "town = %lld, cnt = %lld, cost = %lld\n", cur.town + 1, cur.cnt, cur.cost);
        
        // まだそのタクシーで移動できる
        if(cur.cnt > 0) {
            int ncnt = cur.cnt - 1;
            for(int to : G[cur.town]) {
                if(rec[to][ncnt] > cur.cost) {
                    rec[to][ncnt] = cur.cost;
                    que.push(Elem(to, ncnt, rec[to][ncnt]));
                }
            }
        }

        // のりかえる
        {
            int ncnt = R[cur.town];
            int ncost = cur.cost + C[cur.town];
            if(rec[cur.town][ncnt] > ncost) {
                rec[cur.town][ncnt] = ncost;
                que.push(Elem(cur.town, ncnt, ncost));
            }
        }
    }

    int ans = *min_element(rec[N-1], rec[N-1] + 5010);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 101464
n = int(input())
data = {
    1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0
}

for _ in range(n):
    x = float(input())
    if x < 165.0:
        data[1] += 1
    elif 165.0 <= x < 170.0:
        data[2] += 1
    elif 170.0 <= x < 175.0:
        data[3] += 1
    elif 175.0 <= x < 180.0:
        data[4] += 1
    elif 180.0 <= x < 185.0:
        data[5] += 1
    elif 185.0 <= x:
        data[6] += 1

for key, val in data.items():
    a = '*' * val
    print('{}:{}'.format(key, a))


Measured memory_bytes: 5608
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
K, X = map(int, input().split())

res = []
for x in range(X-K+1, X+K):
    if x < -100000 or x > 1000000:
        continue
    res.append(x)

print(*res)


Measured memory_bytes: 21528
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        float[] A = new float[N];

        for (int i = 0; i < N; i++)
            A[i] = sc.nextFloat();

        float ans = 0.0f;

        for (int i = 0; i < N; i++)
            ans += 1 / A[i];

        ans = 1 / ans;

        System.out.println(ans);

    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;

  if (S=="SUN")
    cout << 7 << endl;
  else if (S=="MON")
    cout << 6 << endl;
  else if (S=="TUE")
    cout << 5 << endl;
  else if (S=="WED")
    cout << 4 << endl;
  else if (S=="THU")
    cout << 3 << endl;
  else if (S=="FRI")
    cout << 2 << endl;
  else if (S=="SAT")
    cout << 1 << endl;

  return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S, T;
    cin >> S >> T;
    print(T+S);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

class UnionFind {
public:
    explicit UnionFind(int element_count) : v(element_count, -1) {}
    bool unite(int x, int y) {
        auto rx = root(x);
        auto ry = root(y);
        if (rx == ry)
            return false;

        auto nx = -v[rx];
        auto ny = -v[ry];
        if (nx < ny) {
            v[rx] = -(nx + ny);
            v[ry] = rx;
        } else {
            v[rx] = ry;
            v[ry] = -(nx + ny);
        }
        return true;
    }

    int size(int x) { return -v[root(x)]; }

    int root(int x) {
        if (v[x] < 0)
            return x;
        auto rx = root(v[x]);
        v[x] = rx;
        return rx;
    }

    bool same(int x, int y) { return root(x) == root(y); }

private:
    std::vector<int> v;
};

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

    auto friends = vector<vector<int>>(n);
    auto blocking = vector<vector<int>>(n);
    auto uf = UnionFind(n);

    for (auto i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
        friends[a].push_back(b);
        friends[b].push_back(a);
    }
    for (auto i = 0; i < k; ++i) {
        int c, d;
        cin >> c >> d;
        --c, --d;
        blocking[c].push_back(d);
        blocking[d].push_back(c);
    }

    for (auto v = 0; v < n; ++v) {
        auto cnt = uf.size(v);
        for (auto f : friends[v])
            if (uf.same(v, f))
                cnt--;
        for (auto b : blocking[v])
            if (uf.same(v, b))
                cnt--;
        cout << (cnt - 1) << (v + 1 == n ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 17020
#include<bits/stdc++.h>
using namespace std;
#define ioS            ios::sync_with_stdio(false);cin.tie(0);
#define li             long int
#define ll             long li
#define ull            unsigned ll
#define pi             pair<int,int>
#define vi             vector<int>
#define vli            vector<li>
#define vll            vector<ll>
#define vvi            vector<vector<int>>
#define pb             push_back
#define mp             make_pair
#define forn(i,s,n)    for(auto i=s;i<n;++i)               
#define forr(i,s,n)    for(auto i=s;i>=n;--i) 
#define all(x)         (x).begin(),(x).end()
const ll mx = 1e9;
string alpha = "abcdefghijklmnopqrstuvwxyz";

void solve(int test)
{
    int x;
    cin>>x;
    cout<<(1-x)<<endl;
}   
int32_t main()
{
    ioS    
    int t;
    // cin>>t;
    // forn(i,1,t+1)
        solve(0);
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n){
		cin >> h[i];
	}
	
	//cost[i]=iからNー1に至るまでの最小コストと定義する
	vector<int> cost(n);
	cost[0] = 0;
	cost[1] = abs(h[1]-h[0]);
	
	for (int i = 2; i < n; ++i) {
		cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]));
	}
	
	cout << cost[n-1] << endl;
	
}



Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std; 
const int mod = 1000000007;
vector<vector<int> > neighbours(200000);
int parent[200000];
int fact[200000];
pair<int,int> ways[200000];
int num_ways[200000];
long long gcdExtended(int a, int b, long long *x, long long *y); 
long long modu(long long p){
	return ((p%mod)+mod)%mod;
}
// Function to find modulo inverse of a 
int modInverse(int a, int m) 
{ 
    long long x, y; 
    long long g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        return 1; 
    else
    { 
        // m is added to handle negative x 
        int res = (x%m + m) % m; 
        return  res; 
    } 
} 
  
// C function for extended Euclidean Algorithm 
long long gcdExtended(int a, int b, long long *x, long long *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return (long long) b; 
    } 
  
    long long x1, y1; // To store results of recursive call 
    long long gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 -  x1*(b/a); 
    *y = x1; 
  
    return gcd; 
} 
long long ncr(int p,int q){
	long long  x = modu(((long long)fact[p] )* modInverse(fact[q],mod));
	long long  y = modu(( x)*modInverse(fact[p-q],mod));
	return y;
}
void dfs(int node){
	//cout<<"Node"<<endl;
	int num = 0;
	for(int j=0;j<neighbours[node].size();j++){
		if(neighbours[node][j]!=parent[node]){
			parent[neighbours[node][j]] = node;
			dfs(neighbours[node][j]);
			
			num = num + ways[neighbours[node][j]].first;
		}
	}
	long long s = 1;
	int chosen = 0;
	for(int j=0;j<neighbours[node].size();j++){
		if(neighbours[node][j]!=parent[node]){
			s = modu(modu(s * ways[neighbours[node][j]].second)*ncr(num - chosen,ways[neighbours[node][j]].first));
		    chosen = chosen+ ways[neighbours[node][j]].first;
		}
		
	}
	ways[node].second = (int) s;
	ways[node].first = num+1;
}

int main(){
	
	int N;
	cin>>N;
	for(int j=0;j<N-1;j++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		neighbours[b].push_back(a);
		neighbours[a].push_back(b);
	}
	fact[0] = 1;
	for(int j =1;j<=N;j++){
		fact[j] = modu(((long long)fact[j-1])*j);
	}
	parent[0] = 0;
	dfs(0);
//	cout<<"ways"<<endl;
//	for(int jj=0;jj<N;jj++){
//		cout<<ways[jj].second<<" ";
//	}
//	cout<<endl;
	int current = 0;
	num_ways[0] = ways[0].second;
	queue<int> q;
	q.push(current);
	while(!q.empty()){
		current = q.front();
	//	cout<<current<<endl;
		int chosen = 0;
		if(current!=0){
			long long s = (long long) num_ways[parent[current]];
			s = modu(s* modInverse(ncr(N-1,ways[current].first),mod));
			s = modu(s * ncr(N-1,ways[current].first-1));
			num_ways[current] = (int) s;
			
		}
		q.pop();
		for(int j=0;j<neighbours[current].size();j++){
			if(neighbours[current][j] != parent[current]){
				q.push(neighbours[current][j]);
			}
		}
	}
	for(int j=0;j<N;j++){
		cout<<num_ways[j]<<endl;
	}
	return 0;
}


Measured memory_bytes: 18676
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static Scanner s=new Scanner(System.in);
	static long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	
	public static void main(String[] __){
		ArrayDeque<CompletableFuture<String>> deque=new ArrayDeque<>();
		while(true){
			final String in=s.nextLine();
			if(in.equals(".")) break;
			deque.add(CompletableFuture.supplyAsync(()->solve(in)));
		}
		System.out.println(
				deque.parallelStream().map(CompletableFuture::join).sequential().collect(Collectors.joining("\n"))
				);
	}
	static String solve(String v){
		v=v.replaceAll("[^\\[\\]()]","");
		ArrayDeque<Character> deque=new ArrayDeque<>();
		char c;
		for(int i=0;i<v.length();i++){
			switch(c=v.charAt(i)){
			case '[':
			case '(':
				deque.add(c);
				break;
			case ']':
				if(deque.isEmpty()||deque.pollLast()!='[')
					return "no";
				break;
			case ')':
				if(deque.isEmpty()||deque.pollLast()!='(')
					return "no";
				break;
			}
		}
		return deque.isEmpty()?"yes":"no";
	}
}

Measured memory_bytes: 60552
#include <iostream>
#include <vector>
#include <fstream>
#include "bits/stdc++.h"
using namespace std;
#define bit(x, i) (x & (1 << i))          //select the bit of position i of x
#define lowbit(x) ((x) & ((x) ^ ((x)-1))) //get the lowest bit of x
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
#define abs(x) (x < 0 ? (-x) : x)   
#define IN(i, l, r) (l < i && i < r) //the next for are for checking bound
#define LINR(i, l, r) (l <= i && i <= r)
#define LIN(i, l, r) (l <= i && i < r)
#define INR(i, l, r) (l < i && i <= r)
#define clr(a, x) memset(a, x, sizeof(a)) //set elements of array to some value
#define char2Int(c) (c - '0')
#define lastEle(vec) vec[vec.size() - 1]
#define SZ(x) ((int)((x).size()))
#define REMAX(a, b) (a) = max((a), (b)) // set a to the maximum of a and b
#define REMIN(a, b) (a) = min((a), (b));
#define FOREACH(i, t) for (typeof(t.begin()) i = t.begin(); i != t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(), (c).end()                                          //handy for function like 
#define PRESENT(c, x) ((c).find(x) != (c).end())
#define CPRESENT(c, x) (find(ALL(c), x) != (c).end())
#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define ui unsigned int
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef pair<int, int> ii;
#define F(i, L, R) for (int i = L; i < R; i++) //next four are for for loops
#define FE(i, L, R) for (int i = L; i <= R; i++)
#define FF(i, L, R) for (int i = L; i > R; i--)
#define FFE(i, L, R) for (int i = L; i >= R; i--)
const int mod = 1e9 + 7;
namespace EU
{
void max_self(int &a, int b)
{
a = max(a, b);
}
}
void add_self(int &a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}
const int nax = 10123;
char k[nax];

int main() {
    scanf("%s", k);
    int D;
    scanf("%d", &D);
    int len = strlen(k);
    vvi dp(D, vi(2));
// dp[sum][smaller_already] - the number of ways to choose digits so far
// st the sum of digits modulo D is the sum and smaller already
// says wethere we already chosen some digit smaller than K
dp[0][0] = 1;
F(where, 0, len) {
    vvi new_dp(D, vi(2));
    F(sum, 0, D) {
        for(bool sm_already :  {false, true}) {
            F(digit, 0, 10) {
                if (digit > k[where] - '0' && !sm_already) {
                    break;
                }
                add_self(new_dp[(sum + digit) %D][sm_already || (digit < k[where] - '0')], dp[sum][sm_already]);
            }
        }
    }
    dp = new_dp;
}
    int answer = (dp[0][false] + dp[0][true]) % mod;
    --answer;
    if(answer == -1) {
        answer = mod - 1;
    }
    printf("%d\n", answer);
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long[] a = new long[5];
		for (int i = 0; i < n; i++) {
			String[] s = sc.next().split("");
			if (s[0].equals("M"))
				a[0]++;
			if (s[0].equals("A"))
				a[1]++;
			if (s[0].equals("R"))
				a[2]++;
			if (s[0].equals("C"))
				a[3]++;
			if (s[0].equals("H"))
				a[4]++;
		}
		long ans = 0;
		ans += a[0] * a[1] * a[2];
		ans += a[1] * a[2] * a[3];
		ans += a[2] * a[3] * a[4];
		ans += a[0] * a[2] * a[3];
		ans += a[0] * a[2] * a[4];
		ans += a[0] * a[3] * a[4];
		ans += a[0] * a[1] * a[3];
		ans += a[0] * a[1] * a[4];
		ans += a[1] * a[2] * a[4];
		ans += a[1] * a[3] * a[4];
		System.out.println(ans);
	}
}

Measured memory_bytes: 64708
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n,m=map(int,input().split())
    fib=[0,1]
    a,b=0,1
    for _ in range(n):
        a,b=b,(a+b)%MOD
        fib.append(b)
    A=[-1]+[int(input()) for _ in range(m)]+[n+1]
    ans=1
    for i in range(m+1):
        ans*=fib[A[i+1]-A[i]-1]%MOD
    print(ans%MOD)

resolve()

Measured memory_bytes: 46404
#include <iostream>
#include <climits>
#include <vector>
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n+3),ret(n+3,INT_MAX);
	for (int i=0; i<n; ++i) cin >> v[i];
	ret[0]=0;
	for (int i=0; i<n; ++i){
		ret[i+1] = min(ret[i+1],abs(v[i]-v[i+1])+ret[i]);
		ret[i+2] = min(ret[i+2],abs(v[i]-v[i+2])+ret[i]);
	}
	cout << ret[n-1];
	return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    
    int n, m;
    cin >> n >> m;
    cout << (n == m ? "Yes" : "No") << '\n';


    return 0;
}

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

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

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long  INF = 5e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

string s, t;
int c[30], d[30];

int main() {
	cin >> s >> t;
	for (int i = 0;i < 26;i++)c[i] = -1, d[i] = -1;
	for (int i = 0;i < s.size();i++) {
		if (c[s[i] - 'a'] == -1) {
			c[s[i] - 'a'] = t[i] - 'a';
		}
		else {
			if (c[s[i] - 'a'] != t[i] - 'a') {
				cout << "No" << endl;
				return 0;
			}
		}
		if (d[t[i] - 'a'] == -1) {
			d[t[i] - 'a'] = s[i] - 'a';
		}
		else {
			if (d[t[i] - 'a'] != s[i] - 'a') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 900
n = int(input())
p = list(map(int, input().split()))

c = 0
for i in range(1,n-1):
  if p[i-1] < p[i] and p[i] < p[i+1]:
    c += 1
  elif p[i-1] > p[i] and p[i] > p[i+1]:
    c += 1
print(c)

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, n) {
        int tmp = v[i] - c[i];
        if(tmp > 0) ans += tmp;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
<?php
  list($a, $b, $c, $d, $e, $f) = explode(" ", trim(fgets(STDIN)));

  $max_p = 0;
  $max_w = 0;
  $max_s = 0;

  for($i=0; $a * $i <= $f; $i = $i + 100){
    for($j=0; $a * $i + $b * $j <= $f; $j = $j + 100){
      if($i == 0 && $j == 0){
        break;
      }
//      echo ($a * $i + $b * $j).PHP_EOL;
      for($k=0; ($k * $c) * 100 <= $e * ($a * $i + $b * $j); $k++){
        for($l=0; ($k * $c + $l * $d) * 100 <= $e * ($a * $i + $b * $j); $l++){
          if(($k * $c + $l * $d) + ($a * $i + $b * $j) > $f){
            break;
          }
//          if($k == 0 && $l == 0){
//            break;
//          }
          if($max_p <= ($k * $c + $l * $d) / ($a * $i + $b * $j)){
            $max_p = ($k * $c + $l * $d) / ($a * $i + $b * $j);
            $max_w = ($k * $c + $l * $d) + ($a * $i + $b * $j);
            $max_s = ($k * $c + $l * $d);
          }
        }
      }
    }
  }
  echo $max_w." ".$max_s;

Measured memory_bytes: 16156
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	string S,T;
	int N;
	int tmp;
	ll i,j;
	ll answer=0;
	ll counter=0;
	vector<int> given;

	cin >> S >> T;

	N=S.size();
	for(i=0;i<N;i++){
		if(S[i]!=T[i]) counter++;
	}


	answer=counter;
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 3784
import sys
from pprint import pprint

mod = 10**9 + 7
def solve(n, a):

    zero_count = [0] * 60
    for a_i in a:
        for j in range(61):
            if a_i >> j & 1:
                zero_count[j] += 1

    ans = 0
    for i, count in enumerate(zero_count):
        # ans += (2**i) * (count * (n - count)) 
        ans += pow(2, i, mod) * (count % mod) * ((n - count) % mod) 
        ans %= mod
    print(ans)

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    a = map(int, sys.stdin.readline().strip().split(" "))
    
    solve(n, a)

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

int main() {
  int N;
  cin>>N;
  vector<int> v(N);
  rep(i,N){
    cin>>v.at(i);
  }
  int n=0;
  int m=0;
  int p=0;
  int q=0;
  int ans=0;
  rep(j,N){
    rep(i,N){
    if(v.at(i)>n){
      n=v.at(i);
      p=i;
    }
    }
    ans+=n;
    v.at(p)=0;
  rep(i,N){
    if(v.at(i)>m){
      m=v.at(i);
      q=i;
    }
  }
    ans-=m;
    v.at(q)=0;
    n=0;
    m=0;
    p=0;
    q=0;
  }
  cout<<ans<<endl;
    
}

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

int main() {
    int N; cin>>N;
    ll C,K; cin>>C>>K;
    vector<ll> T(N,0);
    for(int i=0;i<N;i++){
        cin>>T[i];
    }
    sort(T.begin(),T.end());
    ll ans=0;
    ll count=0;
    ll saisyo=0;
    for(int i=0;i<N;i++){
        if(T[i]>saisyo+K || count==C){
            count=0;
        }
        if(count==0){
            saisyo=T[i];
            ans++;
        }
        count++;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    string s, s1;
    cin >> s >> s1;
    ll ans = 0;
    for(ll i = 0; i < s.length(); ++i){
        if(s[i] == s1[i])ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
<?php
	$a = fgetc(STDIN);
	$b = fgetc(STDIN);
	$c = fgetc(STDIN);
	$d = fgetc(STDIN);
	if (($a == $b) || ($b == $c) || ($c == $d)) {
		echo "Bad" . "\n";
    } else {
		echo "Good" . "\n";
    }
      
?>

Measured memory_bytes: 3576