akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

 
public class Main {
	static final long MOD1=1000000007;
	static final long MOD2=998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int N=sc.nextInt();
		int[] p=sc.nextIntArray(N);
		int[] dp=new int[N+1];
		for (int i = 0; i < p.length; i++) {
			dp[p[i]]=dp[p[i]-1]+1;
		}
		int max=0;
		for (int i = 0; i < dp.length; i++) {
			max=Math.max(max, dp[i]);
		}
		System.out.println(N-max);
	}
		static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 35924
N, P = gets.chomp.split(" ").map(&:to_i)
S = gets.chomp

if P == 2 || P == 5
  count = 0
  (N - 1).downto(0) do |i|
    count += i + 1 if S[i].to_i % P == 0
  end
  puts count 
else
  mods = Array.new(P, 0)
  sum = 0
  bit = 1
  (N - 1).downto(0) do |i|
    sum += S[i].to_i * bit
    sum %= P
    mods[sum] += 1
    bit = bit * 10 % P
  end
  count = mods[0]
  for i in (0..P-1)
    count += mods[i] * (mods[i] - 1) / 2
  end
  puts count
  end

Measured memory_bytes: 2300
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
#include<stdio.h>

using namespace std;

int main(){
int64_t N;
 cin >> N;
 int64_t a[N];
 int64_t sum = 0;
 int i;
 int j;
 int64_t bi = 1;
 int mod = 1e9 +7;
 for(i=0;i<N;++i){
     cin >> a[i];
   }
 for(i=0;i<61;++i){
    int64_t count = 0;
  for(j=0;j<N;++j){
    count += (a[j] % 2);
    a[j] /= 2;}
    sum = (sum + (((count * (N - count))%mod) * bi)%mod) %mod;
   bi = (bi * 2) %mod;
   }
  cout << sum%mod  << endl; 
  return 0;
}

Measured memory_bytes: 2560
// https://atcoder.jp/contests/dp/tasks/dp_c

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

