akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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() {
  uint64_t N;
  cin >> N;
  if(N % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  
  // 2で割れる回数
  uint64_t tmpN = N;
  uint64_t two = 0;
  while(0 != N){
    N /= 2;
    two += N;
  }

  // 5で割れる回数
  N = tmpN / 2;
  uint64_t five = 0;
  while(0 != N){
    N /= 5;
    five += N;
  }

  uint64_t ans = min(two, five);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (){
    int n, k;
    
    cin >> n >> k;
    
    if(k == 1){ 
        cout << 0 << endl;
        return 0;
    }
    
    if (n - k <= 1){
        if (n - k == 0){
            cout << 0 << endl;
        } else {
            cout << 1 << endl;
        }
    } else {
        cout << n - k << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	double n, m;
    double a;
	cin >> n >> m;
      a = pow(2,m);
	cout << ((n - m) * 100 + (1900 * m))*a<< endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
set<string> st;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        string s;
        cin>> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}

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

int modpower(int x,int n,int m){
    long long result=x;
    long long ans=1;
    int ans_int;

    while (n!=0){
        if(n%2==0){

            result = ((result%m)*(result%m))%m;
            n >>= 1;

        }else{
            ans = ((ans%m) * (result%m))%m;
            --n;

        }
    }
    ans_int=ans%m;
    return ans_int;
}

int modmul(int p,int q,int m){
    long long ans,pp=p,qq=q;
    int ans_int;
    ans=((pp%m)*(qq%m))%m;
    ans_int=ans%m;
    return ans_int;
}


int main(){
    long long ans=1;
    int mod=1000000007;
    int n;
    string s;
    map<char,int> m;
    cin >>n>>s;

    for (int i = 0; i < n; i++){
        m[s[i]]++;
    }
    

    for(auto p:m){
        ans = modmul(ans,p.second+1,mod);
    }
    ans = (ans-1)%mod;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define MOD 1
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ;

    ll n;
    cin >> n;
    ll arr[n];
    ll i;
    for(i=0;i<n;i++)
    {

        cin >> arr[i];
    }
    sort(arr,arr+n);
    //ll i;
    ll x= arr[n/2];
    ll y = arr[(n-2)/2];
    if(x==y)
    {

        cout << 0 << endl;
    }
    else
    {

        cout << x-y << endl;

    }




    return 0;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll H, N;
ll A[1010];
ll B[1010];
ll dp[20010];
ll maxA;
ll ans;
int main(){
	cin >> H >> N;
	REP(i,0,N){
		cin >> A[i] >> B[i];
		maxA = max(maxA, A[i]);
	}
	REP(i,1,20010){
		dp[i] = inf;
	}
	REP(i,0,N){
		REP(h, 0, H+maxA+1){
			if(h+A[i]<=H+maxA) {
				dp[h+A[i]] = min(dp[h+A[i]], dp[h]+B[i]);
			}
			else break;
		}
	}
	ans = inf;
	REP(h, H, H+maxA+1){
		ans = min (dp[h], ans);
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iostream>
#include <list>
#include <functional>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
typedef long long ll;
const ll mll = 9223372036854775807;
const int mint = (2 << 31) - 1;
using namespace std;

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	vector<int> v;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	sort(v.begin(), v.end());
	printf("%d\n", v[2] - v[0]);
}

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

int W, a, b, dis;
int main() {
    cin >> W >> a >> b;
    if (a > b)
    {
        dis = a - (W + b);
    } else 
    {
        dis = b - (W + a);
    }
    if (dis <= 0)
    {
        cout << 0 << endl;
    } else
    {
        cout << dis << endl;
    }
    
    
    
    cin.get();
    return 0;
}

Measured memory_bytes: 256
s = list(input())

if(s[0] == s[1] == s[2] == "R"):
    ans = 3
elif(s[0] == s[1] == "R" or s[2] == s[1] == "R"):
    ans = 2
elif(s[0] == s[1] == s[2] == "S"):
    ans = 0
else:
    ans = 1

print(ans)



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int H,A;
  cin>>H>>A;
  cout<<(H+A-1)/A<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

struct query {
  string name;
  int length;
  int year;
};

main()
{
  int N, Q;
  query q[1001];
  
  while( cin >> N >> Q, !(N == 0 && Q == 0) ) {
   
    Rep(i, N) {
      string s;
      int l, y;
      cin >> s >> l >> y;
      q[i] = (query){ s, l, y };
    }

    Rep(i, Q) {
      int y;
      cin >> y;

      bool flag = false;
      Rep(i, N) {
	if( q[i].year - q[i].length < y && y - (q[i].year - q[i].length) <= q[i].length ) {
	  cout << q[i].name << " " << y - (q[i].year - q[i].length) << endl;
	  flag = true;
	  break;
	}
      }

      if( !flag ) cout << "Unknown" << endl;
      
    }
    
  }
  
}

Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int len;
	bool ans = false;

	cin >> S;
	len = S.length();

	repc(i, 0, 7) {
		string sub;
		if (i == 7) sub = S.substr(0, i);
		else sub = S.substr(0, i) + S.substr(len - (7 - i), 7 - i);

		if (sub == "keyence") ans = true;
	}

	cout << (ans ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    double r;
    cin >> r;
    cout << 2 * 3.1415926535 * r << endl;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)


int main(){
    ll N, X, Y; cin >> N >> X >> Y;
    --X;
    --Y;
    vector<ll> ans(N, 0);
    rep(j, N){
        rep(i, j){
            ll jdm = j - i;
            chmin(jdm,abs(X - i) + abs(Y - j) + 1);
            //cout << jdm << endl;
            ans[jdm]++; 
        }
    }
    rep(i, N-1) cout << ans[i + 1] << endl;
    return 0;
}

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

using namespace std;

const int WHITE = 0, GREY = 1, BLACK = 2;

struct CC {
    int n;
    vector<vector<int>> g;
    vector<int> color;
    vector<int> component;
    int cId = 0; //component id
    
    CC (int n) : n(n) {
        g.assign(n, vector<int>(0));
        color.assign(n, WHITE);
        component.assign(n, -1);
    }
    
    void addEdge (int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    void solve () {
        for (int i = 0; i < n; i++) {
            if (color[i] == WHITE) {
                cId++;
                dfs(i);
            }
        }
    }
    
    void dfs (int u) {
        color[u] = GREY;
        component[u] = cId;
        for (int v : g[u]) {
            if (color[v] == WHITE) {
                dfs(v);
            }
        }
        color[u] = BLACK;
    }
};

int main() {
    
    int n, m;
    cin >> n >> m;
    CC cc(n);
    
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        cc.addEdge(u, v);
    }
    
    cc.solve();
    
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int u, v;
        cin >> u >> v;
        if (cc.component[u] == cc.component[v]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


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

using namespace std;
vector<long long> fac;
vector<long long> fac_inv;
vector<long long> inv;

void init_combination(long long n, long long mod)
{
	fac.resize(n+1);
	fac_inv.resize(n+1);
	inv.resize(n+1);
	fac[0] = 1;
	fac[1] = 1;
	fac_inv[0] = 1;
	fac_inv[1] = 1;
	inv[1] = 1;
	for (long long i = 2; i <= n; i++) {
		fac[i] = fac[i-1]*i%mod;
		inv[i] = mod - (inv[mod%i] * (mod / i)) % mod;
		fac_inv[i] = fac_inv[i-1] * inv[i] % mod;
	}
}

long long modcomb(long long n, long long r, long long mod)
{
	if (n < r)
		return 0;
	long long result = fac[n]%mod;
	result *= (fac_inv[r] * fac_inv[n-r]) % mod;
	result %= mod;
	return result;
}
const long long p = 1e9+7;

#ifndef RUNTEST
int main(void)
{
	int n, k;
	cin >> n >> k;
	init_combination(n, p);
	long long a[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a+n);
	long long maxs = 0;
	long long mins = 0;
	for (int i = 0; i < n; i++) {
		maxs += (a[i] * modcomb(i, k-1, p))%p;
		maxs %= p;
		mins += (a[i] * modcomb(n-i-1, k-1, p))%p;
		mins %= p;
	}
  	long long ans = (maxs-mins)%p;
  	if (ans < 0)
      ans += p;
	cout << ans << endl;
	return 0;
}
#endif

Measured memory_bytes: 6292
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	int cnt2=0, cnt4=0;
	for(int i=0; i<n; i++){
		ull a;
		cin >> a;
		if(a%4==0) cnt4++;
		else if(a%2==0) cnt2++;
	}

	if(n/2<=cnt4) cout << "Yes" << endl;
	else if(cnt2>=n-2*cnt4) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; i++) {
		string a, b;
		cin >> a >> b;
		for (auto j = a.rbegin(); j != a.rend(); ++j) {
			if (*j == 'J') {
				char c;
				c = b.back();
				b.pop_back();
				b = c + b;
			}
			if (*j == 'C') {
				char c;
				c = b[0];
				for (int k = 0; k < b.size() - 1; k++) {
					b[k] = b[k + 1];
				}
				b[b.size() - 1] = c;
			}
			if (*j == 'E') {
				string s, t;
				for (int k = 0; k < b.size() / 2; k++) {
					s += b[k];
				}
				for (int k = (b.size() + 1) / 2; k < b.size(); k++) {
					t += b[k];
				}
				for (int k = 0; k < b.size() / 2; k++) {
					b[k] = t[k];
				}
				for (int k = (b.size() + 1) / 2; k < b.size(); k++) {
					b[k] = s[k - (b.size() + 1) / 2];
				}
			}
			if (*j == 'A') {
				for (int k = 0; k < b.size() / 2; k++)swap(b[k], b[b.size() - 1 - k]);
			}
			if (*j == 'M') {
				for (int k = 0; k < b.size(); k++) {
					if (b[k] >= '0'&&b[k] <= '9') {
						b[k]++;
						if (b[k] == char('9' + 1))b[k] = '0';
					}
				}
			}
			if (*j == 'P') {
				for (int k = 0; k < b.size(); k++) {
					if (b[k] >= '0'&&b[k] <= '9') {
						b[k]--;
						if (b[k] == char('0' - 1))b[k] = '9';
					}
				}
			}
		}
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <sstream>
#include <bitset>
#include <vector>
using namespace std;

int main(){
  int n;
  cin >> n;
  if (n < 10)
    cout << n;
  else if(n<100)
    cout << 9;
  else if(n<1000)
    cout << n-90;
  else if(n<10000)
    cout << 909;
  else if(n<100000)
    cout<< n-9999+909;
  else if(n==100000)
    cout << 9 + 900 + 90000;
}

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

int main(void){
    ll a, b, c, x, y, ans = pow(10, 9)+1;
    cin >> a >> b >> c >> x >> y;
    for (int i=0; i<=2*max(x,y); i+=2){
        ans = min(ans, a*max(0, (int)(x-(i/2))) + b*max(0, (int)(y-(i/2))) + c*i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3532
# -*- coding: utf-8 -*-

import sys

ns = raw_input().split()[0]
n = int(ns)

nl = [int(c) for c in ns]
ns = sum(nl)

# print ns
# print n
# print nl
# print ns
# print n % ns

if (n % ns) == 0:
    sys.stdout.write('Yes\n')
else:
    sys.stdout.write('No\n')
sys.stdout.flush()


Measured memory_bytes: 2568
import java.util.Scanner;
 
public class Main {
 
		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			String S = sc.next();
			int c = 0;
			for(int i = 0; i < 3; i++) {
			if(S.charAt(i) == 'o') {
			c++;}}
			System.out.println(700 + 100 * c);
			}}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define il inline
#define ri register int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 100050
#define MAXM
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define repd(i, x, y) for(ri i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
int n, m, a[MAXN], num[MAXN];
int main() {
	read(n, m), a[1] = 1;
	rep(i, 1, n) num[i] = 1;
	int x, y;
	while(m--) {
		read(x, y), num[x]--, num[y]++;
		a[y] |= a[x];
		if(!num[x]) a[x] = 0;
	}
	int ans = 0;
	rep(i, 1, n) ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
def main():
  N = int(input())
  s = input()

  # S: 1, W: 0
  for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
    l = [a0, a1]

    for c in s[1:] + s[0]:
      if c == 'o':
        a0, a1 = a1, not (a0 ^ a1)
      else:
        a0, a1 = a1, (a0 ^ a1)
      l.append(a1)

    if (l[0] == a0) and (l[1] == a1):
      print(''.join('WS'[i] for i in l[:-2]))
      exit()

  print(-1)

if __name__ == '__main__':
  main()

Measured memory_bytes: 5620
n, a, b = map(int,input().split())
mod = 10 ** 9 + 7

def permutation(n,r,mod):
    perm = 1
    for integer in range(n-r+1, n+1):
        perm *= integer
        perm %= mod
    return perm

def RepeatSquaring(x, n, m):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)%m
    x = (x*x)%m
    n = n >> 1
  return ans

def cmb(n, r, mod):
    nume = permutation(n,r,mod)
    deno = permutation(r,r,mod)
    return (nume * RepeatSquaring(deno, mod-2, mod)) % mod

ans = (RepeatSquaring(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)) % mod

print(ans)

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> ES(N + 1), OS(N + 1);
    ES[0] = 0;
    OS[0] = 0;
    ll T = 0;
    rep(i, N) {
        ES[i + 1] = ES[i];
        OS[i + 1] = OS[i];
        if (i % 2 == 1) ES[i + 1] += A[i];
        if (i % 2 == 0) OS[i + 1] += A[i];
        T += A[i];
    }
    ll ans;
    rep(i, N) {
        if (i == 0) {
            ans = T - 2 * ES[N - 1];
        } else if (i % 2 == 0) {
            ans = T - 2 * (OS[i - 1] + ES[N - 1] - ES[i]);
        } else if (i == 1) {
            ans = T - 2 * (OS[N] - OS[1]);
        } else {
            ans = T - 2 * (ES[i - 1] + OS[N] - OS[i]);
        }
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;

int a[3];

int main(){
	int n = 0,m = INF;
	for(int i = 0; i < 3; i++){
		cin >> a[i];
		n = max(n,a[i]);
		m = min(m,a[i]);
	}
	cout << n-m << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define BUF_SIZE 100
#define LONG_MIN -2147483646
#define LONG_MAX 2147483647

int main(void)
{
  char buf[100];
  long input, maxv = LONG_MIN, min = LONG_MAX;
  long linum;
  long diff = 0;

  fgets(buf, BUF_SIZE, stdin);
  sscanf(buf, "%ld", &linum);

  while(linum--){
    fgets(buf, BUF_SIZE, stdin);
    if(buf[0] == '\n') break;
    sscanf(buf, "%ld", &input);

    diff = input - min;
    if(maxv < diff){
      maxv = diff;
    }

    if(input < min){
      min = input;
    }

  }

  printf("%ld\n", maxv);

  return 0;
}

Measured memory_bytes: 604
import sys
input = sys.stdin.readline
n,m = list(map(int,input().split()))
ab = sorted([list(map(int,input().split())) for _ in range(n)])
dri_cos = 0

for i in range(n):
    if m >= ab[i][1]:
        dri_cos += ab[i][0]*ab[i][1]
    else:
        dri_cos += ab[i][0]*m
    m -= ab[i][1]
    if m <=0:
        print(dri_cos)
        exit()

Measured memory_bytes: 28412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,g,b;
  cin >> r >> g >> b;
  
  int total = 100*r + 10*g + b;
  
  if(total%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;
const int N = 2e6 + 5, M = 2e6 + 5;
int n, m, id[N], cnt, vis[N], dp[N<<1];
struct Edge { int Nxt, v; } e[M << 1];
int h[N], p = 1;
void add(int u, int v) {
	e[++p].Nxt = h[u]; e[p].v = v; h[u] = p;
}
int father[N];
int find(int x) {
	if(father[x] != x) father[x] = find(father[x]);
	return father[x];
}
struct EdgeR { int u, v; };
vector<EdgeR> a[N];
queue<int> q;
int main()
{
	int c = 0, x, y;
	scanf("%d%d", &n, &m); cnt = n;
	for(int i = 1, u, v, p; i <= m; i++) {
		scanf("%d%d%d", &u, &v, &p);
		a[p].push_back((EdgeR){u, v});
		c = max(c, p);
	}
	for(int i = 1; i <= c; i++) if(!a[i].empty())
	{
		for(int j = 0; j < a[i].size(); j++)
		{
			father[a[i][j].u] = a[i][j].u;
			father[a[i][j].v] = a[i][j].v;
			id[a[i][j].u] = -1; id[a[i][j].v] = -1;
			vis[a[i][j].u] = 0; vis[a[i][j].v] = 0;
		}
		for(int j = 0; j < a[i].size(); j++)
			father[find(a[i][j].u)] = find(a[i][j].v);
		for(int j = 0; j < a[i].size(); j++)
		{
			if(!vis[a[i][j].u]) {
				vis[a[i][j].u] = 1;
				int x = find(a[i][j].u);
				if(id[x] == -1) id[x] = ++cnt;
				add(a[i][j].u, id[x]); add(id[x], a[i][j].u);
			}
			if(!vis[a[i][j].v]) {
				vis[a[i][j].v] = 1;
				int x = find(a[i][j].v);
				if(id[x] == -1) id[x] = ++cnt;
				add(a[i][j].v, id[x]); add(id[x], a[i][j].v);
			}
		}
	}
	memset(dp, 0x3f, sizeof(dp));
	memset(vis, 0, sizeof(vis));
	q.push(1); dp[1] = 0;
	while(!q.empty()) {
		int u = q.front(); q.pop();
		if(vis[u]) continue;
		vis[u] = 1;
		for(int i = h[u]; i; i = e[i].Nxt) {
			int v = e[i].v;
			dp[v] = min(dp[v], dp[u] + 1);
			q.push(v);
		}
	}
	printf("%d\n", dp[n] == 0x3f3f3f3f ? -1 : dp[n] / 2);
	return 0;
}

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


int main(){
    while(true){
        string N; cin >> N;
        if(N == "0"){
            break;
        }
        int ans = 0;
        for(int i = 0; i < N.size(); i++){
            int tmp = N[i]-'0';
            ans += tmp;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);


int main(void) {
	int N, n, i, j, cnt = 0, max = 0;

	i_cin(N);
	if (N == 1) {i_cout(1); return 0;}
	
	for (i = N; i > 0; i--) {
		j = i; cnt = 0;
		while(j>0) {
			if (!(j % 2)) cnt++;
			j /= 2;
		}
		if (max < cnt) {
			max = cnt; n = i;
		}
	}

	i_cout(n);

	return 0;
}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}


Measured memory_bytes: 128
/**-------------------------
|--------From A.R.A--------|
-------------------------**/

#include <bits/stdc++.h>

#define ll            long long int
#define pb            push_back
#define ull           unsigned long long int
#define endl          "\n"
#define sz(c)         (c).size()
#define sall(c)       sort((c).begin(),(c).end())
#define rsall(c)      sort((c).rbegin(),(c).rend())
#define rev(c)        reverse((c).begin(),(c).end())
#define FOR(i,n)      for(ll i=0;i<n;i++)
#define max3(a,b,c)   max(max(a,b),c)
#define min3(a,b,c)   min(min(a,b),c)
#define input(a,i,n)  for(ll i=0;i<n;i++){      cin>>a[i];}
#define output(a,i,n) for(ll i=0;i<n;i++){cout<<a[i]<<" ";}

using namespace std;
int64_t R=1;
void solution(){
    int64_t n,times=0,ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int64_t x,y;
        cin>>x>>y;
        if(x==y) times++;
        else{
            times=0;
        }
        ans=max(ans,times);
    }
    if(ans>2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main()
{
   // cin>>R;
    FOR(i,R){solution();}
    return 0;
}


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

using namespace std;

const int inf = 1e8;
const int maxN = 3 * 1e5 + 5;
char c[maxN];
int s[maxN], N;

int main() {
	scanf("%d", &N); scanf("%s", c + 1);
	for(int i = 1; i <= N; ++i) s[i] = s[i - 1] + (c[i] == 'E');
	int ans = inf;
	for(int i = 1; i <= N; ++i) {
		ans = min(ans, s[N] - s[i] + (i - 1 - s[i - 1]));
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
int main() {
    string s; cin >> s;
    int sum = accumulate(s.begin(), s.end(), 0) - '0' * s.length();
    ll prod = 1; for (char c : s) prod *= c + 1 - '0';
    ll acc = 0;
    { // decide for sum and prod
        vector<vector<unordered_map<ll,ll> > > dp(s.length()+1,
               vector<unordered_map<ll,ll> >(sum+1));
        dp[0][0][1] = 1;
        repeat (i,s.length()) {
            repeat (j,sum+1) {
                for (auto it : dp[i][j]) {
                    ll k = it.first;
                    repeat (d,10) {
                        if (j+d < sum or (j+d == sum and k*(d+1) < prod)) {
                            dp[i+1][j+d][k*(d+1)] += dp[i][j][k];
                        }
                    }
                }
            }
        }
        repeat (j,sum+1) {
            for (auto it : dp[s.length()][j]) {
                acc += it.second;
            }
        }
    }
    { // decide for int
        array<vector<vector<unordered_map<ll,ll> > >,2> dp;
        dp[0].resize(s.length()+1, vector<unordered_map<ll,ll> >(sum+1));
        dp[1].resize(s.length()+1, vector<unordered_map<ll,ll> >(sum+1));
        dp[0][0][0][1] = 1;
        repeat (l,2) { // 0 : match, 1 : not
            repeat (i,s.length()) {
                repeat (j,sum+1) {
                    for (auto it : dp[l][i][j]) {
                        ll k = it.first;
                        repeat (d,10) {
                            int nl = 1;
                            if (l == 0 and d >  s[i]-'0') continue;
                            if (l == 0 and d == s[i]-'0') nl = 0;
                            if (j+d >  sum) continue;
                            if (j+d == sum) {
                                if (prod % (k*(d+1)) != 0) continue;
                                if (k*(d+1) >  prod) continue;
                            }
                            dp[nl][i+1][j+d][k*(d+1)] += dp[l][i][j][k];
                        }
                    }
                }
            }
        }
        acc += dp[0][s.length()][sum][prod];
        acc += dp[1][s.length()][sum][prod] - 1;
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 27832
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

constexpr int INF = 1000000001;
constexpr int MAX = 10000;

typedef pair<int, int> P;

struct Edge {
    int to;
    int cap;
    int cost;
    int rev;
    Edge(int to, int cap, int cost, int rev) 
        : to(to), cap(cap), cost(cost), rev(rev) {}
};

int V, E, F;
vector<Edge> G[MAX];
int h[MAX];
int dist[MAX];
int prevv[MAX], preve[MAX];

auto add_edge(int from, int to, int cap, int cost) -> void {
    G[from].push_back(Edge(to, cap, cost, G[to].size()));
    G[to].push_back(Edge(from, 0, -cost, G[from].size() - 1));
}

auto min_cost_flow(int s, int t, int f) -> int {
    auto res = 0;
    fill(h, h + V, 0);
    while(f > 0) {
        priority_queue<P, vector<P>, greater<P>> que;
        fill(dist, dist + V, INF);
        dist[s] = 0;
        que.push(P(0, s));
        while(!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (auto i = 0; i < G[v].size(); i++) {
                Edge &e = G[v][i];
                if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.push(P(dist[e.to], e.to));
                }
            }
        }
        if (dist[t] == INF) {
            return -1;
        }
        for (int v = 0; v < V; v++) {
            h[v] += dist[v];
        }

        int d = f;
        for (auto v = t; v != s; v = prevv[v]) {
            d = min(d, G[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * h[t];
        for (auto v = t; v != s; v = prevv[v]) {
            Edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}

auto main(int argc, char const *argv[]) -> int {
    int n;

    cin>>V>>E>>F;
    while(E--){
        int u, v, c, d;
        cin>>u>>v>>c>>d;
        add_edge(u,v,c,d);
    }

    cout<<min_cost_flow(0, V - 1, F)<<endl;

    return 0;
}

Measured memory_bytes: 3388
import scala.io.StdIn
 
object Main {
  def main(args: Array[String]){

	val (hh, mm, ss) = calcTime(StdIn.readLine().toInt)
    println(f"${hh}%d:${mm}%d:${ss}%d")
  }
  
  def calcTime(ss: Int): (Int, Int, Int) = {
  	@annotation.tailrec
	def f(t: Int, r: Int, n: Int): (Int, Int) =
		if (r >= t) f(t, r - t, n + 1) else (n, r)

	val (hh, ss2) = f(3600, ss,  0)
	val (mm, ss3) = f(60,   ss2, 0)
	(hh, mm, ss3)
  }
}


Measured memory_bytes: 43960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

// Problem link : https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_a

int main() {
	string s;
	cin >> s;
	const int n = s.size();
	if (n & 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < n; i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
hhh = list(map(int, input().split()))
ans = 0
cnt = 0
for h1, h2 in zip(hhh, hhh[1:]):
    if h1 >= h2:
        cnt += 1
        ans = max(ans, cnt)
    else:
        cnt = 0
print(ans)


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

char to_upper(char c) {
	return c + 'A' - 'a';
}

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << to_upper(a[0]) << to_upper(b[0]) << to_upper(c[0]) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=120;
string maze[maxn];
const int inf=0x3f3f3f3f;
int step[maxn][maxn];
int xx[4]= {1,0};
int yy[4]= {0,1};
int h,w;
struct node
{
    int x,y;
};
int bfs()
{
    queue<node>q;
    node nw;
    nw.x=0,nw.y=0;
    if(maze[0][0]=='.')
        step[0][0]=0;
    else
        step[0][0]=1;
    q.push(nw);
    while(!q.empty())
    {
        nw=q.front();
        q.pop();
        for(int i=0; i<2; ++i)
        {
            int X=nw.x+xx[i];
            int Y=nw.y+yy[i];
            if(X<0||X>=h||Y<0||Y>=w)
                continue;
            int st;
            if(maze[X][Y]=='#'&&maze[nw.x][nw.y]=='.')
                st=1;
            else
                st=0;
            if(step[X][Y]>step[nw.x][nw.y]+st)
            {
                step[X][Y]=step[nw.x][nw.y]+st;
                node tp;
                tp.x=X;
                tp.y=Y;
                q.push(tp);
            }
        }
    }
    return step[h-1][w-1];
}
int main()
{
    memset(step,inf,sizeof step);
    cin>>h>>w;
    for(int i=0; i<h; ++i)
        cin>>maze[i];
    cout<<bfs()<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a,b,c; cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


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

typedef long long ll;

ll md = 1000000007;

vector<ll> a;
vector<ll> x;
const double PI=3.14159265358979323846;
int main(int, char**) 
{
	double a, b, x, n;
	std::cin >> a >> b >> x;
	if (x > a * a * b / 2.0) {
		double y = ((a * b - x / a) * 2 / a);
		n = atan(y / a) * 180 / PI;
	} else {
		double y = x * 2 / a / b;
		n = atan(b / y) * 180.0 / PI;
	}
	
	cout << setprecision(12) << n << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
    cout << "Yes" << endl;
  }
  else if(s.at(1)==s.at(2)&&s.at(2)==s.at(3)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
import math
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return math.gcd #最大公約数
def lcm(a,b):return (a*b) // math.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
A = iln()
B = iln()
A_sum = sum(A)
B_sum = sum(B)

if A_sum < B_sum:
    print(-1)
    exit()

cnt = 0
minus = 0
plus = []
for i in range(N):
    diff = A[i] - B[i]
    if diff < 0:
        cnt += 1
        minus += abs(diff) 
    elif diff > 0:
        plus.append(diff)
plus.sort(reverse=True)
if minus == 0:
    print('0')
else:
    for i in range(len(plus)):
        minus -= plus[i]
        cnt += 1
        if minus <= 0:
            break
    print(cnt)







Measured memory_bytes: 19264
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		
		long k = xor(a-1)^xor(b);
		
		System.out.println(k);
		
	}
	static long xor(long x) {
		if(x % 2 == 0) {
			if(x % 4 == 2) {
				return x^1;
			}
			else {
				return x^0;
			}
		}
		else {
			if((x+1)%4 == 2) {
				return 1;
			}
			else {
				return 0;
			}
		}
	}

}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int x;
	int a, b;
	cin >> x >> a >> b;

	cout << (x - a) % b << endl;

}

Measured memory_bytes: 256
package main
import "fmt"
func main(){
    var N, K, X, Y, ans int
    
    fmt.Scanf("%d", &N)
    fmt.Scanf("%d", &K)
    fmt.Scanf("%d", &X)
    fmt.Scanf("%d", &Y)
    for i := 0; i < min(K, N); i++ {
        ans += X
    }
    for i := min(K, N); i < N; i++ {
        ans += Y
    }
    
    fmt.Println(ans)
}

func min(n ...int) int {
    cnt := len(n)
    ret := n[0]
    for i := 1; i < cnt; i++ {
        if ret > n[i] {
            ret = n[i]
        }
    }
    return ret
}

Measured memory_bytes: 512
function Main(input) {
  input = input.split('\n');
  const [n, k] = input[0].split(' ').map(Number);
  const p = input[1].split(' ').map(Number).sort((a, b) => a - b);
  let sum = 0;
  for (let i = 0; i < k; i++) {
    sum += p[i];
  }
  console.log(sum);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29704
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  500005

ll col[N];
ll last[N];
vi BIT(N);
void update(ll idx,ll val)
{
    for(;idx<N;idx+=(idx&-idx))
        BIT[idx]+=val;
}
ll query(ll idx)
{
    ll ans=0;
    for(;idx>0;idx-=(idx&-idx))
        ans+=BIT[idx];
    return ans;
}
struct node
{
    ll idx,l,r;
};
node quer[N];
bool cmp(node a,node b)
{
    if(a.r==b.r)
        return a.l<b.l;
    return a.r<b.r;
}
void solve()
{
    memset(last,-1,sizeof(last));
    ll n,q;
    cin>>n>>q;
    rep(i,0,n)
    cin>>col[i+1];
    rep(i,0,q)
    {
        ll x,y;
        cin>>x>>y;
        quer[i].idx=i;
        quer[i].l=x;
        quer[i].r=y;
    }
    sort(quer,quer+q,cmp);
    ll cq=0;
    ll ans[q];
    for(int i=1;i<=n;i++)
    {
        
        update(i,1);
        if(last[col[i]]!=-1)
            update(last[col[i]],-1);
        last[col[i]]=i;
        while(cq<q&&quer[cq].r==i)
        {
            ans[quer[cq].idx]=query(quer[cq].r)-query(quer[cq].l-1);
            cq++;
        }
    }
    rep(i,0,q)
    cout<<ans[i]<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 31096
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (in.hasNext()) {
            int lenH = in.nextInt();
            int lenW = in.nextInt();

            if (lenH == 0) {
                break;
            }

            char[][] wallDef = {
            		{'#', '.'},
            		{'.', '#'}
            };
            for (int hPos = 0; hPos < lenH; hPos++) {
                for (int wPos = 0; wPos < lenW; wPos++ ) {
                	sb.append(wallDef[hPos % 2][wPos % 2]);
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 20760
import itertools
import sys
import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N, C = map(int, input().split())
COSTS = []
for _ in range(C):
    COSTS.append(list(map(int, input().split())))
# (C, C)
COSTS = np.array(COSTS)
COLORS = []
for _ in range(N):
    COLORS.append(list(map(int, input().split())))
# (N, N)
COLORS = np.array(COLORS) - 1

# cs[x, y]: x == (i + j) % 3 で、色が y であるマスの数
cs = np.zeros((3, C))
for i in range(N):
    for j in range(N):
        cs[(i + j) % 3, COLORS[i, j]] += 1

ans = INF
# (i + j) % 3 == N のマスを cN にする場合のコストを全通り計算する
for c0, c1, c2 in itertools.permutations(range(C), r=3):
    ans = min(
        ans,
        np.dot(COSTS[:, c0], cs[0]) +
        np.dot(COSTS[:, c1], cs[1]) +
        np.dot(COSTS[:, c2], cs[2]))
print(int(ans))


Measured memory_bytes: 18780
#include <stdio.h>
int main(void)
{
  int a1,a2,a3,a4;
  int b1,b2,b3,b4;
  int hit,blow;

  while(scanf("%d %d %d %d %d %d %d %d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4) != EOF)
    {
      hit = 0;
      blow = 0;

      if(a1 == b1) hit++;
      if(a2 == b2) hit++;
      if(a3 == b3) hit++;
      if(a4 == b4) hit++;
      
      if(a1 == b2) blow++;
      if(a1 == b3) blow++;
      if(a1 == b4) blow++;
      if(a2 == b1) blow++;
      if(a2 == b3) blow++;
      if(a2 == b4) blow++;
      if(a3 == b1) blow++;
      if(a3 == b2) blow++;
      if(a3 == b4) blow++;
      if(a4 == b1) blow++;
      if(a4 == b2) blow++;
      if(a4 == b3) blow++;

      printf("%d %d\n",hit,blow);
    }
  return 0;
}

Measured memory_bytes: 0
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
///////////////////////////////////////////////////////////

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

   int n;cin >> n;
   long long ans = 0;
   for(ll i = 1;i <= n;i++){
        if(!(i % 3 == 0) and !(i % 5 == 0))ans+=i;
   }
   cout << ans << '\n';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
//#define DEBUG
#define REP( i , nn ) for(int i = 0 ; i < (int) nn; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int n;
    cin >> n;
    vi h(n);
    REP(i,n) cin >> h[i];
    int ans = 0;
    for(int i = 0, j = 0; i < n ; i = j){
        int count = 0;
        for( j = i + 1 ; j < n ; j++){
            if( h[j] > h[j-1]) break;
            count++; 
        }
        if( count > ans) ans = count;
    } 
    cout << ans << "\n";
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
  int n,i,j,tyouten,shutujisu,num;
  int M[100][100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&tyouten,&shutujisu);
    tyouten--;
    for(j=0;j<shutujisu;j++){
      scanf("%d",&num);
      num--;
      M[tyouten][num]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n;
     m=1;
    for(i=1;i<=n;i++)m*=i;
    ll a[n];
    for(i=0;i<n;i++)a[i]=i;
    ll x[i],y[i];
    for(i=0;i<n;i++)cin>>x[i]>>y[i];
    double ans=0;
    for(i=0;i<m;i++)
    {
        for(j=1;j<n;j++)
        {
            k=(x[a[j]]-x[a[j-1]])*(x[a[j]]-x[a[j-1]])+(y[a[j]]-y[a[j-1]])*(y[a[j]]-y[a[j-1]]);
            //cout<<sqrt(k)<<" ";
            ans=(ans+sqrt(k));
        }
        next_permutation(a,a+n);
    }
    ans/=m;
    cout<<fixed<<setprecision(10)<<ans;
}


Measured memory_bytes: 256