akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
  int t;    //データセットの個数
  cin >> t;
  for (int i=0; i<t; i++)   //データセット
  {
    int n;    //ブロックの個数
    cin >> n;
    int up_diff = 0;
    int down_diff = 0;
    int* block = new int[n];
    for (int j=0; j<n; j++)
    {
      cin >> block[j];
    }

    for (int j=0; j<n-1; j++)     //ブロック
    {
      int diff;
      diff = block[j+1] - block[j];
      if ( diff < 0 )         //down
      {
        if ( down_diff < -diff )
        {
          down_diff = -diff;
        }
      }
      else if ( 0 < diff )    //up
      {
        if ( up_diff < diff )
        {
          up_diff = diff;
        }
      }
    }
    cout << up_diff << ' ' << down_diff << endl;
    delete[] block;
  }
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

ll n,a,b,k;

int main(){
  cin>>n>>k;
  ll ans=0,tmp=0;
  for(ll i=k+1;i<=n;i++){
    tmp=0;
    tmp+=((n)/i)*(i-k);
    if(k==0){
      if((n-((n/i)*i))-(k) >=0)tmp+=(n-((n/i)*i))-(k);
    }
    else if((n-((n/i)*i))-(k-1) >=0)tmp+=(n-((n/i)*i))-(k-1);
//    cout<<i<<" "<<((n)/i)*(i-k)<<" "<<(n-((n/i)*i))-(k-1)<<endl;
    ans+=tmp;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)

def main():
    x=int(input())
    l=lcm(360,x)
    print(l//x)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 61788
#include <cstdio>
#define LL long long
LL n, now = 100;

int main() {
	scanf ( "%lld", &n );
	for ( LL i = 1;;i ++ ) {
		now = now + now / 100;
		if ( now >= n ) return ! printf ( "%lld", i );
	}
	return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h> 
using namespace std;
int n,k,a[5050],b[15050],v[5050];
long long ans = -1000000000;
bool vis[5050];
int main() {
	scanf("%d%d",&n,&k);
	for (int i = 1;i <= n; i++) {
		scanf("%d",&a[i]);
	}
	for (int i = 1;i <= n; i++)
		scanf("%d",&v[i]);
	for (int i = 1;i <= n; i++) {
		if (!vis[i]) {
			int tail = 0;
			int now = i;
			while (!vis[now]) {
				vis[now] = 1;
				b[++tail] = v[now];
				now = a[now];
			}
			long long sum = 0;
			for (int j = 1;j <= tail; j++)
				b[j+tail+tail] = b[j+tail] = b[j],sum += b[j];
			int ti = k;
			int ci = (ti-1)/tail-1;
			if (ci < 0)
				ci = 0;
			sum = sum>0?ci*sum:0;
			ti -= ci*tail;
			long long ma = -1000000000;
			for (int j = 1;j <= tail; j++) {
				long long tmp = 0;
				for (int kk = 0;kk < ti; kk++) {
				
					tmp += b[j+kk];
					ma = max(ma,tmp);
				}
			}
			ans = max(ans,sum+ma);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
        int R, G, B, N;
        cin >> R >> G >> B >> N;

        long long cnt = 0;
        for(int i = 0; i <= 3000; i++)
        {
                for(int j = 0; j <= 3000; j++)
                {
                        int r = R*i;
                        int g = G*j;
                        if(r+g > N) continue;
                        int sum = N - r - g;
                        if(sum % B == 0) cnt++;
                }
        }

        cout << cnt << endl;

        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a>>b>>c>>d;
	if(a+b>c+d){
		cout << "Left"<<endl;
	}
	if(a+b==c+d){
		cout<< "Balanced"<<endl;
	}
	if(a+b<c+d){
		cout << "Right"<<endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class RollingHash {
    static const ll base1 = 1009;
    static const ll base2 = 2009;
    static const ll mod1 = 1000000007;
    static const ll mod2 = 1000000009;
    vector<ll> hash1, hash2, pow1, pow2;

public:
    RollingHash(const string &S) {
        int n = (int) S.size();
        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        pow1.assign(n + 1, 1);
        pow2.assign(n + 1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = (pow1[i] * base1) % mod1;
            pow2[i + 1] = (pow2[i] * base2) % mod2;
        }
    }

    /**
     * S の [l, r) のハッシュ値を返す
     * O(1)
     */
    inline pair<ll, ll> get(int l, int r) const {
        ll res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (res2 < 0) res2 += mod2;
        return make_pair(res1, res2);
    }

    /**
     * S のハッシュ値を返す
     * O(1)
     */
    inline pair<ll, ll> hash() const {
        return get(0, (int) hash1.size() - 1);
    }

    /**
     * LCP (Longest Common Prefix)
     * O( log N )
     */
    inline int getLCP(int a, int b) const {
        int len = min((int) hash1.size() - a, (int) hash1.size() - b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a + mid) != get(b, b + mid)) high = mid;
            else low = mid;
        }
        return low;
    }

    /**
     * hash h1 と 長さ h2_len の文字列の hash h2 を結合
     */
    pair<ll, ll> concat(pair<ll, ll> h1, pair<ll, ll> h2, int h2_len) {
        return make_pair((h1.first * pow1[h2_len] + h2.first) % mod1, (h1.second * pow2[h2_len] + h2.second) % mod2);
    }
};

void Main() {
    string T, P;
    cin >> T >> P;
    RollingHash rollingHash(T);
    RollingHash rollingHash1(P);

    ll N = T.size();
    ll M = P.size();
    vector<ll> ans;
    rep(i, N - M + 1) {
        auto v = rollingHash.get(i, i + M);
        auto u = rollingHash1.hash();
        if (u == v) ans.push_back(i);
    }
    rep(i, ans.size()) {
        cout << ans[i] << '\n';
    }
}

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



Measured memory_bytes: 44784
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int m, t, p, r;
	while (cin >> m >> t >> p >> r, m) {
		pair<pair<int, int>, pair<int, int>>log[2014];
		//time team problem result
		for (int i = 0; i < r; i++) 
			cin >> log[i].first.first >> log[i].first.second >> log[i].second.first >> log[i].second.second;
		pair<pair<int, int>, int>point[60];
		//problems penalty teamnum
		int penalty[60][15] = {};
		for (int i = 1; i <= t; i++) {
			point[i].first.first = 15;
			point[i].first.second = 0;
			point[i].second = i;
		}
		for (int i = 0; i < r; i++) {
			if (log[i].second.second) {
				//WRONG ANSWER
				penalty[log[i].first.second][log[i].second.first]++;
			}
			else{
				//ACCEPTED
				point[log[i].first.second].first.first--;
				point[log[i].first.second].first.second += penalty[log[i].first.second][log[i].second.first] * 20 + log[i].first.first;
			}
		}
		for (int i = 1; i < t; i++) {
			for (int j = i + 1; j <= t; j++) {
				if (point[i].first > point[j].first)swap(point[i], point[j]);
				else if (point[i].first == point[j].first)if (point[i].second < point[j].second)swap(point[i], point[j]);
			}
		}
		cout << point[1].second;
		for (int i = 2; i <= t; i++) {
			if (point[i].first == point[i - 1].first)cout << '=';
			else cout << ',';
			cout << point[i].second;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3100
N, W = [int(i) for i in input().split()]
weight, value = [0] * (N + 1), [0] * (N + 1)

for i in range(1, N + 1):
    weight[i], value[i] = [int(i) for i in input().split()]

#%%

sum_value = sum(value)
dp = [[float("inf")] * (sum_value + 1) for _ in range(N + 1)]
dp[0][0] = 0

for i in range(1, N + 1):
    for j in range(sum_value + 1):
        if j >= value[i]:
            dp[i][j] = min(dp[i - 1][j], weight[i] + dp[i - 1][j - value[i]])
        else:
            dp[i][j] = dp[i -1][j]
        
ans = 0
for i in range(sum_value + 1):
    if dp[N][i] <= W:
        ans = i

print(ans)

Measured memory_bytes: 308168
a=input()
b=input()
dic_a={}
dic_b={}
for i in a:
    if i not in dic_a:
        dic_a[i]=1
    else:
        dic_a[i] += 1
for i in b:
    if i not in dic_b:
        dic_b[i]=1
    else:
        dic_b[i] += 1


print("Yes" if (sorted(dic_a.values())==sorted(dic_b.values())) else "No" )


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;

llint h, w;
llint a[1005], b[1005];

int main(void)
{
	cin >> h >> w;
	for(int i = 0; i < h; i++) cin >> a[i];
	for(int i = 0; i < w; i++) cin >> b[i];
	sort(a, a+h);
	sort(b, b+w);
	
	for(int i = 0; i < h-1; i++){
		if(a[i] == a[i+1]){
			cout << 0 << endl;
			return 0;
		}
	}
	for(int i = 0; i < w-1; i++){
		if(b[i] == b[i+1]){
			cout << 0 << endl;
			return 0;
		}
	}
	
	llint ans = 1;
	for(int i = h*w; i >= 1; i--){
		int r = lower_bound(a, a+h, i) - a;
		int c = lower_bound(b, b+w, i) - b;
		if(a[r] == i && b[c] == i) continue;
		if(a[r] == i) ans *= w-c, ans %= mod;
		else if(b[c] == i) ans *= h-r, ans %= mod;
		else{
			llint rem = (h-r)*(w-c)-(h*w-i);
			if(rem <= 0){
				cout << 0 << endl;
				return 0;
			}
			ans *= rem, ans %= mod;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
inputnum,outputnum = (int(n) for n in input().split(' '))
while True:
    data = {}
    for i in range(inputnum):
        temp = input().split(' ')
        data[temp[0]] = [int(temp[2]) - int(temp[1]) + 1,int(temp[2])]
    for o in range(outputnum):
        targ = int(input())
        for k,v in data.items():
            if v[0] <= targ  <= v[1]:
                print(k + ' ' + str(targ-v[0] + 1))
                break
        else:
            print("Unknown")
    inputnum,outputnum = (int(n) for n in input().split(' '))
    if inputnum == outputnum == 0:
        break

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

int main() {
  int x; cin >> x;
  if (x == 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3628
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(n):
    if A[i] >= B[i]:
        ans += B[i]
    else:
        ans += A[i]
        B[i] -= A[i]

        if A[i+1] >= B[i]:
            ans += B[i]
            A[i+1] -= B[i]
        else:
            ans += A[i+1]
            A[i+1] = 0

print(ans)

Measured memory_bytes: 18624
N, K = map(int, input().split())
a = list(map(int, input().split()))
chk = [0] * N
start = -1
ido = [0]
chk[0] = 1
index = 0
cnt = 0

while True:
    index = a[index] - 1
    if chk[index] == 0:
        chk[index] += 1
        cnt += 1
        ido.append(index)
    else:
        start = index
        break

if cnt >= K:
    print(ido[K] + 1)
    exit()
tmp = ido.index(start)
ido = ido[tmp:]
K -= tmp

print(ido[K % len(ido)] + 1)

Measured memory_bytes: 95432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int balance = (a + b) - (c + d);
  if (balance > 0) {
    cout << "Left" << endl;
  }
  else if (balance == 0) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void solve(vector<string>& res, string cur, char alpha){
    int cnt = 0;
    vector<int> pos;
    for(int i=0;i<cur.size();i++){
        if(cur[i] == '?'){
            ++cnt;
            if(cnt == 1){
                cur[i] = alpha;
            } else {
                pos.push_back(i);
            }
        }
    }
    if(pos.empty()){
        res.push_back(cur);
        return;
    }
    for(int i=0;i<(1<<pos.size());i++){
        string next = cur;
        for(int j=0;j<pos.size();j++){
            if(i&(1<<j)) next[pos[j]] = alpha;
        }
        solve(res, next, alpha+1);
    }
}

int main(){
    int N;
    while(cin >> N){
        vector<string> res;
        solve(res, string(N, '?'), 'a');
        sort(res.begin(), res.end());
        for(auto& s : res) cout << s << endl;
    }
}

Measured memory_bytes: 7796
# include<cstdio>
# include<cstring>
# include<algorithm>
using namespace std;
const int N = 2e5 + 5;
typedef long long ll;
int a[N];
int n,val;
ll ans;
int main()
{
	scanf("%d",&n);
	for (int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]),a[i] -= i;
	sort(a + 1,a + n + 1);
	if (n & 1) val = a[n / 2 + 1];
	else val = (a[n / 2] + a[n / 2 + 1]) >> 1;
	for (int i = 1 ; i <= n ; ++i) ans += (ll)abs(a[i] - val);
	printf("%lld\n",ans);
	return 0;
}

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

int main() {

  long long H, W, ans;

  cin >> H >> W;
  
  if(H == 1 || W == 1){
    ans = 1;
  }
  else if(H % 2 == 0){
    ans = (H * W) / 2;
  }else{
    if(W % 2 == 0){
      ans = (((H - 1) * W) / 2) + (W / 2);
    }else{
      ans = (((H - 1) * W) / 2) + (W / 2) + 1;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 04 Apr 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        br.close();
        System.out.println(c + " " + a + " " + b);
    }
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        String str = scanner.nextLine();

        int maxCnt = 0;
        int cnt = 0;

        for(int c: str.toCharArray()){
            if(c == 'A' || c == 'T' || c == 'C' || c == 'G'){
                cnt++;
            }else{
                maxCnt = Math.max(maxCnt, cnt);
                cnt = 0;
            }
        }

        maxCnt = Math.max(maxCnt, cnt);

        System.out.println(maxCnt);

    }

}


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

int main(){
    int N;
    cin>>N;
    int sum = 0;
    int max = 0;
    rep(i, N){
        int p;
        cin>>p;
        sum += p;
        max = std::max(max, p);
    }

    cout << (sum-max+max/2) << endl;
}


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

using namespace std;

long long prime = 1000000007;

long long pow(long long a, long long r) {
    if (r == 0) return 1LL;
    long long y = pow(a, r/2);
    long long z = y * y % prime;
    if (r % 2 == 1) {
        return z * a % prime;
    }
    return z;
}

long long inv(long long x) {
    return pow(x, prime-2);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    if (x < y) {
        swap(x, y);
    }
    // x >= y is now always true.
    if (x > 2*y) {
        cout << 0 << endl;
        return 0;
    }
    // z is the total number of moves.
    int z = (x + y)/3;
    int w = y - z;
    // w = y - z is the number of moves (1, 2).
    // So the answer is \binom{z}{w} = z(z-1)...(z-w+1)/w!
    long long top = 1, bottom = 1;
    for (int i = z; i >= z-w+1; --i) {
        top = (top * i) % prime;
    }
    for (int i = 1; i <= w; ++i) {
        bottom = (bottom * i) % prime;
    }
    cout << (top * inv(bottom) % prime) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    md = 10 ** 9 + 7
    n = int(input())
    aa = LI()
    cnt = [[0] * 2 for _ in range(61)]
    for a in aa:
        for i in range(61):
            cnt[i][a & 1] += 1
            a >>= 1
    #print(cnt)
    base = 1
    ans = 0
    for c0, c1 in cnt:
        ans += base * c0 * c1
        ans %= md
        base = base * 2 % md
    print(ans)

main()


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

int main(){
  vector<int>A(5);
  for(int i = 1; i <= 5; i++){
    cin >> A[i];
  }
  for(int i = 1; i <= 5; i++){
    if(i != A[i])cout << i << endl;
  }
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;

	cout << ((a < b && b < c) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i=0;i<n;i++)

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359


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

    // process
    if (S == "ABC") {
        cout << "ARC";
    } else {
        cout << "ABC";
    }

    return 0;
}


Measured memory_bytes: 3036
#include <iostream>

using namespace std;

int main(){
   double a;
   while(cin >> a){
      double s = a;
      for(int i=2;i<11;i++){
	 if (i % 2) a /= 3;
	 else  a *= 2;
	 s += a;
      }
      cout.precision(8);
      cout << fixed << s << endl;         
   }
   return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long
#define M 1000000007
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    string s;
    cin >> s;
    int l = s.length();
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
    {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<long long,long long>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a);}
                a=(a*a);
                b>>=1;
        }
    return ans;
        
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>v1,v2,v3;
    for(int i=0;i<n;i++){
        if(s[i]=='R')v1.push_back(i);
        else if(s[i]=='G')v2.push_back(i);
        else v3.push_back(i);
    }
    int ans=0;
    for(auto i:v1){
        int j=lower_bound(v2.begin(),v2.end(),i)-v2.begin();
        for(int k=j;k<v2.size();k++){
            int l=lower_bound(v3.begin(),v3.end(),v2[k])-v3.begin();
            ans+=v3.size()-l;
            if(binary_search(v3.begin(),v3.end(),i+2*(v2[k]-i)))ans--;
        }
    }
    for(auto i:v1){
        int j=lower_bound(v3.begin(),v3.end(),i)-v3.begin();
        for(int k=j;k<v3.size();k++){
            int l=lower_bound(v2.begin(),v2.end(),v3[k])-v2.begin();
            ans+=v2.size()-l;
            if(binary_search(v2.begin(),v2.end(),i+2*(v3[k]-i)))ans--;
        }
    }
    for(auto i:v2){
        int j=lower_bound(v3.begin(),v3.end(),i)-v3.begin();
        for(int k=j;k<v3.size();k++){
            int l=lower_bound(v1.begin(),v1.end(),v3[k])-v1.begin();
            ans+=v1.size()-l;
            if(binary_search(v1.begin(),v1.end(),i+2*(v3[k]-i)))ans--;
        }
    }
    for(auto i:v2){
        int j=lower_bound(v1.begin(),v1.end(),i)-v1.begin();
        for(int k=j;k<v1.size();k++){
            int l=lower_bound(v3.begin(),v3.end(),v1[k])-v3.begin();
            ans+=v3.size()-l;
            if(binary_search(v3.begin(),v3.end(),i+2*(v1[k]-i)))ans--;
        }
    }
    for(auto i:v3){
        int j=lower_bound(v2.begin(),v2.end(),i)-v2.begin();
        for(int k=j;k<v2.size();k++){
            int l=lower_bound(v1.begin(),v1.end(),v2[k])-v1.begin();
            ans+=v1.size()-l;
            if(binary_search(v1.begin(),v1.end(),i+2*(v2[k]-i)))ans--;
        }
    }
    for(auto i:v3){
        int j=lower_bound(v1.begin(),v1.end(),i)-v1.begin();
        for(int k=j;k<v1.size();k++){
            int l=lower_bound(v2.begin(),v2.end(),v1[k])-v2.begin();
            ans+=v2.size()-l;
            if(binary_search(v2.begin(),v2.end(),i+2*(v1[k]-i)))ans--;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll mod = 1e9 + 7;
const ll MAX1E5 = 100000;
const ll MAX1E10 = 10000000000;


int main() {
    int N, M, p = 0;
    ll n = 1, m = 1, answer;
    vector<int> C(8);
    cin >> N >> M;
    if (abs(N - M) > 1) {
        cout << p << endl;
        return 0;
    }
    REP(i, N) {
        n = (n * (N - i)) % mod;
    }

    REP(i, M) {
        m = (m * (M - i)) % mod;
    }
    answer = (n * m )% mod;
    if (N == M) {
        answer = answer * 2 % mod;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
 
int main(void){
    while(1){
        int n, k, ans = 0;
        cin >> n >> k;
        if(n == 0 && k == 0) break;//00???????????????????????????
        bool flag = false;//?????¨???????????????0??????????????????????????????????????°
        vector<bool> num(n + 1, false);//?????±??????????????????????????????
        rep(i, k){
            int tmp; scanf("%d", &tmp);
            if(tmp == 0){
                flag = true;
                continue;
            }
            num[tmp] = true;//?????±????????????
        }
        int pre = 0;//???????????£?¶??¢????????????°???????????°?????\????????????
        int cnt = 0;//?????????????????£?¶??¢????????????°???????????°????????????????????????????????¨
        int now;
        int end = 0;//???????????£?¶???¨????¢?????????????????????°????????\????????????
        bool rennketukanouseiflag = false;//??£??\????????£?¶??¢????????????????1?????¨?????????true
        reps(i, 1, n + 1){
            //??°???i????????????
            if(num[i] == true){
                if(i == end + 2) rennketukanouseiflag = true;//???????????£?¶??¢?????????¨?????????1
                cnt++;
            //??°???i???????????¨???
            }else{
                now = cnt;//?????¨??????????????£?¶???¨????¢????????????°???????????°
                //?????¨?????????0????????????????????????????????£??\????????£?¶???¨??????????????°???1???????????¨?????????????????£?¶???¨???????????????????????£????????????
                if(flag == true && rennketukanouseiflag == true) ans = max(ans, pre + now + 1);
                //???????????¶????????????????????¨?????????????????£?¶???¨????¢???????????????§?????§??????????????¢?????°??????
                else ans = max(ans, now);
                
                // ?????????
                cnt = 0;
                rennketukanouseiflag = false;
                pre = now;//?????¢??£?????????
                end = i;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3148
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

iscanl :: (Int -> a -> b -> a) -> a -> V.Vector b -> V.Vector a
iscanl !k !a !v = V.scanl' (\(!x) (!i, !v) -> k i x v) a (V.indexed v)

iscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
iscanlU !k !a !v = VU.scanl' (\(!x) (!i, !v) -> k i x v) a (VU.indexed v)

ipostscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
ipostscanlU !k !a !v = iscanlU (\(!i) (!a) (!b) -> k (i + 1) a b)
                               (k 0 a (VU.unsafeHead v))
                               (VU.unsafeTail v)

solve :: Int -> VU.Vector Int -> Double
solve !n !pn = VU.sum $ VU.drop ((n + 1) `div` 2) $ V.last dp
 where
  dp :: V.Vector (VU.Vector Double)
  dp =
    iscanl
        ( \(!i) (!prev) (!pint) -> VU.generate
          (i + 2)
          ( \(!j) ->
            let pi = fromIntegral pint / 100
                qi = 1 - pi
            in  (if j == 0 then 0 else prev VU.! (j - 1) * pi)
                  + (if i + 1 == j then 0 else prev VU.! j * qi)
          )
        )
        (VU.singleton 1)
      $ V.convert pn

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt
  let readDouble :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readDouble b = readInt $ B.drop 2 b

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  pn <- VU.unfoldrN n readDouble <$> B.getLine
  print $ solve n pn


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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class B {
public:

    struct Dice {
      int i{}, j{}, k{}, x{}, y{};
      Dice(int i, int j, int k, int x, int y):
        i(i), j(j), k(k), x(x), y(y){}
    };

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w; cin >> h >> w;
      vector<vector<int>> mat(h, vector<int>(w));
      rep(i, h) {
        rep(j, w) {
          char c; cin >> c;
          if (c == '#') {
            mat[i][j] = 100;
          } else {
            mat[i][j] = c-'0';
          }
          debug(i, j, mat[i][j]);
        }
      }
      vector<vector<bool>> dp(h, vector<bool>(w));
      queue<Dice> que;
      que.emplace(1, 2, 3, 0, 0);
      dp[0][0] = true;

      while(!que.empty()) {
        auto d = que.front(); que.pop();
        debug(d.i, d.j, d.k, d.x, d.y);
        if (d.x > 0 && (!dp[d.x-1][d.y]) && mat[d.x-1][d.y] == 7-d.j) {
          dp[d.x-1][d.y] = true;
          que.emplace(d.j, 7-d.i, d.k, d.x-1, d.y);
        }
        if (d.x < h-1 && (!dp[d.x+1][d.y]) && mat[d.x+1][d.y] == d.j) {
          dp[d.x+1][d.y] = true;
          que.emplace(7-d.j, d.i, d.k, d.x+1, d.y);
        }
        if (d.y > 0 && (!dp[d.x][d.y-1]) && mat[d.x][d.y-1] == 7-d.k) {
          dp[d.x][d.y-1] = true;
          que.emplace(d.k, d.j, 7-d.i, d.x, d.y-1);
        }
        if (d.y < w-1 && (!dp[d.x][d.y+1]) && mat[d.x][d.y+1] == d.k) {
          debug(d.x, d.y);
          dp[d.x][d.y+1] = true;
          que.emplace(7-d.k, d.j, d.i, d.x, d.y+1);
        }
      }

      if (dp[h-1][w-1]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }

    }
};

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


Measured memory_bytes: 3280
#include <stdio.h>
 int main(void){    
 int N,M,i,j,A[1000],c,b[1000],max_count=0,max_game=-1;  
   scanf("%d%d",&N,&M);  
     for(i=0;i<N;i++){  
       scanf("%d",&A[i]);          
   b[i]=0;   
  }    
 for(j=0;j<M;j++){   
      scanf("%d",&c);   
      for(i=0;i<N;i++){     
        if(A[i]<=c){
	b[i]++;
	break;
}  
 
} 
    
}    
   for(i=0;i<N;i++){        
 if(max_count<b[i]){    
         max_count=b[i];     
        max_game=i;      
   }    
 }      
 printf("%d\n",max_game+1);
return 0;
 } 

Measured memory_bytes: 604
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))

#define equal equalll
#define less lesss
const int N = -1;
const long long INF = 1e9 + 19;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int n;

void read() {
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int y;
        cin >> y;
        sum = (sum + y) % 2;
    }
    if (sum == 0)
        puts("YES");
    else
        puts("NO");


}

void solve() {

}

void stress() {

}

int main(){
#ifdef HOME 
    freopen("in", "r", stdin);
#endif
    if (1) {
        read();
        solve();
    }
    else {
        stress();
    }

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>

const std::array<int32_t, 4> dx({-1, 0, 1, 0});
const std::array<int32_t, 4> dy({0, -1, 0, 1});

inline uint32_t id(const std::vector<int32_t>& coord, int32_t target) {
  return std::lower_bound(coord.begin(), coord.end(), target) - coord.begin();
}

int main() {
  uint32_t N = 0, M = 0;
  std::cin >> N >> M;
  std::vector<int32_t> A(N), B(N), C(N);
  for (size_t n = 0; n < N; n++) std::cin >> A[n] >> B[n] >> C[n];
  std::vector<int32_t> D(M), E(M), F(M);
  for (size_t m = 0; m < M; m++) std::cin >> D[m] >> E[m] >> F[m];

  // coordinate compression
  std::vector<int32_t> x_mesh(A);
  x_mesh.insert(x_mesh.end(), B.begin(), B.end());
  x_mesh.insert(x_mesh.end(), D.begin(), D.end());
  x_mesh.push_back(0);
  std::vector<int32_t> y_mesh(C);
  y_mesh.insert(y_mesh.end(), E.begin(), E.end());
  y_mesh.insert(y_mesh.end(), F.begin(), F.end());
  y_mesh.push_back(0);

  std::sort(x_mesh.begin(), x_mesh.end());
  std::sort(y_mesh.begin(), y_mesh.end());

  x_mesh.erase(std::unique(x_mesh.begin(), x_mesh.end()), x_mesh.end());
  y_mesh.erase(std::unique(y_mesh.begin(), y_mesh.end()), y_mesh.end());

  // gen grid
  std::vector<std::vector<int32_t>> grid(
      x_mesh.size() * 2, std::vector<int32_t>(y_mesh.size() * 2, 0));
  for (size_t n = 0; n < N; n++) {
    uint32_t A_id = id(x_mesh, A[n]), B_id = id(x_mesh, B[n]),
             C_id = id(y_mesh, C[n]);
    for (size_t i = A_id * 2; i <= B_id * 2; i++) grid[i][C_id * 2] = -1;
  }
  for (size_t m = 0; m < M; m++) {
    uint32_t D_id = id(x_mesh, D[m]), E_id = id(y_mesh, E[m]),
             F_id = id(y_mesh, F[m]);
    for (size_t i = E_id * 2; i <= F_id * 2; i++) grid[D_id * 2][i] = -1;
  }

  // bfs
  bool INF = false;
  uint64_t sum = 0;
  std::queue<std::pair<int32_t, int32_t>> Q;
  Q.push({id(x_mesh, 0) * 2, id(y_mesh, 0) * 2});
  while (!Q.empty()) {
    int32_t x = Q.front().first, y = Q.front().second;
    Q.pop();

    if (grid[x][y] != 0) continue;
    grid[x][y] = 1;

    // grid edge
    if (x == 0 || x == static_cast<int32_t>(grid.size()) - 1 || y == 0 ||
        y == static_cast<int32_t>(grid[0].size()) - 1) {
      INF = true;
      break;
    }

    // current area
    if (x % 2 && y % 2)
      sum += static_cast<uint64_t>(x_mesh[x / 2 + 1] - x_mesh[x / 2]) *
             static_cast<uint64_t>(y_mesh[y / 2 + 1] - y_mesh[y / 2]);

    // next area
    for (size_t i = 0; i < dx.size(); i++) Q.push({x + dx[i], y + dy[i]});
  }

  if (INF)
    std::cout << "INF" << std::endl;
  else
    std::cout << sum << std::endl;

  return 0;
}

Measured memory_bytes: 144156
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define pause system("pause")
#define all(x) x.begin(),x.end()
using namespace std;
main () {
	ios::sync_with_stdio(0);
	int a,b,n;
	cin>>a>>b>>n;
	int x=min(b-1,n);
	int answer=a*x/b-a*(x/b);
	cout<<answer<<endl;
	return 0;
}
/*
  _   _   _          _
 | \ | | (_)        | |
 |  \| |  _    ___  | | __  ___    ___    _ __     __ _
 | . ` | | |  / __| | |/ / / __|  / _ \  | '_ \   / _` |
 | |\  | | | | (__  |   <  \__ \ | (_) | | | | | | (_| |
 |_| \_| |_|  \___| |_|\_\ |___/  \___/  |_| |_|  \__,_|

*/




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

int main(){
    int n;
    string S;
    cin >> n >> S;
    int ans = 0;
    for(int i = 0; i < n-2; i++){
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


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

	long long n, i, j, k, maxx = 0, ans = 0, x;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		if (x < maxx) ans += maxx - x;
		else maxx = x;
	}
	cout << ans << "\n";

	return 0;
}



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

int main(){
    int n;
    cin >> n;
    //double start = clock();

    vector<vector<int>> a(n, vector<int>(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> a[i][j];
        }
    }

    vector<long long int> dp(vector<long long int>(1<<n));
    dp[0] = 1;
    for(int bit=1; bit<(1<<n); bit++){// set of matched females
        int i = -1;// matched upto i-th male
        for(int j=0; j<n; j++){
            if(((bit>>j) & 1) == 1) i += 1;
        }

        for(int j=0; j<n; j++){// j-th female
            if(((bit>>j) & 1) == 1 && a[i][j] == 1){// match with i-th male
                dp[bit] += dp[bit ^ (1<<j)];
                dp[bit] %= MOD;
            }
        }
    }
    cout << dp[(1<<n)-1] << endl;
    //cout << fixed << setprecision(10) << (clock() - start) / CLOCKS_PER_SEC << endl;
    return 0;
}

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

#define M 1000000
#define MAX_L 13
typedef long long ll;

char table[M][MAX_L];

int h1(ll);
int h2(ll);
int getNum(char);
ll getKey(char*);
void insert(char*);
int find(char*);
void init_table(void);

int main(){
  int N,i;
  char command[7],str[MAX_L];
  init_table();
  scanf("%d",&N);
  for(i = 0 ; i < N ; i++){
    scanf("%s%s",command,str);
    if(!strcmp(command,"insert")){
      insert(str);
    }else{
      printf("%s\n",(find(str) ? "yes" : "no"));
    }
  }
  return 0;
}

int h1(ll k){
  return k % M;
}

int h2(ll k){
  return 1 + k % (M-1);
}

int getNum(char ch){
  if(ch == 'A'){ return 1; }
  if(ch == 'C'){ return 2; }
  if(ch == 'G'){ return 3; }
  if(ch == 'T'){ return 4; }
  return -1;
}

ll getKey(char *str){
  ll res = 0,j;
  int i,len = strlen(str);
  for(i = 0, j = 1 ; i < len ; i++, j *= 5){
    res += getNum(str[i])*j;
  }
  return res;
}

void insert(char *str){
  ll k = getKey(str),cur = h1(k);
  int i;
  for(i = 0 ; i < M ; i++){
    if(table[cur][0] == '#' || !strcmp(str,table[cur])){
      strcpy(table[cur],str);
      break;
    }
    cur = (cur + h2(k)) % M;
  }
}

int find(char *str){
  ll k = getKey(str),cur = h1(k);
  int i;
  for(i = 0 ; i < M ; i++){
    if(table[cur][0] == '#'){
      return 0;
    }
    if(!strcmp(str,table[cur])){
      return 1;
    }
    cur = (cur + h2(k)) % M; 
  }
}

void init_table(){
  int i;
  for(i = 0 ; i < M ; i++){
    table[i][0] = '#';
  }
}

Measured memory_bytes: 13300
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long A, long long B){
    cout << (A * B - A - B + 1) << "\n";
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



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

int main(){
  int H,N;
  cin>>H>>N;
  int A[N];
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    ans+=A[i];
  }
  if(ans>=H){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>                          
using namespace std; 
string s;                                            
int main(){	
	getline(cin,s);
	reverse(s.begin(),s.end());
	for(int i=0;i<s.size();i++)
	{
    	if(i+6<=s.size()&&s.substr(i,7)=="remaerd") i+=6;	
	    else {if(i+4<=s.size()&&s.substr(i,5)=="maerd") i+=4;
		else {if(i+5<=s.size()&&s.substr(i,6)=="resare") i+=5;
		else {if(i+4<=s.size()&&s.substr(i,5)=="esare") i+=4;
		else {cout<<"NO";return 0;}
		}}}
	}
	cout<<"YES";
	return 0;
}     

Measured memory_bytes: 512
from collections import Counter

N = int(input())
plus = Counter([input() for _ in range(N)])
M = int(input())
minus = Counter([input() for _ in range(M)])

ans = 0
for k, v in dict(plus).items():
    if minus[k]:
        ans = max(ans, v - minus[k])
    else:
        ans = max(ans, v)

print(ans)


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

const int maxn=3005,mod=998244353;
int a[maxn];
long long dp[maxn][maxn][3];
int n,s;

int main()
{
	scanf("%d %d",&n,&s);
	for(int i=1; i<=n; ++i)
		scanf("%d",a+i);
	dp[0][0][0]=1;
	for(int i=1; i<=n; ++i) {
		for(int j=0; j<=s; ++j) {
			(dp[i][j][0]+=dp[i-1][j][0])%=mod;
			(dp[i][j][1]+=dp[i-1][j][0]+dp[i-1][j][1])%=mod;
			(dp[i][j][2]+=dp[i-1][j][0]+dp[i-1][j][1]+dp[i-1][j][2])%=mod;
			if(j+a[i]<=s) {
				(dp[i][j+a[i]][1]+=dp[i-1][j][0]+dp[i-1][j][1])%=mod;
				(dp[i][j+a[i]][2]+=dp[i-1][j][0]+dp[i-1][j][1])%=mod;
			}
		}
	}
	printf("%lld",dp[n][s][2]);
}

Measured memory_bytes: 211584
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/*int min(double *x,int n){
	int i,c=0;
	double ans;
	ans=100005;
	for(i=0; i<n; i++){
		if(ans>x[i]){
			ans=x[i];
			c=i;
		}
	}
	return c;
}*/
int main()
{
	int n,i,c=0;
	double h[1005],max,m=0.006,f,t,a,ans[1005];
	scanf("%d%lf%lf",&n,&t,&a);
	max=1000000.000;
	for(i=0; i<n; i++){
		scanf("%lf",&h[i]);
		f=(h[i]*m);
		f=t-f;
		ans[i]=abs(a-f);
		if(ans[i]<max){
			max=ans[i];
			c=i;
		}
		//printf("%lf\n",ans[i]);
	}
	printf("%d\n",c+1);
	return 0;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<string> grid(n);
    rep(i,0,n) cin >> grid[i];
    int ans=0;
    rep(io,0,n) {
        bool good=true;
        rep(i,0,n) {
            if(!good) break;
            rep(j,i,n) {
                if(grid[(i+io)%n][j]!=grid[(j+io)%n][i]) {
                    good=false;
                    break;
                }
            }
        }
        if(good) ans+=n;
    }
    cout<<ans<<"\n";
}


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

int main(){
  int i,j;
  int N;
  int KTK,mini;
  int count=0;
  int Alength;
  
  scanf("%d",&N);
  
  int A[N];
  
  Alength = sizeof(A)/sizeof(int);
  
  for(i=0;i<=Alength-1;i++){
    scanf(" %d",&A[i]);
  }

  A[Alength]='\0';

  for(i=0;i<=Alength-1;i++){
    mini=i;
    for(j=i;j<=Alength-1;j++){
      if(A[j]<A[mini]){
	mini=j;
      }
    }
      KTK=A[mini];
      A[mini]=A[i];
      A[i]=KTK;
      if(A[i]!=A[mini])count++;
  }

  for(i=0;i<Alength-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d",A[i]);
  printf("\n");
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2756
from sys import stdin
import numpy as np

N,M = map(int,stdin.readline().strip().split())
X = np.array(list(map(int,stdin.readline().strip().split())))
X.sort()
dX = np.diff(X,n=1)
dX.sort()

if N >= M:
    print(0)
else:
    print(dX[0:M-N].sum())


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int a,b; cin>>a>>b;
    int c = b-a-1;
    cout<<c*(c+1)/2-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
const int maxn = 1e5 + 10;
int A[maxn];
int num[maxn];
int main(void)
{
	int N, k;
	cin >> N >> k;
	for (int i = 1; i <= N; ++i)
		cin >> A[i];
	LL ans = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = i + 1; j <= N; ++j)
			if (A[j] < A[i])
				++num[i];
		ans += 1ll * num[i] * k % mod;
		for (int j = 1; j < i; ++j)
			if (A[j] < A[i])
				++num[i];
		ans += 1ll * (k - 1) * (k) / 2 % mod * num[i] % mod;
		ans %= mod;


	}

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

Measured memory_bytes: 256