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

public class Main{ 
	
	static class FastReader{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

		int nextInt() 
		{ 
			return Integer.parseInt(next()); 
		} 

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 
	}
  
	public static void main(String[] args) 
	{ 
		FastReader sc = new FastReader(); 
		char[] arr = sc.nextLine().toCharArray();
		int n = arr.length;
		int[] res = new int[n];
		int i=0;
		while(i<n){
			int r=0, ri=0, l=0, li=0;
			while(i<n && arr[i]=='R'){
				//System.out.println("1. "+i);
				r++;
				i++;
			}
			ri = i-1;
			li = i;

			while(i<n && arr[i]=='L'){
				//System.out.println("2. "+i);
				i++;
				l++;
			}
			
			res[ri] = (r+1)/2 + l/2;
			res[li] = r/2 + (l+1)/2;
		}
      
      	for(i=0;i<n;i++)
			System.out.print(res[i]+" "); 
	} 
} 


Measured memory_bytes: 43204
#w = "abcab"
n=input()
s = input()
counter = {}
for word in s:
    if word in counter:
        counter[word] += 1
    else:
        counter[word] = 1

seki = 1
for i in counter.values():
    seki *= i+1
print((seki-1)%(10**9+7))



Measured memory_bytes: 3188
#include <cstdio>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main(void) {
  int k, s;
  scanf("%d %d", &k, &s);

  int count = 0;

  for(int i = 0; i <= k; i++) {
    for(int j = i; j <= k; j++) {
      for(int l = j; l <= k; l++) {
	if(i + j + l == s) {
	  if( i == j && j == l) {
	    count++;
	  }
	  else if(i == j || j == l || l == i) {
	    count += 3;
	  }
	  else {
	    count += 6;
	  }
	}
      }
    }
  }
  printf("%d\n", count);
}

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