int main (int argc, char* argv[]) {
	long long n;
	cin >> n;

	vector<long long> prev_h(3);
	vector<long long> curr_h(3);
	for (long long i = 0; i < n; i++) {
		long long h1, h2, h3;
		cin >> h1 >> h2 >> h3;
		curr_h[0] = max(prev_h[1] + h1, prev_h[2] + h1);
		curr_h[1] = max(prev_h[0] + h2, prev_h[2] + h2);
		curr_h[2] = max(prev_h[0] + h3, prev_h[1] + h3);
		prev_h.swap(curr_h);
	}
	cout << *max_element(prev_h.begin(), prev_h.end()) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if(n == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  if(n < 4) {
    cout << "No" << endl;
    return 0;
  }
  vector<bool> dp(n + 1);
  dp[0] = true;
  dp[1] = dp[2] = dp[3] = dp[5] = dp[6] = false;
  dp[4] = true;
  for(int i=7;i<=n;i++) dp[i] = dp[i-4] || dp[i-7];
  cout << (dp[n] ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	
	cout << a[n - 1] << " ";
	
	int t = a[n - 1] / 2;
	int r = n - 2;
	int l = 0;
	int c = (l + r) / 2;
	while (l + 1 < r) {
		if (a[c] < t) {
			l = c;
		}
		else {
			r = c;
		}
		c = (l + r) / 2;
	}
	cout << (abs(a[n - 1] - a[l] * 2) > abs(a[n - 1] - a[l + 1] * 2) ? a[l + 1] : a[l]) << endl;

	return 0;
}

Measured memory_bytes: 640
/*input
20
*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define mp make_pair
#define F first
#define S second


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll x;
	cin>>x;
	ll n=1000000;
	ll a[1000000];
	init(a,n,0);
	rep(i,2,1000){
		if(!a[i])
			for(j=i*2;j<n;j+=i){
				a[j]=1;
			}
	}
	rep(i,x,1000000){
		if(!a[i]){
			cout<<i;
			return 0;
		}
	}

	return 0;
}




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

int32_t main(){__
	int a;
	string s;
	cin>>a>>s;
	if(a<3200){
		cout<<"red\n";
	}
	else{
		cout<<s<<"\n";
	}
return 0;
}

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

const int N = (1e5) + 5;
char s[N];

int main() { // claudio van
  scanf("%s", s);
  int n = strlen(s);
  int cnt0 = 0, cnt1 = 0;
  for (int i = 0; i < n; ++i) {
    cnt0 += (s[i] == '0');
    cnt1 += (s[i] == '1');
  }
  printf("%d\n", 2 * min(cnt0, cnt1));
  return 0;
}

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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.at(i) = a;
  }
  int maxdis = 0;
  for (int i = 1; i < N; i++) {
    if (A.at(i) - A.at(i - 1) > maxdis) {
      maxdis = A.at(i) - A.at(i - 1);
    }
  }
  if (K - (A.at(N - 1) - A.at(0)) > maxdis) {
    maxdis = K - (A.at(N - 1) - A.at(0));
  }
  cout << K - maxdis << endl;
}


Measured memory_bytes: 1152
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**9

X_dif = []
for i in range(N-1):
  X_dif.append(X[i+1]-X[i])

S = [0]
for i in range(N-1):
  S.append(S[i]+X_dif[i])

#print(X, X_dif, S)

def f(x, y):
  return min(abs(x), abs(y))

for i in range(N-K+1):
  #print(ans, S[i+K-1] - S[i] + f(X[i], X[i+K-1]))
  ans = min(ans, S[i+K-1] - S[i] + f(X[i], X[i+K-1]))

print(ans)

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt() * 2;
		int[] l = new int[n];
		for(int i=0;i<n;i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		int ans = 0;
		for(int i=0;i<n;i+=2) {
			ans += l[i];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 9940
#include<cstdio>
const int MAXN = 100;
const int MAXS = MAXN*MAXN;
struct edge{
	int to, num; edge *nxt;
}edges[MAXS + 5], *adj[MAXN + 5], *ecnt=&edges[0];
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->num = 0, p->nxt = adj[u], adj[u] = p;
//	printf("! %d %d\n", u, v);
}
int A[MAXN + 5][MAXN + 5];
int x[MAXS + 5], y[MAXS + 5], N, M, tot;
int vis[MAXN + 5], lnk[MAXN + 5], nw;
bool dfs(int x) {
	for(edge *p=adj[x];p;p=p->nxt)
		if( !p->num ) {
			if( !vis[p->to] ) {
				vis[p->to] = true;
				if( !lnk[p->to] || dfs(lnk[p->to]) ) {
					lnk[p->to] = x;
					return true;
				}
			}
		}
	return false;
}
int f[MAXS + 5];
int B[MAXN + 5][MAXN + 5], C[MAXN + 5][MAXN + 5];
int main() {
	scanf("%d%d", &N, &M);
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++) {
			scanf("%d", &A[i][j]);
			x[A[i][j]] = i, y[A[i][j]] = j;
		}
	tot = N*M;
	for(int i=1;i<=tot;i++)
		addedge(x[i], (i - 1) / M + 1);
	for(nw=1;nw<=M;nw++) {
		for(int i=1;i<=N;i++) lnk[i] = 0;
		for(int i=1;i<=N;i++) {
			for(int j=1;j<=N;j++)
				vis[j] = false;
			dfs(i);
		}
		for(int i=1;i<=N;i++) {
			for(edge *p=adj[i];p;p=p->nxt)
				if( !p->num ) {
					if( lnk[p->to] == i ) {
						p->num = nw;
						break;
					}
				}
		}
	}
	for(int i=1;i<=N*M;i++)
		B[x[i]][edges[i].num] = i;
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			printf("%d%c", B[i][j], (j == M) ? '\n' : ' ');
	for(int i=1;i<=N*M;i++)
		C[(i - 1) / M + 1][edges[i].num] = i;
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)
			printf("%d%c", C[i][j], (j == M) ? '\n' : ' ');
}

Measured memory_bytes: 640
N, K = map(int, input().split());
p = list(map(int, input().split()));
sum = 0;
max_sum = 0;
for i in range(K):
  sum += p[i]

max_sum = sum
for i in range(N-K):
  sum -= p[i]
  sum += p[i+K]
  max_sum= max(max_sum, sum)

print((max_sum+K) / 2)

Measured memory_bytes: 24812
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

vector<int> g[200000];
bool v[200000] = {};

void rec(int i)
{
    v[i] = true;
    for (int j = 0; j < g[i].size(); ++j)
        if (!v[g[i][j]])
            rec(g[i][j]);
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = 0; i < m; ++i)
        v[100000 + i] = true;

    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d", &k);

        for (int j = 0; j < k; ++j) {
            int l;
            scanf("%d", &l);
            l -= 1;
            g[i].push_back(100000 + l);
            g[100000 + l].push_back(i);
            v[100000 + l] = false;
        }
    }

    rec(0);

    bool ans = true;
    for (int i = 0; i < n; ++i)
        ans = ans && v[i];
    for (int i = 0; i < m; ++i)
        ans = ans && v[100000 + i];
    if (ans)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 8704
import sys

n = int(sys.stdin.readline().rstrip())
a = [0] + [int(x) for x in sys.stdin.readline().split()]
b = [0] + [int(x) for x in sys.stdin.readline().split()]

def main():
    for i in range(n):
        a[i+1] += a[i]
        b[i+1] += b[i]
    res = 0
    for i in range(1, n + 1):
        res = max(res, a[i] + b[n] - b[i-1])
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3064
N = int(input())
ans = 10**N - 9**N - 9**N + 8**N

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
"""
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
"""
a = ans%mod
print(a)


Measured memory_bytes: 11260
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
    
    string S, T;
    cin >> S >> T;
    int count = 0;
    rep(i,min(S.length(), T.length())) if (S[i] == T[i]) count++;

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;

int main()
{
    int n, m;
    cin >> n >> m;
    Graph G(n);

    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, n)
    {
        cout << G[i].size() << endl;
    }

    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  if ((N*A) >= B) {
    cout << B << endl;
  }
  
  else if ((N*A) < B) {
    cout << N*A << endl;
  }

}

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

    //# define int long

    using namespace std;


    int32_t main()
    {
      int n, mx = 0;
      cin >> n;

      map < string, int > mp;

      for ( int i = 0; i < n; i++ ) {
        string s;
        cin >> s;
        mp[s]++;
        mx = max( mx, mp[s] );
      }

      for ( auto i: mp ) {
        if ( i.second == mx ) {
          cout << i.first << '\n';
        }
      }
    }


Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    ll a[100005] = {}, f[100005] = {1}, g[100005] = {}, z = 0, y = 0;
    g[100000] = 716327852;
    for (int i = 1; i <= 100000; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 99999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (ll i = k - 1; i < n; i++) {
        z = (z + f[i] * g[k - 1] % mod * g[i - k + 1] % mod * (a[i] + mod)) % mod;
    }
    for (ll i = 0; i <= n - k; i++) {
        y = (y + f[n - i - 1] * g[k - 1] % mod * g[n - k - i] % mod * (a[i] + mod)) % mod;
    }
    z -= y;
    if (z < 0) z += mod;
    cout << z;
}


Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n, k; cin >> n >> k;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> X(n);
    vector<int> Y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        X[i] = x[i];
        Y[i] = y[i];
    }

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

    int ans = INF;
    for(int u = 0; u < n; u++){
        for(int d = u + 1; d < n; d++){
            for(int l = 0; l < n; l++){
                for(int r = l + 1; r < n; r++){
                    int lx = X[l];
                    int rx = X[r];
                    int dy = Y[d];
                    int uy = Y[u];
                    int cnt = 0;
                    for(int i = 0; i < n; i++){
                        if(lx <= x[i] && x[i] <= rx && uy <= y[i] && y[i] <= dy) cnt++;
                    }

                    //cout << lx << " " << rx << " " << dy << " " << uy << " " << cnt << endl;
                    if(cnt >= k) ans = min(ans, (rx - lx) * (dy - uy));
                }
            }
        }
    }

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

Measured memory_bytes: 256
//************************************JAI SAI RAM*************************************** 
// ED ROUND 85 DIV 2 PROBLEM D HARD TO THINK OF and hard TO IMPLEMENT .
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n";
#define pair pair<ll,ll> 
ll MAX=LLONG_MAX;
ll MIN=LLONG_MIN;
ll P=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t,x,a[5001],b[5001],c[5001],tt=0;
    cin>>n;
    string ss;
    cin>>ss;
    a[n]=0;
    b[n]=0;
    c[n]=0;
    for(i=n-1;i>=0;i--)
    {
        a[i]=a[i+1];
        b[i]=b[i+1];
        c[i]=c[i+1];
        if(ss[i]=='R')
        {
         a[i]++;
        }
        else if(ss[i]=='G')
        b[i]++;
        else 
        c[i]++;
    }
    s=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
             if(ss[i]=='R'&&ss[j]=='G')
             {
                 k=(j+(j-i));
                 s+=c[j+1];
                 if(k<=n-1&&ss[k]=='B'&&k<=n-1)
                 s--;
             }
             else if(ss[i]=='R'&&ss[j]=='B')
             {
                 k=(j+(j-i));
                 s+=b[j+1];
                 if(k<=n-1&&ss[k]=='G')
                 s--;
             }
             else if(ss[i]=='G'&&ss[j]=='R')
             {
                 k=(j+(j-i));
                 s+=c[j+1];
                 if(k<=n-1&&ss[k]=='B'&&k<=n-1)
                 s--;
             }
             else if(ss[i]=='B'&&ss[j]=='R')
             {
                 k=(j+(j-i));
                 s+=b[j+1];
                 if(k<=n-1&&ss[k]=='G'&&k<=n-1)
                 s--;
             }
             else if(ss[i]=='G'&&ss[j]=='B')
             {
                 k=(j+(j-i));
                 s+=a[j+1];
                 if(k<=n-1&&ss[k]=='R'&&k<=n-1)
                 s--;
             }
             else if(ss[i]=='B'&&ss[j]=='G')
             {
                 k=(j+(j-i));
                 s+=a[j+1];
                 if(k<=n-1&&ss[k]=='R'&&k<=n-1)
                 s--;
             } 
        }
    }
    cout<<s<<endl;
    return 0;
}  
    


Measured memory_bytes: 3716
#include<iostream>
using namespace std;
long long gcd(long long a,long long b)
{
	if (!b) return a;
	return gcd(b,a%b);
}
long long n,pr,c;
int main()
{
	cin>>n>>pr;
	for (int i=1;i<n;i++)
	{
		cin>>c;
		pr=pr/gcd(pr,c)*c;
	}
	cout<<pr<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
#define INF (ll)(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;}

int main(){
	ll n;cin>>n;
	printf("ABC%d",n);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int c[100],v[100],d=0;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>c[i];
  for(int i=0;i<n;i++)
    cin>>v[i];
  for(int i=0;i<n;i++)
    if(c[i]-v[i]>0) d+=c[i]-v[i];
  cout<<d<<endl;
}

Measured memory_bytes: 256
N,X=map(int,input().split())
xs = list(map(int,input().split()))

def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return(x)
    

xs[0] -= X
g = xs[0]
import math
for i in range(1,N):
    xs[i] -= X
    g = gcd(g,xs[i])
print(abs(g))

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define int long long

signed main(){
	int N; cin >> N;
	vector<int> a(N), b(N), c(N);
	for(int i = 0; i < N; i++) cin >> a[i];
	for(int i = 0; i < N; i++) cin >> b[i];
	for(int i = 0; i < N; i++) cin >> c[i];
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	int ans = 0;
	for(int i = 0; i < N; i++){
		int ida, idc;
		idc = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
		ida = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		ans += ida * (N - idc);
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll N;
  cin>>N;
  vector<ll> A(N);
  map<ll,ll> cnt,sum;
  ll tot=0;
  rep(i,N){
  	cin>>A[i];
  	cnt[A[i]]++;
  }
  for(P c : cnt){
  	sum[c.fi]+=c.se*(c.se-1)/2;
  	tot+=c.se*(c.se-1)/2;
  }

  rep(i,N){
  	ll crt=(cnt[A[i]]-1)*(cnt[A[i]]-2)/2;
  	ll crtt=tot+crt-sum[A[i]];
  	cout<<crtt<<"\n";
  }

  return 0;
}


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

using namespace std;

bool f[10];

bool ok(int n){
    while(n != 0){
        if(f[n % 10])
            return false;
        n /= 10;
    }
    return true;
}

int main(){
    int n, k, i, x, j;

    cin >> n >> k;
    while(k--){
        cin >> x;
        f[x] = true;
    }

    while(!ok(n))
        n++;

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 105
string s;
int n;

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

    cin >> s;
    int n=s.length();
    F0R(i, n){
        if(s[i] != s[n-i-1]){
            cout << "No\n";
            return 0;
        }
    }
    int half = (n-1)/2;
    F0R(i, half){
        if(s[i] != s[half-i-1]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    vector<vector<int> > is(26);
    rep(i,n) is[s[i] - 'a'].push_back(i); // ascii同士の引き算
    rep(i,n) is[s[i] - 'a'].push_back(i+n);
    ll ans = 0;
    int p = 0;
    rep(i,m) {
        int c = t[i] - 'a';
        if ( sz(is[c]) == 0 ){
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if(p >= n) {
            if(p >= n) {
                p -= n;
                ans += n;
            }
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
 
int main()
{
    vector<int> S;
    int n, m, t;
    cin >> n;

    REP(i, n){
        cin >> t;
        S.emplace_back(t);
    }

    cin >> m;
    int ans=0;
    REP(i, m){
        cin >> t;
        if(binary_search(ALL(S), t)) ans++;
    }
    
    print(ans);
    return 0;
}


Measured memory_bytes: 3404
//AtCoder C - Sugar Water
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    ll amax=F/(100*A);
    ll bmax=F/(100*B);
    double den_max=-1.0;
    ll ans_t=0,ans_s=0;
    for(ll a=0;a<=amax;++a){
		for(ll b = 0; b <= bmax; ++b) {
            ll sug_max=(A*a+B*b)*E;
            ll cmax=sug_max/C;
            for(ll c=0;c<=cmax;++c){
                ll dmax=(sug_max-c*C)/D;
                for (ll d=0;d<=dmax;++d){
                    ll sug = C*c + D*d;
                    ll wat = A*a+B*b;
                    ll ttl = 100*wat+sug;   
                    if (wat<=0) continue;
                    if (sug > sug_max) continue;
                    if (ttl > F) continue;
                    double den=(double)sug/(double)(A*a+B*b);
                    if (den>den_max) {
                        ans_t=ttl;
                        ans_s=sug;
						den_max = den;
					}
                }
            }
		}
	}
    cout<<ans_t<<" "<<ans_s<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define inf 0x7fffffff/2
#define rd read()
using namespace std;
inline int read()
{  
    int s=0,w=1;  
    char ch=getchar();  
    while(ch<='0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}  
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();  
    return s*w;  
}  
int gcd(int a,int b)
{
    if(b==0)return a;
	else return gcd(b,a%b);	
} 
int main()
{
	int n,x,a,ans;
    n=rd;x=rd;a=rd;a=abs(x-a); 
    if(n==1)printf("%d",a),exit(0);
	ans=a;a=rd;a=abs(x-a);ans=gcd(ans,a);
	if(n==2)printf("%d",ans),exit(0);
	for(register int i=3;i<=n;i++)
	    a=rd,ans=gcd(ans,abs(x-a));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int dp[110][10100];

int main(){
    int N,W;
    cin >> N >> W;
    vector<int> v(N),w(N);
    rep(i,N)cin >> v[i] >> w[i];
    //dp[i][j]:=i番目の品物まで見て、総和がjを超えないよう選んだときの価値の最大値
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7020
#include <stdio.h>
 
int main(int argc, const char * argv[]) {
     
    while (1) {
        int h,w;
     
        scanf("%d %d",&h,&w);
     
        if(h==0 && w==0){
            break;
        }
         
        int i,j;
        for (i=0; i<h; i++) {
            for(j=0;j<w;j++){
                if((i+j) % 2 == 1){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
            printf("\n");
        }
         
        printf("\n");
    }
    return 0;
}

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

using namespace std;
typedef long long LL;

int main(){
  int K;
  cin >> K;
  queue<LL> q;
  rep(i,9) q.emplace(i+1);
  vector<LL> ans;
  rep(i,K){
    LL j=q.front(); q.pop();
    ans.emplace_back(j);
    if(j%10!=0) q.emplace(10*j+j%10-1);
    q.emplace(10*j+j%10);
    if(j%10!=9) q.emplace(10*j+j%10+1);
  }
  cout << ans[K-1] << endl;
  
  return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define DEKAI 1000000007
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */

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

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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> sum(n);
    sum[0] = a[0];
    for(int i=1;i<n;i++) {
        sum[i] = sum[i-1] + a[i];
        //cout << sum[i] << endl;
    }
    ll ans = n;
    for(int i=n-2;i>=0;i--) {
        if(sum[i] * 2 >= a[i+1]) continue;
        else {
            ans = n - i - 1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll ans;
string s;

int main() {
    fast_io; cout_precision;
    cin >> s;
    ans = 0;
    for (ll i = 0, p_cnt = 0; i < (ll) s.length(); i++) {
        p_cnt++;
        if (s[i] == 'g') {
            ans++;
        }
        if (2 * p_cnt > i + 1) {
            p_cnt--;
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    i64 d, a;
    cin >> d >> a;
    vector<pair<i64, i64>> mon_s(n);
    rep(i, n)
    {
        i64 x, h;
        cin >> x >> h;
        mon_s[i] = {x, h};
    }
    sort(mon_s.begin(), mon_s.end());

    vector<i64> x_s(n);
    vector<i64> diff(n);
    i64 cur = mon_s[0].second;
    rep(i, n)
    {
        x_s[i] = mon_s[i].first;
    }
    rep(i, n - 1)
    {
        diff[i] = mon_s[i + 1].second - mon_s[i].second;
    }

    i64 ans = 0;
    rep(i, n)
    {
        if (cur <= 0)
        {
            cur += diff[i];
            continue;
        }
        i64 bomb = (cur + a - 1) / a;
        i64 y = bomb * a;
        ans += bomb;
        cur -= y;
        int j = upper_bound(x_s.begin() + i + 1, x_s.end(), x_s[i] + 2 * d) - x_s.begin();
        diff[j - 1] += y;
        cur += diff[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9536
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int gcd(int a, int b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

int main() {
    int N;
    scanf("%d", &N);
    vector<int> A;
    rep(i, N) {
        int j;
        scanf("%d", &j);
        A.pb(j);
    }
    /* ====================================== */
    int ans;
    rep(i, N - 1) {
        if (i == 0) {
            ans = gcd(A[0], A[1]);
        } else {
            ans = gcd(ans, A[i + 1]);
        }
    }

    cout << ans;
    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		//宣言文
		//標準入力オブジェクトを生成
		Scanner sc = new Scanner(System.in);
		//標準入力で以下の変数を初期化
		int number = sc.nextInt();
		int[] numArray = new int[number];
		for(int i = 0; i < numArray.length; ++i) {
			numArray[i] = sc.nextInt();
		}
		//カウント変数
		int countNum = 0;
		boolean flagNum = true;
		
		do {
			for(int i = 0; i < numArray.length; i++) {
				//全て偶数か判定
				if(!(numArray[i]%2 == 0)){
					flagNum = false;
					break;
				}
				//割る２する処理を流す。
				numArray[i] = numArray[i] / 2;
			}
			//全体の処理をカウント
			if(flagNum) {
				countNum++;
			}
		}while(flagNum);//全て偶数なら繰り返す
			//標準出力
			System.out.print(countNum);
	}
}


Measured memory_bytes: 22868
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int k,n;cin>>k>>n;
    vector<int> a(n);
    rep(i, n) {
        cin>>a[i];
    }
    dump(a);

    int md = k+a[0] - a[n-1];
    rep(i, n-1){
        chmax(md, a[i+1]-a[i]);
    }
    cout << k-md << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
class Main{
	public static void main(String[] a){
		Scanner in = new Scanner(System.in);
		List<Character> dict = new ArrayList<Character>();
		for(char c : "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz".toCharArray()) {
			dict.add(c);
		}
		while(in.hasNext()) {
			char[] line = in.nextLine().toCharArray();
			char[] tmp = new char[line.length];
			int l = dict.size();
			int x  = 0;
			while(l-->0) {
				for(int i = 0; i < line.length; i++) {
					if('.' == line[i] || ' ' == line[i]) {
						tmp[i] = line[i];
						continue;
					}
					int index = dict.indexOf(line[i]);
					index+=x;
					tmp[i] = dict.get(index);
				}
				String ans = new String(tmp);
				if(ans.contains("this")||ans.contains("that")||ans.contains("the")) {
					System.out.println(ans);
					break;
				}
				x++;
			}
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    vector<int> alpha(26);
    string s;
    cin >> s;
    rep(i, s.length()){
        alpha[(int)s[i]-97]++;
    }
    rep(i,26){
        if(alpha[i] > 1){
            cout << "no" << endl;
            return 0; 
        }
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  char a;
  cin >> a;
  if (a >= 'a' && a <= 'z') {
    cout << 'a' << endl;
    return 0;
  }
  cout << 'A' << endl;
  return 0;
}

Measured memory_bytes: 3060
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    d = a % b
    if d == 0:
        return b
    return gcd(b, d)

def main():
    K = int(input())
    table = [[0]*K for i in range(K)]
    for i in range(K):
        for j in range(K):
            table[i][j] = gcd(i + 1, j + 1)
    ans = 0
    for i in range(K):
        for j in range(K):
            for k in range(K):
                ans += table[i][table[j][k]-1]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9484
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x;
    cin>>x;
    if(x<600){
        cout<<8<<endl;
    }
    else if(x<800){
        cout<<7<<endl;
    }
    else if(x<1000){
        cout<<6<<endl;
    }
    else if(x<1200){
        cout<<5<<endl;

    }
    else if(x<1400){
        cout<<4<<endl;
    }
    else if(x<1600){
        cout<<3<<endl;
    }
    else if(x<1800){
        cout<<2<<endl;
    }
    else if(x<2000){
        cout<<1<<endl;
    }
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

ll arr[3030];
pll dp[3003][3003][2];

void func(int l, int r, int turn)
{
	if(dp[l][r][turn].ff!=-1 && dp[l][r][turn].ss!=-1) return;
	dp[l][r][turn].ff=dp[l][r][turn].ss=0;
	if(l==r)
	{
		if(turn==0) dp[l][r][turn].ff=arr[l];
		else dp[l][r][turn].ss=arr[l];
		return;
	}
	func(l+1, r, 1-turn);
	func(l, r-1, 1-turn);
	if(turn==0)
	{
		pll temp1=dp[l+1][r][1-turn];
		temp1.ff+=arr[l];
		pll temp2=dp[l][r-1][1-turn];
		temp2.ff+=arr[r];
		if(temp1.ff-temp1.ss > temp2.ff-temp2.ss) dp[l][r][turn]=temp1;
		else dp[l][r][turn]=temp2;
	}
	else
	{
		pll temp1=dp[l+1][r][1-turn];
		temp1.ss+=arr[l];
		pll temp2=dp[l][r-1][1-turn];
		temp2.ss+=arr[r];
		if(temp1.ff-temp1.ss > temp2.ff-temp2.ss) dp[l][r][turn]=temp2;
		else dp[l][r][turn]=temp1;
	}
}

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		int n; cin >> n;
		for(int i=0;i<n;i++) cin >> arr[i];
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<=n;j++)
			{
				for(int k=0;k<2;k++)
				{
					dp[i][j][k].ff=dp[i][j][k].ss=-1;
				}
			}
		}
		func(0,n-1,0);
		cout << dp[0][n-1][0].ff-dp[0][n-1][0].ss << "\n";
	}
	return 0;
}


Measured memory_bytes: 282240
#include <bits/stdc++.h>
#define def define;
#define optimizator ios_base::sync_with_stdio(0);
#define starter int n;cin>>n;int a[n],b[n],c[n];for(int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];
using namespace std;
int main(){
	optimizator;
	int a;
	cin>>a;
	for(int i=1; i<=9; i++){
		for(int j=1; j<=9; j++){
			if(i*j==a){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}

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

int N, A[100000], B[100000], C[100000], Q, K, X[100000], Y[100000];

vector< vector< pair<int, int> > > G(100001);
vector<int64_t> dist(100001);

void dfs(int node){
    for(int i=0;i<G[node].size();i++){
        int nextNode = G[node][i].first;
        int nextCost = G[node][i].second;
        if(dist[nextNode] == -1){
            dist[nextNode] = dist[node] + nextCost;
            dfs(nextNode);
        }
    }
}

int main(){
    cin >> N;
    for(int i=0;i<N-1;i++)  cin >> A[i] >> B[i] >> C[i];
    cin >> Q >> K;
    for(int i=0;i<Q;i++)    cin >> X[i] >> Y[i];

    for(int i=0;i<N-1;i++){
        G[ A[i] ].push_back( make_pair(B[i], C[i]) );
        G[ B[i] ].push_back( make_pair(A[i], C[i]) );
    }

    for(int i=1;i<=N;i++)   dist[i] = -1;
    dist[K] = 0;
    dfs(K);

    for(int i=0;i<Q;i++)    cout << dist[ X[i] ] + dist[ Y[i] ] << endl;
}

Measured memory_bytes: 13184
#include<iostream>

int main(){
int n;
 std::cin >> n;
 int a[n+1];
 for(int i=1;i<=n;i++)
     std::cin >> a[i];
 bool f=0;
 int t=0;
 int i=1;
 while(t!=n){
    if(a[i]==2){
          t++;
          f=1;
          break;
    }
    else{
     i=a[i];
    }
    t++;
 }
 f==1?std::cout << t : std::cout << "-1";
 return 0;
}


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

int main()
{
    int N;

    cin >> N;

    vector<int> count(4, 0);

    for (int i = 0; i < N; i++)
    {
        string r;

        cin >> r;

        if (r == "AC")
            count.at(0)++;
        else if (r == "WA")
            count.at(1)++;
        else if (r == "TLE")
            count.at(2)++;
        else
            count.at(3)++;
    }

    cout << "AC x " << count.at(0) << endl;
    cout << "WA x " << count.at(1) << endl;
    cout << "TLE x " << count.at(2) << endl;
    cout << "RE x " << count.at(3) << endl;
}


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

int main(){
  string g; cin >> g;
  int count =0;
  bool flag = false;
  sort(g.rbegin(),g.rend());
  for(int i = 0; i < g.size();i++){
    if(g[i] == g[i+1]){
      count++;
    }
    else{
      if(count %2 == 0){
        flag =true;
      }
      count = 0;
    }
  }
  if(flag)
  cout << "No" << endl;
  else
  {
    cout << "Yes" << endl;
  }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    double p = 1;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        p = p*a[i];
    }
    double d = 0;
    for(int i=0;i<n;i++)
    {
        d = d + (p/a[i]);
    }
    double ans = p/d;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

int main(void) {
    int N;
    cin >> N;

    map<string, int> hash;
    rep(i, N) {
        string S;
        cin >> S;

        hash[S]++;
    }

    vector<pair<int, string>> vecp;
    for(auto kv : hash) {
        vecp.push_back(make_pair(kv.second, kv.first));
    }

    sort(RALL(vecp));

    priority_queue<string, vector<string>, greater<string>> pq;
    int max_num = vecp[0].first;
    for(int i = 0; i < N; i++) {
        if(vecp[i].first != max_num) {
            break;
        }

        pq.push(vecp[i].second);
    }

    // output ans
    while(!pq.empty()) {
        cout << pq.top() << endl;
        pq.pop();
    }
    return 0;
}

Measured memory_bytes: 32876