int main() {
	int n, s = 0, a;
	cin >> n;
	a = n;
	while (a != 0) {
		s += a % 10;
		a /= 10;
	}
	if (n%s == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int l = 0, r = s.size() - 1;
    int ans = 0;
    while (l < r)
    {
        if (s[l] == s[r])
        {
            l++;
            r--;
            continue;
        }
        else if (s[l] == 'x')
        {
            l++;
            ans++;
        }
        else if (s[r] == 'x')
        {
            r--;
            ans++;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A + B >= C) cout << B + C << endl;
    else cout << A + 2 * B + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[20005];
int main()
{
  int n,m;
  cin>>m>>n;
  memset(dp,0x3f3f3f3f,sizeof dp);
  dp[0]=0;
  while(n--){
    int w,v;
    cin>>w>>v;
    for(int i=w;i<=m+w-1;i++)
      dp[i]=min(dp[i-w]+v,dp[i]);
  }
  int minn=0x3f3f3f3f;
  for(int i=m;i<=20000;i++)
       minn=min(dp[i],minn);
  cout<<minn<<endl;
}


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

using namespace std;

int main()
{
    int n,i;
    cin>>n;int a[n];
    float p[n],sum=0.000000;
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++)p[i]=1/float(a[i]);
    cout<<fixed<<setprecision(6);
    for(i=0;i<n;i++)sum=sum+p[i];
    cout<<1/sum;
    return 0;
}

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

vector<int> weights, values;
vector<vector<long long int> > table;

int MAX = 101000;

long long int choose(int bond){

    int size = weights.size();

    table = vector<vector<long long int> >(size, vector<long long int>(MAX, 0));

    table[0][0] = 0;
    table[0][weights[0]] = values[0];  
    for(int i = 1; i < size; i++){

        for(int total = 0; total <= bond; total++){

            long long int choose = 0;
            if(total - weights[i] >= 0)
                choose = table[i-1][total - weights[i]] + values[i];
            long long int not_choose = table[i-1][total];

            table[i][total] = max(choose, not_choose);

        }
    }

    long long int max = 0;
    for(int total = 0; total <= bond; total++){
    //cout << "total[" << total << "]=" << table[size-1][total] << "\n";
        if(table[size-1][total] > max)
            max = table[size-1][total];
    }

    return max;
}

int main(){
    int n, w;
    cin >> n >> w;

    weights = vector<int>(n);
    values = vector<int>(n);

    for(int i = 0; i < n; i++)
        cin >> weights[i] >> values[i];

    long long int result = choose(w);

    cout << result << "\n"; 

    return 0;
}


Measured memory_bytes: 80256
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 998244353
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

int main()
{
    Minato_Namikaze
  
    
    char c;
    cin >> c;
    c++;
    cout << c;  

    return 0;
    
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    while (true) {
        int M, T, P, R;
        cin >> M >> T >> P >> R;
        if (!M)
            break;
        map<int, map<int, int>> penq;
        map<int, int> ttlpen;
        map<int, int> solved;
        rep(i, 0, R) {
            int m, t, p, r;
            cin >> m >> t >> p >> r;
            if (r != 0) {
                penq[t][p]++;
            } else {
                ttlpen[t] += m + penq[t][p] * 20;
                solved[t]++;
            }
        }
        vector<pair<pii, int>> ranks;
        rep(i, 1, T + 1) ranks.push_back({{-solved[i], ttlpen[i]}, -i});
        sort(all(ranks));
        rep(i, 0, ranks.size()) {
            cout << -ranks[i].second;
            if (i + 1 != ranks.size()) {
                cout << (ranks[i].first != ranks[i + 1].first ? ',' : '=');
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3276
#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__)
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
    ll n, m;
    cin >> n >> m;
    int time = 1900;
    ll p = 1;
    rep(i, m) p *= 2;
    ll ans = (1900 * m + 100 * (n-m)) * p;

    cout << ans << endl;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int ans = 1;
	for (int i = 1; i*i <= m; i++) {
		if (m%i != 0)continue;

		int j = m / i;

		if ((LL)i*n <= m) { ans = max(ans, i); }
		if ((LL)j*n <= m) { ans = max(ans, j); }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(void){
    int n;
    std::string s;
    std::cin >> n >> s;
    if(s.size() % 2 == 1){
	std::cout << "No" << std::endl;
	return 0;
    }else{
	int mid = s.size() / 2;
	for(int i = 0; i < mid; i++){
	    if(s[i] != s[i + mid]){
		std::cout << "No" << std::endl;
		return 0;
	    }
	}
    }
    std::cout << "Yes" << std::endl;
    
    return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1};
const int dy[]={0,1,-1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> Pii;
typedef pair<int,vi > P;
typedef long long ll;
int coin[25];
int N,M;

int memo[21][50001];

int solve(int idx,int money){
    //printf("%d %d\n",idx,money);
    
    if(memo[idx][money]){
        return memo[idx][money];
    }

    if(money == N){
        return 0;
    }
    if(idx == M){
        return INF;
    }


    int ret = INF;

    reps(i,idx,M){
        if(money + coin[i] > N)continue;
        ret = min(ret,solve(i,money+coin[i]) + 1);
    }

    return memo[idx][money] = ret;

}

int main(){
    scanf("%d%d",&N,&M);
    

    rep(i,M){
        scanf("%d",&coin[i]);
    }
    sort(coin,coin+M);

    printf("%d\n",solve(0,0));

    return 0;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    int x = stoi(a+b);
    int count = 0;
    for(int i = 1; i <= 1000; i++){
        if(i*i == x){
            count++;
        }
    }
    if(count == 0){
        cout << "No";
    } else {
        cout << "Yes";
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int N;
    scanf("%d",&N);
    if (N%10==7) printf("Yes");
    else if (N%100-N%10==70) printf("Yes");
    else if (N-N%100==700) printf("Yes");
    else printf("No");
    printf("\n");
    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,g,b,k;
    cin>>r>>g>>b>>k;
    while (k--)
    {
            if(r>=g)
                g*=2;
            else if(r>=b)
                b*=2;
            else if(g>=b)
                b*=2;
    }
    if (g>r && g<b && b>r) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    }

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,a,ans;
    cin>>h>>a;
    if(a>h)
        cout<<1<<endl;
    else
    {
        ans=h/a;
        if(h%a==0)
            cout<<ans<<endl;
        else
            cout<<ans+1<<endl;
    }

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        StringBuilder S = new StringBuilder();
        S.append("i");
        S.append(sc.next());
        long r =0,g=0,b=0;
        for(int i=1;i<=N;i++){
            if(S.charAt(i)=='R') r++;
            else if(S.charAt(i)=='G')g++;
            else if(S.charAt(i)=='B')b++;
        }
        long opt = r*g*b;
        for(int i=1;i<=N-1;i++){
            for(int j=i+1;j<=(N+i)/2;j++){
                int k = 2*j-i;
                if(S.charAt(i)!=S.charAt(j)&&S.charAt(j)!=S.charAt(k)&&S.charAt(i)!=S.charAt(k))opt--;
            }
        }
        if(opt>=0)System.out.println(opt);
        else System.out.println(0);
    }
}

Measured memory_bytes: 36268
from itertools import combinations

S = raw_input()
N = len(S)
cnt = 0

for a, b, c in combinations(range(1, N), 3):
    ok = True
    A = S[:a]
    B = S[a:b]
    C = S[b:c]
    D = S[c:]
    for x in [A, B, C, D]:
        y = int(x)
        if y > 255:
            ok = False
        if y == 0 and len(x) != 1:
            ok = False
        if y != 0 and x[0] == '0':
            ok = False
    cnt += ok

print cnt



Measured memory_bytes: 4728
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var odd = n / 2;
        var eve = n / 2;

        if (n % 2 == 1) odd++;

        return odd * eve;
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main(){
	long n;
	cin >> n;
	
	long temp = n;
	int sum = 0;
	while(temp > 0){
		sum += temp%10;
		temp /= 10;
	}
	if(n%sum == 0)
        cout << "Yes";
    else
        cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int D[100010], ans_e[200010], ans_v[100010], mx=1e9;
bool sast[100010];
pair<int, int> dd[100010];

void dfs(int key, vector<vector<int>> &g){
	for(int i=0; i<g[key].size(); ++i){
		if(ans_v[g[key][i]]==0){
			ans_v[g[key][i]]=3-ans_v[key];
			dfs(g[key][i], g);
		}
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	for(int i=1; i<=N; ++i){
		cin >> D[i];
		dd[i-1]=make_pair(D[i], i);
	}
	sort(dd, dd+N);
	vector<vector<pair<int, int>>> G(N+1);
	for(int i=0; i<M; ++i){
		int u, v;
		cin >> u >> v;
		G[u].emplace_back(make_pair(v, i));
		G[v].emplace_back(make_pair(u, i));
	}
	vector<vector<int>> h(N+1);
	for(int i=0; i<N; ++i){
		int s=dd[i].second;
		if(!sast[s]){
			bool flag=true;
			for(int t=0; t<G[s].size(); ++t){
				if(D[G[s][t].first]<=D[s]){
					ans_e[G[s][t].second]=D[s];
					h[s].emplace_back(G[s][t].first);
					h[G[s][t].first].emplace_back(s);
					sast[s]=sast[G[s][t].first]=1;
					flag=false;
					break;
				}
			}
			if(flag){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	for(int i=1; i<=N; ++i){
		if(ans_v[i]==0){
			ans_v[i]=1;
			dfs(i, h);
		}
	}
	for(int i=1; i<=N; ++i) cout << (ans_v[i]==1 ? 'B' : 'W');
	cout << endl;
	for(int i=0; i<M; ++i){
		if(ans_e[i]==0) cout << mx << endl;
		else cout << ans_e[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 18304
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n;
    cin >> n;
    for(int i = 1;i <= 9;i++){
        for(int j = 1;j <= 9;j++){
            if (n == i*j){
                cout << "Yes";
                exit(0);
            }
        }
    }
    cout << "No";
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
INF = 1<<31
from bisect import bisect_left

def main():
    N,Q = map(int,input().split())
    roadwork = [tuple(map(int,input().split())) for _ in range(N)]
    roadwork.sort(key = lambda x:x[2])
    D = [int(input()) for _ in range(Q)]
    ans = [-1] * Q
    skip = [-1] * Q
    for s,t,x in roadwork:
        L = bisect_left(D,s - x)
        R = bisect_left(D,t - x)
        while L < R:
            if skip[L] == -1:
                ans[L] = x
                skip[L] = R
                L += 1
            else:
                L = skip[L]
    print('\n'.join(map(str,ans)))
if __name__ == '__main__':
    main()

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

typedef long long ll;
ll x;
int main()
{
    cin >> x;
    if (x % 11 == 0) cout << x / 11 * 2 << endl;
    else if (x % 11 <= 5 + 1 - x / 11 % 2) cout << x / 11 * 2 + 1 << endl;
    else cout << x / 11 * 2 + 2 << endl;
    return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll n,W,val[105],wt[105],dp[105][100005];



int main(){
  cin >> n >> W;
  for(int i=0;i<n;++i){
    cin >> wt[i] >> val[i];
  }
  for(int i=0;i<=n;++i){
    for(int j=0;j<=W;++j){
        if(i==0 || j==0){
            dp[i][j]=0;
        }
        else if(wt[i-1]>j){
            dp[i][j]=dp[i-1][j];
        }
        else{
            dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
        }
    }
  }
  cout << dp[n][W];
  return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 100005;

int n, q, k, a[MAXN];
vector<pi> crd;

struct bit{
	int tree[MAXN];
	void add(int x, int v){
		while(x < MAXN){
			tree[x] += v;
			x += x & -x;
		}
	}
	int query(int x){
		int ret = 0;
		while(x){
			ret += tree[x];
			x -= x & -x;
		}
		return ret;
	}
}bit;

int sum = 0;

set<pi> s;

void rem_intv(pi s){
	int S = bit.query(s.second) - bit.query(s.first - 1);
	if(s.second - s.first + 1 >= k) sum -= min(S, s.second - s.first + 2 - k);
}

void add_intv(pi s){
	int S = bit.query(s.second) - bit.query(s.first - 1);
	if(s.second - s.first + 1 >= k) sum += min(S, s.second - s.first + 2 - k);
}

int main(){
	cin >> n >> k >> q;
	for(int i=0; i<n; i++){
		cin >> a[i];
		crd.emplace_back(a[i], i + 1);
	}
	sort(crd.rbegin(), crd.rend());
	int ret = 1e9;
	int e = 0;
	for(int i=0; i<crd.size(); i++){
		while(e < crd.size() && sum < q){
			bit.add(crd[e].second, 1);
			int st = crd[e].second, ed = crd[e].second;
			auto l = s.lower_bound(pi(crd[e].second, crd[e].second));
			if(l != s.end() && l->first == crd[e].second + 1){
				ed = l->second;
				rem_intv(*l);
				l = s.erase(l);
			}
			if(l != s.begin() && prev(l)->second == crd[e].second - 1){
				st = prev(l)->first;
				rem_intv(*prev(l));
				s.erase(prev(l));
			}
			add_intv(pi(st, ed));
			s.insert(pi(st, ed));
			e++;
		}
		if(sum >= q) ret = min(ret, crd[i].first - crd[e - 1].first);
		auto l = --s.upper_bound(pi(crd[i].second + 1, -1));
		rem_intv(*l);
		bit.add(crd[i].second, -1);
		add_intv(*l);
	}
	cout << ret << endl;
}


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

int main(){
	long long a,b,k;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
	    if(i%2==0){
	    	if(a%2)a--;
	    	b+=a/2,a-=a/2;
	    }
	    else{
	    	if(b%2)b--;
		    a+=b/2,b-=b/2;
	    }
		
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)

using namespace std;
int N,M,Q,a[50],b[50],c[50],d[50],i,j,ansNow=0;

int dfs(vector <int> v,int N,int ans){
	if(v.size() == N+1){
		ansNow = 0;
		myfor(i,Q)if(v[b[i]]-v[a[i]]==c[i])ansNow+=d[i];
		ans = max(ans,ansNow);
		return ans;
	}
	v.push_back(v.back());
	
	while(v.back() <= M){
		ans = dfs(v,N,ans);
		v.back()++;
	}
	return ans;
}

int main(){
	
	cin >> N >> M >> Q;
	myfor(i,Q)cin >> a[i]>> b[i] >> c[i] >> d[i];
	int num[10];
	int ans = dfs(vector<int>(1,1),N,0);
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <deque>
#include <string>
#include <algorithm>

class TDoublyLinkedList
{
	std::deque<int> Data;
	
	void InsertInput();
	void DeleteInput();
	void DeleteFirst();
	void DeleteEnd();
public:
	void Manupulate(int Command);
	void Output() const;
};

void TDoublyLinkedList::InsertInput()
{
	int Number = 0;
	std::cin >> Number;
	Data.push_front(Number);
}

void TDoublyLinkedList::DeleteInput()
{
	int Number = 0;
	std::cin >> Number;
	std::deque<int>::iterator It = std::find(Data.begin(),Data.end(),Number);
	if(It != Data.end())
	{
		Data.erase(It);
	}
}

void TDoublyLinkedList::DeleteFirst()
{
	Data.pop_front();
}
void TDoublyLinkedList::DeleteEnd()
{
	Data.pop_back();
}

void TDoublyLinkedList::Output()const
{
	for(unsigned int i=0;i<Data.size();i++)
	{
		std::cout << Data[i] << std::flush;
		if(i < Data.size() - 1)
		{
			std::cout << " " << std::flush;
		}else{
			std::cout << std::endl;
		}
	}
}

void TDoublyLinkedList::Manupulate(int Command)
{
	switch(Command)
	{
		case 0 : InsertInput();break;
		case 1 : DeleteInput();break;
		case 2 : DeleteFirst();break;
		case 3 : DeleteEnd();break;
	}
}

int CommandToIndex(std::string Command)
{
	if(Command == "insert") return 0;
	if(Command == "delete") return 1;
	if(Command == "deleteFirst") return 2;
	if(Command == "deleteLast") return 3;
	return -1;
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int Count = 0;
	std::cin >> Count;
	
	TDoublyLinkedList List;
	for(int i=0;i<Count;i++)
	{
		std::string Command;
		std::cin >> Command;
		List.Manupulate(CommandToIndex(Command));
	}
	List.Output();
	
	return 0;
}

Measured memory_bytes: 5320
#include <stdio.h>
int main(){
  int K, A, B;
  scanf("%d%d%d",&K,&A,&B);
  int bl = 0;
  for(int i=A; i<=B; i++){
    if((i%K)==0)bl++;
  }
  if(bl){
    printf("OK\n");
  }else{
    printf("NG\n");
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n,a,b,c,x;
	while(1){
		cin>>n>>a>>b>>c>>x;
		if(n+a+b+c+x==0) break;
		vi y(n);
		rep(i,0,n) cin>>y[i];
		int now=0,ans=-1;
		rep(i,0,10001){
			if(i) x=(a*x+b)%c;
			if(x==y[now]) now++;
			if(now==n){
				ans=i;
				break;
			}
		}
		o(ans);
	}
}

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 998244353;
const int MAXN = 2e5 + 5;


ll nc[MAXN], mc[MAXN], N, M, K, fac[MAXN];

ll POW(ll a, ll b) {
	if(b == 0) return 1;
	if(b == 1) return a;
	ll t = POW(a, b/2); t = (t * t) % MOD;
	if(b % 2) t = (t * a) % MOD;
	return t;
}

ll MOD_INV(ll x) {
	return POW(x, MOD-2);
}

ll ans;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> M >> K;
	nc[0] = mc[0] = fac[0] = 1;
	for(ll i=1; i<=N; i++) {
		nc[i] = (nc[i-1] * (N-i) % MOD) * MOD_INV(i) % MOD;
		fac[i] = (fac[i-1] * i) % MOD;
	}
	for(ll i=1; i<=M; i++) {
		mc[i] = (mc[i-1] * (M-i+1) % MOD) * MOD_INV(i);
	}

	for(ll i=N-K-1; i<=N-1; i++) {
		ans = (ans + (POW(M-1, i) * M % MOD) * nc[i] % MOD) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vli vector<li>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pi pair<int,int>
#define FOR(i,s,n) for(auto i=s;i<n;++i)
#define FORN(i,s,n) for(auto i=s;i<=n;++i)
#define FORR(i,s,n) for(auto i=s;i>=n;--i)
#define FORE(i,a) for(auto i : a)
#define mp make_pair
const int MOD = 1e9+7;

void solve() {
    int n;
    cin >> n;
    // cout << "mod : " << n%1000 << endl;
    if(n%1000==0) {
        cout << 0 << endl;
        return;
    }
    int res = 1000 - (n%1000);
    cout << res << endl;
}

int32_t main()
{
    hyperspeed
    int test=1;
    // cin >> test;
    while(test--) {
        solve();
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int maxn=2002;
vector<int>m[maxn];
int n,p;
int sum;
int vis[maxn];
void dfs(int cot,int num)
{
    if(num==n)
    {
        sum++;
        return;
    }
    for(int i=0;i<m[cot].size();i++)
    {
        if(vis[m[cot][i]]==0)
        {
            vis[m[cot][i]]=1;
            dfs(m[cot][i],num+1);
            vis[m[cot][i]]=0;
        }
    }
}
int main()
{
    cin>>n>>p;
    for(int i=1;i<=p;i++)
    {
        int v,u;
        cin>>v>>u;
        m[v].push_back(u);
        m[u].push_back(v);
    }
    sum=0;
    vis[1]=1;
    dfs(1,1);
    cout<<sum<<endl;
    return 0;
}


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

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

void main()
{
  string s; readV(s);

  auto c1 = s.length.iota.count!(i => s[i] != (i%2 ? '0' : '1'));
  auto c2 = s.length.iota.count!(i => s[i] != (i%2 ? '1' : '0'));
  writeln(min(c1, c2));
}


Measured memory_bytes: 2428
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>


using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;


map<string, int> mp;

int main() {
    int n;
    cin >> n;
    int a[10];
    int c = 0;
    rep(i, n) {
        cin >> a[i];
        c += a[i];
    }
    sort(a, a + n);
    c -= a[n - 1] / 2;
    cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int in()
{
	int re=0,f=1;char x=getchar();
	while(x<'0'||x>'9'){if(x=='-')f=-1;x=getchar();}
	while(x>='0'&&x<='9')re=re*10+x-48,x=getchar();
	return re*f;
}
void out(ll x)
{
	if(x<0)putchar('-'),x=-x;
	if(!x){putchar('0');return;}
	char z[21],ct=0;
	while(x){z[++ct]=x%10+48,x/=10;}
	while(ct){putchar(z[ct]);--ct;}
}
int n,m;
ll z[300010],sum[300010],f[300010],tmp[300010];
ll t[300010],s[300010],dpl[300010],dpr[300010];
ll hd,tl,q[300010],fl;
ll *dp;
double slop(int j,int k)
{
	return 1.0*((dp[j]+s[j])-(dp[k]+s[k]))/(j-k);
}
double slop(ll *dp,int j,int k)
{
	return 1.0*((dp[j]+s[j])-(dp[k]+s[k]))/(j-k);
}
ll calc(int j,int i)
{
	return dp[j]+1ll*(i-j)*(i-j+1)/2-(sum[i]-sum[j]);
}
ll calc(ll *dp,int j,int i)
{
	return dp[j]+1ll*(i-j)*(i-j+1)/2-(sum[i]-sum[j]);
}
void work(ll *_dp)
{
	dp=_dp;
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+t[i];
	for(int i=1;i<=n;++i)s[i]=sum[i]+z[i];
	dp[0]=0;tl=1;q[tl]=0;
	for(int i=1;i<=n;++i)
	{
		while(1<tl&&slop(q[tl-1],q[tl])<i)--tl;	
		dp[i]=max(dp[i-1],calc(q[tl],i));
		while(1<tl&&slop(q[tl-1],q[tl])<slop(q[tl],i))--tl;
		q[++tl]=i;
	}
}
void solve(int l,int r)
{
	if(l==r){f[l]=max(f[l],dpl[l-1]+dpr[l+1]+1-t[l]);return;}
	int mid=l+r-fl>>1;
	solve(l,mid);solve(mid+1,r);
	dp=tmp;
	hd=tl=1;q[tl]=0;
	for(int i=l-1;i<=mid;++i)
	{
		while(1<tl&&slop(dpl,q[tl-1],q[tl])<slop(dpl,q[tl],i))--tl;
		q[++tl]=i;
	}
	for(int i=mid+1;i<=r;++i)
	{
		while(1<tl&&slop(dpl,q[tl-1],q[tl])<i)--tl;
		dp[i]=calc(dpl,q[tl],i)+dpr[i+1];
	}
	for(int i=r;i>=mid+1;--i)
	{
		if(i!=r)dp[i]=max(dp[i],dp[i+1]);
		f[i]=max(f[i],dp[i]);
	}
}
int main()
{
//	freopen("score.in","r",stdin);
//	freopen("score.out","w",stdout);
	n=in();
	for(int i=1;i<=n;++i)t[i]=in(),z[i]=1ll*i*(i-1)/2,f[i]=-1e16;
	work(dpl);
	reverse(t+1,t+n+1);
	work(dpr);
	reverse(t+1,t+n+1);
	reverse(dpr+1,dpr+n+1);
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+t[i];
	for(int i=1;i<=n;++i)s[i]=sum[i]+z[i];
	solve(1,n);
	reverse(f+1,f+n+1);reverse(t+1,t+n+1);
	reverse(dpl+1,dpl+n+1);reverse(dpr+1,dpr+n+1);swap(dpl,dpr);
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+t[i];
	for(int i=1;i<=n;++i)s[i]=sum[i]+z[i];
	fl=1;solve(1,n);
	reverse(f+1,f+n+1);reverse(t+1,t+n+1);
	reverse(dpl+1,dpl+n+1);reverse(dpr+1,dpr+n+1);swap(dpl,dpr);
	m=in();
	while(m--)
	{
		int p=in(),x=in();
		out(max(dpl[p-1]+dpr[p+1],f[p]-x+t[p]));
		putchar(10);
	}
}

Measured memory_bytes: 21632
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    let mut count = 1;
    while count < b {
        count = count - 1 + a;
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n, t, e, x;
	cin >> n >> t >> e;
	for(int i = 0;i < n;i++){
		cin >> x;
		int k = t / x * x;
		if(abs(k - t) <= e || abs(k + x - t) <= e){
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1164
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

class Program {
    static void Main(string[] args) {
        var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).OrderBy(x => x).ToArray();
        Console.WriteLine(a[0] * a[1] * a[2] % 2 * a[0] * a[1]);
    }
}

Measured memory_bytes: 13396
use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let mut iter = buffer.split_whitespace();

    let w: i32 = iter.next().unwrap().parse().unwrap();
    let h: i32 = iter.next().unwrap().parse().unwrap();
    let x: i32 = iter.next().unwrap().parse().unwrap();
    let y: i32 = iter.next().unwrap().parse().unwrap();
    let r: i32 = iter.next().unwrap().parse().unwrap();

    let circle_bottom = y - r;
    let circle_top = y + r;
    let circle_left = x - r;
    let circle_right = x + r;

    if circle_bottom >= 0 && circle_top <= h && circle_left >= 0 && circle_right <= w {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5024
def main():
    s=input()
    dp=[0]*len(s)
    dp[0]=1
    for i,v in enumerate(s):
        if dp[i] == 0 or i+5 > len(s):
            continue
        s5 = s[i:i+5]
        if s5 == "dream" or s5 == "erase":
            if len(s) == i+5:
                break
            dp[i+5]=1
        if i+6 <= len(s) and s[i:i+6] == "eraser":
            if len(s) == i+6:
                break
            dp[i+6]=1
        if i+5 <= len(s) and s[i:i+7] == "dreamer":
            if len(s) == i+7:
                break
            dp[i+7]=1
    else:
        print("NO")
        return
    print("YES")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double R;
    cin >> R;
    cout << fixed << setprecision(15);
    cout << 2 * R * 3.14159265 << endl;
    return 0;
}

Measured memory_bytes: 3768
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():  
    N = int(input())
    flag1 = False
    flag2 = False
    left = 0
    left2 = []
    right = 0
    right2 = []
    for _ in range(N):
        s = input()
        stack = ['-']
        for t in s:
            if t == '(':
                stack.append(t)
            else:
                if stack[-1] == '(':
                    stack.pop()
                else:
                    stack.append(')')
        if len(stack) == 1:
            continue
        elif stack[1] == '(':
            flag1 = True
            left += len(stack) - 1
        elif len(stack) >= 3  and stack[1] == ')' and stack[-1] == '(':
            for i in range(len(stack)):
                if stack[i] == '(':
                    s = i
                    break
            left2.append(len(stack) - s)
            right2.append(s - 1)
        else:
            flag2 = True
            right += len(stack) - 1
    if (right == 0 and left == 0 and  sum(right2) == 0 and sum(left2) == 0):
        print('Yes')
    else:
        l = 0
        if len(left2) > 0:
            l = min(left2)
        r = 0
        if len(right2) > 0:
            r = min(right2)
        x = max(r,l)
        if flag1 and flag2 and (right + sum(right2) == left + sum(left2)) and (left >= x) and (right >= x):
            print('Yes')
        else:
            print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 98120
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int n, k;
lint a[100005];
lint l[100005], r[100005];

int main(){
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		l[i] = max(a[i], 0ll);
		r[i] = max(a[i], 0ll);
	}
	for(int i=1; i<=n; i++){
		a[i] += a[i-1];
		l[i] += l[i-1];
		r[n+1-i] += r[n+2-i];
	}
	lint ret = -1e18;
	for(int i=1; i+k-1<=n; i++){
		ret = max(ret, l[i-1] + r[i+k] + max(0ll, a[i+k-1] - a[i-1]));
	}
	cout << ret;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int n,m;
int s,t;
vector<vector<int>> v(100005);
int main(){
  /*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
    */
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		v[a].push_back(b);
	}
	cin>>s>>t;
	s--; t--;
	vector<int> v1;
	for(int i=0;i<n;i++){
		if(i==t) continue;
		for(auto x : v[i]){
			if(x==t){
				v1.push_back(i); break;
			}
		}
	}
	if(v1.size() ==0 ){
		cout<<"-1"; return 0;
	}
	int vis[n][3];
	int dp[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			dp[i][j]=INT_MAX;
			vis[i][j]=0;
		}
	}
	vis[s][0]=1;
	dp[s][0]=0;
	queue<int> q;
	q.push(s);
	int l=0;
	while(q.size()>0 && l<5000000){
		int g=q.front();
		//cout<<g<<endl;
		q.pop();
		for(auto x : v[g]){
			for(int j=0;j<3;j++){
				if(vis[g][j]==0) continue;
				dp[x][(j+1)%3]=min(dp[x][(j+1)%3],dp[g][j]+1);
				if(vis[x][(j+1)%3]==0){
					vis[x][(j+1)%3]=1;
					q.push(x);
					l++;
				}
			}
		}
	}
	/*
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}*/
	int ans=INT_MAX;
	for(auto x : v1){
		ans=min(ans,dp[x][2]);
	}
	if(ans==INT_MAX) cout<<"-1";
	else 
	cout<<(ans+1)/3;
}

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

using namespace std;

const int mod = 1e9 + 7;

const int64_t infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

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

  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  int64_t ans = 0;
  int64_t val = 10;
  while (N >= val) {
    ans += N / val;
    val *= 5;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

void solve()
{
	string s1, s2;
	cin >> s1 >> s2;

	int ans = 0;
	for (int i = 0; i < s1.length(); i++)
	{
		if (s1[i] != s2[i])
			ans++;
	}
	cout << ans << "\n";
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

void solve()
{
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	int sum = 0;
	for (int i = 0; i < k; i++)
		sum += arr[i];
	cout << sum;
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


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

using namespace std;
const int N = 1e5 + 3, MOD = 1e9 + 7;
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	int n, res = 1;
	scanf("%d", &n);
	for (int i = 1; i <= 3; ++i)
		res *= n;
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 256
K = int(input())

# 数列を漸化式と見て、順に余りを計算する
# 余りは循環するので、高々K項まで計算すれば、少なくとも1つの循環を抽出できるので十分
# あとは抽出した余りの列において、0が含まれるか、含まれる場合は何番目かを求める

i, a = 0, 0
l = []
for i in range(K):
  a = (10*a + 7) % K
  l.append(a)

j, ans = 0, -1
for j in range(K):
  if l[j] == 0:
    ans = j + 1
    break
    
print(ans)

Measured memory_bytes: 48344
object Main extends App {
  import scala.io.StdIn._
  val Array(a, b) = readLine().split(" ").map(_.toInt)
  var ans = 0
  var flag = true
  for(i <- (1 until 1010)){
    if(Math.floor(i.toDouble * 0.08) == a && Math.floor(i.toDouble * 0.1) == b && flag){
      ans = i
      flag = false
    }
  }
  println(if(flag) -1 else ans)
}

Measured memory_bytes: 54776
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>

const long INF = 1123456789012345678;

long ans;
std::string s;

int main(){
	long cnt = 0;
	std::cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
			cnt++;
		}else{
			ans = std::max(cnt, ans);
			cnt = 0;
		}
	}
	ans = std::max(cnt, ans);
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  srep(i,K,N) {
    if(A[i]>A[i-K]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;    

    ll x = c/b, y=a/d;
    if(c%b!=0) x+=1; 
    if(a%d!=0) y+=1;

    if(x<=y) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
    string s;
    cin >> s;
    
    long long b = 0, w = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') b++;
        else w++;
    }
    
    long long ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') ans += w;
        else w--;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n,k;
	 cin>>n>>k;

	 map<ll,ll>mp;

	 for(int i=0;i<k;i++)
	 {
	 	ll x;
	 	 cin>>x;

	 	 for(int j=0;j<x;j++)
	 	 {
	 	 	ll y;
	 	 	 cin>>y;
	 	 	 mp[y]++;
	 	 }
	 }
	 ll ans=0;
	 for(int i=1;i<=n;i++)
	 {
	 	if(mp[i]==0)
	 		ans++;
	 }
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;

namespace test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			string input;
			List<List<long>> outList = new List<List<long>> ();
			while ((input = Console.ReadLine()) != null) {
				string[] array = input.Split (' ');
				List<long> list = new List<long> ();
				foreach (string s in array) {
					list.Add (long.Parse(s));
				}

				outList.Add (Euclid(list));	
			}

			foreach (List<long> tmp in outList) {
				Console.WriteLine ("{0} {1}",tmp[0],tmp[1]);
			}

		}

		static List<long> Euclid(List<long> list){
			long a = list [0];
			long b = list [1];

			while (a!=b) {
				if (a > b) {
					a = a - b;
				} else {
					b = b - a;
				}
			}

			long lcd = Math.Abs(list [0] * list [1] / a);
			list [0] = a;
			list [1] = lcd;

			return list;
		}
	}
}

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

int main() {
    int a, b; cin >> a >> b;
    if (a < b) {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
    } else {
        for (int i = 0; i < a; i++) {
            cout << b;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define INF -10000000
using namespace std;

struct edge {
public:
  edge(){to=0; cost=INF;}
  edge(int to, int cost){
    this->to=to;
    this->cost=cost;
  }
  int to, cost;
};

bool dfs(int, vector<edge>*, vector<int>&);

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

  vector<int> entro(n+1, INF);
  vector<edge> graph[n+1];

  int l[m], r[m], d[m];

  for(int i=0; i<m; i++){
    cin >> l[i] >> r[i] >> d[i];
    edge e1(r[i], d[i]), e2(l[i], -d[i]);
    graph[l[i]].push_back(e1);
    graph[r[i]].push_back(e2);
  }

  for(int i=1; i<=n; i++){
    if(entro[i]==INF){
      entro[i]=0;

      if(!dfs(i, graph, entro)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}

bool dfs(int v, vector<edge>* graph, vector<int> &entro){
  for(int i=0; i<(int)graph[v].size(); i++){ //頂点vの周りの頂点についてdfs

    //もし訪問済みなら新しいエントロピーと一致するかをチェック
    if(entro[graph[v][i].to]!=INF){
      if(entro[graph[v][i].to]!=entro[v]+graph[v][i].cost)  return false; //もし一致しないなら不敵
      else continue; //一致するならこの頂点は訪問しなくて良い
    }

    //初訪問ならエントロピーを更新
    entro[graph[v][i].to]=entro[v]+graph[v][i].cost;

    //更新した先でまたdfs
    if(!dfs(graph[v][i].to, graph, entro)){
       return false;
    }
  }

  return true;
}


Measured memory_bytes: 14336