akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin>>n;
    ll mod=1e9+7;
    ll ans=1;

    bool prime[1001];
    for(int i=2;i<=1000;i++){
        prime[i]=true;
    }
    for(int i=2;i<=1000;i++){
        if(prime[i]){
            for(int j=2*i;j<=1000;j+=i){
                prime[j]=false;
            }
        }
    }
    for(int i=2;i<=n;i++){
        if(prime[i]){
            int a=n;
            int p=0;
            while(a>0){
                a/=i;
                p+=a;
            }
            ans=ans*(p+1)%mod;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<s.length(); i++) {
			if (i%2 == 0) sb.append(s.charAt(i));
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 25800
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int nax = 1e5 + 1;
vector<int> adj[nax];
vector<bool> visited(nax, false);

void dfs (int x) {
	if (!visited[x]) {
		visited[x] = true;
		for (auto u : adj[x]) {
			dfs (u);
		}
	}
}

signed main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n, m, x, y;
	cin >> n >> m;
	
	for (int i = 1; i <= m; i++) {
		cin >> x >> y;
		adj[x].push_back (y);
		adj[y].push_back (x);
	}
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!visited[i]) {
			ans++;
			dfs (i);
		}
	}
	
	cout << ans - 1;
	
	return 0;
} 


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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int n;
vector<vector<int>> edges;
vector<int> color;

void dfs(int u, int p, int c) {
    color[u] = c;
    for (int v : edges[u])
        if (v != p) {
            dfs(v, u, 1 - c);
        }
}

void assign(vector<int>& p, int u, int* w, int c1, int c2, int c3 = 0){
    if (w[c1] <= p.size()-1) {
        p[u] = w[c1];
        w[c1] += 3;
    }
    else if (w[c2] <= p.size()-1){
        p[u] = w[c2];
        w[c2] += 3;
    }
    else{
        p[u] = w[c3];
        w[c3] += 3;
    }
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    cin >> n;
    edges.resize(n+1);
    color.resize(n+1);
    FOR(i, n-1){
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }

    dfs(1, -1, 0);
    int cnt0 = 0;
    FOR1(u, n) cnt0 += color[u] == 0;

    vector<int> p(n+1);
    int cnt1 = n-cnt0;

    int w[] = {1, 2, 3};
    if (cnt0 <= n/3){
        FOR1(u, n){
            if (color[u] == 0)
                assign(p, u, w, 2, 2, 2);
            else
                assign(p, u, w, 0, 1, 2);
        }
    }
    else if (cnt1 <= n/3){
        FOR1(u, n){
            if (color[u] == 1)
                assign(p, u, w, 2, 2);
            else
                assign(p, u, w, 0, 1, 2);
        }
    }
    else{
        FOR1(u, n){
            if (color[u] == 0)
                assign(p, u, w, 0, 2);
            else
                assign(p, u, w, 1, 2);
        }
    }
    FOR1(u, n) cout << p[u] << " ";
    cout << endl;


    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 17920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e3 + 5;
int d[maxn];
int main()
{
    ios::sync_with_stdio(false);
    string a ; cin >> a;
    if(a.length() != 6) {
        cout << "No" << endl;
        return 0;
    }
    a = '#' + a;
    if(a[1] != a[2] && a[1] != a[3] && a[1] != a[4]  && a[1] != a[5]  && a[1] != a[6]){
        if(a[2] != a[3] && a[2] != a[4]  && a[2] != a[5]  && a[2] != a[6]){
            if(a[3] == a[4]){
                if(a[5] == a[6]){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e6 + 2;
 
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , unsigned ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) % mod ;
//        y = y >> 1;
//        x = (x * x) % mod;
//    }
//    return res % mod ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
//    //ans[a] += ans[b];
//    //return true;
// }
//
//ll sev[275];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 275 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 275 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}
void solve()
{
    ll n ,m ;
    cin >> n >> m;
    if(n == m)
        print("Yes");
    else
        print("No");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    //cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 256
x, n = map(int, input().split())
P = set([int(x) for x in input().split()])
ans = 10 ** 4
for i in range(-1, 102):
    if i in P:
        continue
    if abs(x - ans) == abs(i - x):
        ans = min(ans, i)
    if abs(x - ans) > abs(i - x):
        ans = i
print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <map>
using namespace std;
int main(void){
    
    int n,answer = 0;
    cin >> n;
    
    map<int,bool> m;
    
    for(int i = 0; i < n; i++){
        int input;
        cin >> input;
        
        m[input] = !m[input];
        
    }
    
    for(pair<int,bool> t : m){
        if(t.second == true){
            answer++;
        }
    }
    
    cout << answer << endl;
}


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

class UnionFind
{
private:
  vector<int> par;
  vector<int> rank;

public:
  UnionFind(int n)
  {
    par.resize(n);
    rank.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  
  int find(int x)
  {
    if (par[x] == x) {
      return x;
    } else  {
      return par[x] = find(par[x]);
    }
  }
  
  bool same(int x, int y)
  {
    return find(x) == find(y);
  }
  
  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if (x == y) return;
    
    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) ++rank[x];
    }
  }
};

typedef vector<vector<int> > Graph;

const int MAXN = 100000;
int N, Q;
int par[MAXN];
Graph G;

int main()
{
  while (cin >> N >> Q && (N|Q)) {
    G = Graph(N);
    for (int i = 1; i < N; ++i) {
      cin >> par[i]; --par[i];
      G[par[i]].push_back(i);
    }

    vector<char> op(Q);
    vector<int> v(Q);
    for (int i = 0; i < Q; ++i) {
      cin >> op[i] >> v[i];
      --v[i];
    }
    reverse(op.begin(), op.end());
    reverse(v.begin(), v.end());

    vector<int> M(N);
    M[0] = 1;
    for (int i = 0; i < Q; ++i)
      if (op[i] == 'M') ++M[v[i]];

    UnionFind uf(N);
    vector<int> nearest(N, -1);
    for (int st = 0; st < N; ++st) {
      if (!M[st]) continue;
      queue<int> que;
      que.push(st);
      while (que.size()) {
        int v = que.front();
        que.pop();
        for (int i = 0; i < G[v].size(); ++i) {
          int nv = G[v][i];
          if (M[nv]) continue;
          uf.unite(v, nv);
          que.push(nv);
        }
      }
      nearest[uf.find(st)] = st;
    }

    lli res = 0;
    for (int i = 0; i < Q; ++i) {
      if (op[i] == 'Q') {
        res += nearest[uf.find(v[i])] + 1;
      } else if(!--M[v[i]]) {
        int tmp = nearest[uf.find(par[v[i]])];
        uf.unite(v[i], par[v[i]]);
        nearest[uf.find(par[v[i]])] = tmp;
      }
    }
    cout<< res << endl;
  }
  return 0;
}

Measured memory_bytes: 9804
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int K;
  cin >> K;
  vector<ll> A(K);
  for (int i = 0; i < K; i++) {
    cin >> A[i];
  }
  ll s = 2, t = 2;
  for (int i = K - 1; i >= 0; i--) {
    ll ss = (s + A[i] - 1) / A[i] * A[i];
    ll tt = t / A[i] * A[i];
    if (ss > t || tt < s || ss > tt) {
      cout << -1 << endl;
      return 0;
    }
    s = ss;
    t = tt + A[i] - 1;
  }
  cout << s << " " << t << endl;
  return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b;
    while(cin>>a>>b){
        vector<int> deg(200,0);
        deg[a-1]++;
        deg[b-1]++;
        while(cin>>a>>b&&(a||b)){
            deg[a-1]++;
            deg[b-1]++;
        }
        
        int odd = 0;
        rep(i,deg.size())if(deg[i]%2)odd++;
        
        if(deg[0]%2 && deg[1]%2 && odd==2)cout<<"OK"<<endl;
        else cout<<"NG"<<endl;
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

string dp[10101];

void chmax(string& a, string b){
    // cout << a << " " << b << endl;
    if (a.size() < b.size()) a = b;
    else if(a.size() == b.size() && a < b) a = b;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> cost = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<int> v(m), w(m);
    rep(i, m){
        cin >> v[i];
        w[i] = cost[v[i]-1];
        // cout << v[i] << " " << w[i] << endl;
    }

    rep(i, n){
        rep(j, m){
            if(i == 0) dp[i+w[j]] = v[j]+'0';
            else if(dp[i] != ""){
                string next;
                if(dp[i][0]-'0' < v[j]){
                    next = v[j]+'0';
                    next += dp[i];
                }else{
                    next = dp[i];
                    next += v[j]+'0';
                }
                chmax(dp[i+w[j]], next);
            }
            // cout << dp[i+w[j]] << " (" << i+w[j] << ")" << endl;
        }
            // cout << endl;

    }
    cout << dp[n] << endl;

}

Measured memory_bytes: 48128
#include<stdio.h>
#include<string.h>
int main(){
	char s[5];
	int n;
	scanf("%s",s);
	n = strlen(s);
	if(n == 2)
		printf("%s\n",s);
	if(n == 3)
		printf("%c%c%c\n",s[2],s[1],s[0]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
using namespace std;
int n;
double t[101],v[101];
main()
{
	double V=0;double ans=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>t[i];
	for(int i=0;i<n;i++)cin>>v[i];
	for(int i=0;i<n;i++)
	{
		double sto=v[i+1],ma=0;
		for(int j=n;--j>i;)ma=min(ma+t[j],v[j]);
		v[i+1]=ma;
		if(v[i]<=v[i+1])
		{
			if(v[i]-V<=t[i])
			{
				ans+=(v[i]-V)*(v[i]+V)/2+(t[i]-v[i]+V)*v[i];
				V=v[i];
			}
			else
			{
				ans+=t[i]*(V+V+t[i])/2;
				V=V+t[i];
			}
		}
		else
		{
			if(v[i+1]-V>t[i])
			{
				ans+=t[i]*(V+V+t[i])/2;
				V=V+t[i];
			}
			else if(v[i]-V+v[i]-v[i+1]<=t[i])
			{
				ans+=(v[i]-V)*(v[i]+V)/2+(v[i]-v[i+1])*(v[i]+v[i+1])/2+(t[i]-v[i]+V-v[i]+v[i+1])*v[i];
				V=v[i+1];
			}
			else
			{
				double m=(t[i]+V+v[i+1])/2;
				ans+=(m-V)*(m+V)/2+(m-v[i+1])*(m+v[i+1])/2;
				V=v[i+1];
			}
		}
		v[i+1]=sto;
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}

Measured memory_bytes: 256
import itertools
n = int(input())
mark = ['S', 'H', 'C', 'D']
nums = [str(i) for i in range(1, 14)]
cards = []

for i in mark:
    for j in nums:
        cards.append("{0} {1}".format(i, j))


for i in range(1, n+1):
    pair = input()
    cards.remove(pair)


for i in cards:
    print(i)



Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll fac[2020];
ll finv[2020];
ll inv[2020];

void compre() {
  fac[0] = fac[1] = 1LL;
  finv[0] = finv[1] = 1LL;
  inv[1] = 1LL;
  for(ll i = 2LL; i<2020; i++) {
    fac[i] = fac[i-1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

long long modcom(long long n, long long k) {
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main() {
  ll n, k;
  cin >> n >> k;
  compre();
  for(ll i = 1LL; i<=k; i++) {
    ll a = modcom(k-1,i-1);
    ll b = modcom(n-k+1,i);
    cout << a * b % mod << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cmath>
#define range(i,a,b) for(int i = (a); i <= (b); i++)
#define rrange(i,a,b) for(int i = (a); i >= (b); i--)
#define rep(i,b) for(int i = 1; i <= (b); i++)
#define rrep(i,b) for(int i = (b); i >= 1; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long ll;
const int N=3e2+11;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001LL,mod=1e9+7;
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
ll dp[N][N][N],n,m,ans;
vector<pair<int,int> >c[N];
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
ll ll_read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
void add(ll &x,ll y){x=x+y-((x+y>=mod)?mod:0);}
//void add(ll &x,ll y){
//	x+=y;
//	if(x>=mod) x-=mod;
//}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();m=read();
	rep(i,m){
		int l=read(),r=read(),x=read();
		c[r].push_back(make_pair(l,x));
	}
	dp[0][0][0]=1;
	range(i,0,n) range(j,0,n) range(k,0,n){
		int len=max(i,max(j,k));
		range(l,0,(int)c[len].size()-1) if((c[len][l].first<=i)+(c[len][l].first<=j)+(c[len][l].first<=k)!=c[len][l].second) dp[i][j][k]=0;
		if(len==n) add(ans,dp[i][j][k]);
		else add(dp[len+1][j][k],dp[i][j][k]),add(dp[i][len+1][k],dp[i][j][k]),add(dp[i][j][len+1],dp[i][j][k]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 229632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int r=sc.nextInt();
        int g=sc.nextInt();
        int b=sc.nextInt();
        int N=sc.nextInt();
        int sum =0;
        for(int i=0; i<N/r+1; i++){
            for(int j=0; j<N/g+1; j++){
                int nokori=N-r*i-g*j;
                if(nokori<0){
                    break;
                }else{
                    // System.out.println("r:"+i+" g:"+j+", b:"+nokori%b);
                    if(nokori%b==0){
                        sum++;
                    }
                }
            }
        }
        System.out.println(sum);
        // System.out.println("XXXXXXXX");
    }
}


Measured memory_bytes: 23508
n = int(input())
h = [[int(i) for i in input().split()] for j in range(n)]
s = [[h[i][0]+ h[i][1], i] for i in range(n)]
s.sort(reverse=True)
ans = 0
flag = 0
for i in range(n):
    if flag == 0:
        ans += h[s[i][1]][0]
        flag = 1
    else:
        ans -= h[s[i][1]][1]
        flag = 0
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n;
  cin >> n;

  vector<ll> l(n);
  for (ll i = 0; i < n; ++i) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  
  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    for (ll j = i+1; j < n; ++j) {
      auto itr = lower_bound(l.begin(), l.end(), l[i]+l[j]);
      ll top = distance(l.begin(), itr) - 1;
      ans += max(top-j, ll(0));
    }
  }

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

Measured memory_bytes: 256
H,W = map(int,input().split())
step = H+W-2
A = []
for i in range(H):
  temp = str(input())
  temp = list(temp)
  A.append(temp)
cnt = 0
for i in range(H):
  for j in range(W):
    if A[i][j] == "#":
      cnt += 1
if cnt == step+1:
  print("Possible")
else:
  print("Impossible")

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli  long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define fbo find_by_order //returns iterator
#define fok order_of_key //return index
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=998244353;
lli inf=9223372036854775807;
//string s=bitset<32>(n).to_string();
typedef tree<lli,null_type,less<lli>,rb_tree_tag, // change both to lli if set is req insted of multiset
tree_order_statistics_node_update> indexed_set;
#define UNASSIGNED 0  
//&& + - ! ~ ++ - - ()

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

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

ll go(vector<ll> arr, int k=2) {
    int n = arr.size();
    vector<ll> dp(n, LLONG_MAX);
    dp[n-1] = 0;

    for (int i = n-2; i >= 0; i--)
        for (int j = i+1; j <= min(n-1, i+k); j++)
            dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);

    ll ans = dp[0];
    return ans;
}

int main() {
    int n, k;
    cin >> n;
    vector<ll> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    cout << go(arr) << endl;
    return 0;
}


Measured memory_bytes: 5584
N = int(input())
A = list(map(int, input().split()))

zero = False
gu = 1
for a in A:
    if a == 0:
        zero = True
    elif a < 0:
        gu *= -1

anss = [abs(a) for a in A]
if zero | (gu == 1):
    print(sum(anss))

else:
    mina = min(anss)
    print(sum(anss) - 2 * mina)


Measured memory_bytes: 14228
#include <bits/stdc++.h> 
#define ll long long int
#define ld long double
#define ull unsigned long long
const double pi=3.14159265358979323846;
using namespace std;

ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }
    return result;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ull a;
    ld b;
    cin>>a>>b;
    a=a*b;
    cout<<a<<"\n";
}

Measured memory_bytes: 3744
#![allow(unused_imports, dead_code, unused_variables, unused_mut)]
use std::cmp;
use std::mem::swap;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use permutohedron::LexicalPermutation;
use text_io::{read, scan};
use proconio::{input, marker::*, fastout};
const INF: i32 = std::i32::MAX;
const MOD: i32 = 1e9 as i32 + 7;

#[fastout]
fn main() {
    input! {n: usize, a: [i64; n]};

    let mut csum: Vec<i64> = Vec::new();
    csum.push(0);
    for i in 0..n {
        csum.push(csum[i] + a[i]);
    }

    let mut ans:u128 = 0;
    for i in 0..(n - 1) as usize{
        let mut tmp = csum[n] - csum[i + 1];
        tmp %= MOD as i64;
        let mut seki:u128 = (a[i] * tmp) as u128;
        seki %= MOD as u128; 
        ans += seki;
        ans %= MOD as u128;
    }

    println!("{}", ans % MOD as u128);
}

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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;
int N, K;
int r[3005], mxr[3005];
int sum[3005][2];
char s[3005];
int dp[3005][3005];

int count0(int st, int dr)
{
    return (sum[dr][0] - sum[st - 1][0]);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d\n", &N, &K);

    for(int i = 1; i <= N; i++)
        r[i] = i;

    scanf("%s", s + 1);

    for(int i = 1; i <= N; i++)
    {
        sum[i][0] = sum[i - 1][0];
        sum[i][1] = sum[i - 1][1];
        sum[i][ s[i] - '0' ]++;
    }

    for(int i = 1; i <= K; i++)
    {
        int st, dr;
        scanf("%d%d", &st, &dr);
        r[st] = max(r[st], dr);
    }

    for(int i = 1; i <= N; i++)
        mxr[i] = max(mxr[i - 1], r[i]);
    mxr[N + 1] = mxr[N];

    /// DP[i][j] = fixam primele i - 1 si avem j zero pentru [ i, mxr[i] ]

    dp[1][ sum[ r[1] ][0] ] = 1;
    for(int i = 1; i <= N; i++)
        for(int j = 0; j <= N; j++)
            if(dp[i][j])
            {
                int cnt0 = j;
                int cnt1 = mxr[i] - i + 1 - cnt0;

                int cntNext0 = count0(mxr[i] + 1, mxr[i + 1]);

                if(cnt1)
                    dp[i + 1][cntNext0 + cnt0] = (dp[i + 1][cntNext0 + cnt0] + dp[i][j]) % mod;
                if(cnt0)
                    dp[i + 1][cntNext0 + cnt0 - 1] = (dp[i + 1][cntNext0 + cnt0 - 1] + dp[i][j]) % mod;
            }

    printf("%d\n", dp[N + 1][0]);
    return 0;
}


Measured memory_bytes: 33920
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int i = 1, x;
		while (true) {
			x = scanner.nextInt();
			if (x == 0)
				break;
			System.out.println("Case "+ i++ +": " + x);
		}
		scanner.close();
	}
}

Measured memory_bytes: 32996
(n, m) = [int(i) for i in input().split()]
A = []
b = []
for i in range(n):
    A.append([int(j) for j in input().split()])
   
for r in range(m):
    b.append(int(input()))
   
for i in range(n):
    s = 0
    for j in range(m):
        s += A[i][j] * b[j]
    print(s)

Measured memory_bytes: 7012
N, M = map(int, input().split())
P, Y = [], []
ydics = [{} for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    ydics[p-1][i] = (p, y)

odic = {}
for ydic in ydics:
    for o, (i, (p, y)) in enumerate(sorted(ydic.items(), key=lambda x: x[1][1])):
        odic[i] = (p, o+1)
for i, (p, o) in sorted(odic.items()):
    print(str(p).zfill(6) + str(o).zfill(6))

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

void dfs(const vector<vector<bool>> &g, vector<bool> &visited, int v) {
  visited.at(v) = true;
  for (int i = 0; i < visited.size(); i++) {
    if ((not g.at(v).at(i)) or visited.at(i)) continue;
    dfs(g, visited, i);
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  vector<vector<bool>> g(n, vector<bool>(n));
  for (int i = 0; i < m; i++) {
    g.at(a.at(i)).at(b.at(i)) = true;
    g.at(b.at(i)).at(a.at(i)) = true;
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    g.at(a.at(i)).at(b.at(i)) = false;
    g.at(b.at(i)).at(a.at(i)) = false;
    vector<bool> visited(n);
    dfs(g, visited, a.at(i));
    if (!visited.at(b.at(i))) ans++;
    g.at(a.at(i)).at(b.at(i)) = true;
    g.at(b.at(i)).at(a.at(i)) = true;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


int N, S;
ll A[3030];
ll dp[3030][3030];
ll mod = 998244353;

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

	cin >> N >> S;
	for (int i = 0; i < N; i++)cin >> A[i];

	for (int i = 0; i < N; i++) {
		dp[i][0] = 1;
		dp[i][A[i]] = 1;
		if (i == 0)continue;
		for (int j = 0; j <= S; j++) {
			if (j < A[i])dp[i][j] += 2LL * dp[i - 1][j];
			else dp[i][j] += 2LL * dp[i - 1][j] + dp[i - 1][j - A[i]];
			dp[i][j] %= mod;
		}
	}
	puts(dp[N - 1][S]);
	
	return 0;
}

Measured memory_bytes: 74684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> b[i];
  REP(i, n) cin >> c[i];
  SORT(a); SORT(b); SORT(c);
  ll ans = 0;
  REP(i, n) {
    int bj = b[i];
    auto ita = lower_bound(a.begin(), a.end(), bj);
    auto itc = upper_bound(c.begin(), c.end(), bj);
    ans += (ll)(ita - a.begin()) * (ll)(c.end() - itc);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main(){
  int N;
  cin>>N;
  vector<ll> a(N+1);
  for (int i=0;i<N;i++) cin>>a[i];
  ll sum=0;
  for (int x:a){
    sum+=x;
  }
  ll ave=1000*sum/N;
  int ans=N-1;
  for (int i=N-1;i>=0;i--){
    if (abs(1000*a[ans]-ave)>=abs(1000*a[i]-ave)) ans=i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 200010
#define int long long
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#pragma GCC optimize ("Ofast")

// debug_statment ...............................................................................
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug1(int a[], int l, int r) {
	vector<int> temp(a + l, a + r + 1);
	debug(temp);

}


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
// end_debug_statment .......................................................................

signed main(){
    IO;
    // freopen("input.txt", "r", stdin);
    int n;
    string s;
    cin>>n>>s;
    int output =0;
    int r =0, g = 0, b =0;
    for(int i =0 ; i < n ; i ++){
    	r += (s[i]=='R');
    	g += (s[i]=='G');
    	b += (s[i]=='B');
    }
    output = r*g*b;
    for(int i =1; i <= n ; i ++){
    	for(int j = 0; j < n - 2*i; j ++){
    		if(s[j] != s[j + i] && s[j] != s[j + 2*i] && s[j + i] != s[j + 2*i]){
    			output --;
    		}
    	}
    }
    cout<<output;
    cout << setprecision(10) << fixed;
    return 0;
}




Measured memory_bytes: 3660
#include <stdio.h>

#define DNUM 2
#define PNUM 3

int main(void){
	int minP=2000, minD=2000;
	int tmp;
	
	for (int i=0; i<PNUM; i++){
		scanf("%d", &tmp);
		if (tmp < minP) minP = tmp;
	}
	for (int i=0; i<DNUM; i++){
		scanf("%d", &tmp);
		if (tmp < minD) minD = tmp;
	}
	
	printf("%d\n", minD+minP-50);
	
	return 0;
}

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

int dp[101][10001];

int main() {
  int N,W; cin >> N >> W;
  int v[N+1],w[N+1];
  for (int i =1; i<N+1; i++) cin >> v[i] >> w[i];
  
  for (int i =1; i<N+1; i++) {
    for (int j =1; j<W+1; j++) {
      if (j < w[i]) dp[i][j] = dp[i-1][j];
      else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+ v[i]);
    }
  }
  cout << dp[N][W] << endl; 
}



Measured memory_bytes: 7044
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var ans = 0;
            for (int i = 1; i <= N; i++)
            {
                var cnt = i.ToString().Length;
                if (cnt % 2 == 1) ans++;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,d,n,x[3];
	cin>>a>>b>>c>>d>>n;
	x[0]=a*4;
	x[1]=b*2;
	x[2]=c;
	sort(x,x+3);
	if(n==1||x[0]*2<d) cout<<x[0]*n;
	else cout<<d*(n/2)+x[0]*(n%2);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SLEN 10000
int main(){
  int i,m;
  char str[SLEN],*index;
  fgets(str,SLEN,stdin);
  m=atoi(str);
  for(i=0;i<m;i++){
    fgets(str,SLEN,stdin);
    index=str;
    while((index=strstr(index,"Hoshino"))!=NULL){
      index[6]='a';
      index++;
    }
    printf("%s",str);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
     string s;cin >> s;
     for(int i = 0;i<3;i++){
         if(s.at(i)=='1'){
                 cout << 9;
         }else if(s.at(i)=='9'){
                 cout << 1;
         }else{
                 cout << s.at(i)-'0';
         } 
     }cout << endl;
             
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(int argc, char *argv[]){

	char line[256];

	fgets(line, sizeof(line), stdin);
	
	if(line[0] == '9' || line[1] == '9'){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF 99999999 
using namespace std;
 
int main()
{
    int N,M; cin >> N >> M;
    int s = 0;
    for (int i = 0; i < M; i++)
    {
        int a; cin >> a;
        s += a;
    }
    cout << max(N-s,-1) << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}

int main()
{
    std::string word;
    std::string w = "Yes";
    int64_t a,b,c,d,e,f;
    std::cin>> a;
    std::cin>> b;
 
    std::vector< int64_t > list( a );
    c = 0;
 
    for( int i = 0; i < a; i++ )
    {
        std::cin>> list[i];
        c += list[i];
    }
 
    d = c / ( b * 4 );

    if( c % ( b * 4 ) != 0 )
    {
        d += 1;
    }
 
    w = "No";
    e = 0;
    
    for( int i = 0; i < a; i++ )
    {
        if( list[i] >= d )
        {
            e += 1;
        }
    }
 
    if( b <= e )
    {
        w = "Yes";
    }
    
    std::cout<< w;
}


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

int main() {
	long long n;
	string s;
	cin >> n;
	cin >> s;
	long long r, g, b;
    r = 0; g = 0; b = 0;
	for (long long i = 0; i < n; ++i)
	{
		if (s[i] == 'R') r++;
		if (s[i] == 'G') g++;
		if (s[i] == 'B') b++;
	}
	long long dec = 0;
	for (long long i = 1; i < n/2; ++i) // 間隔
	{
		for (long long j = 0; j < n - 2 * i; ++j) // 開始位置
		{
			if (s[j] != s[j + i] && s[j] != s[j + 2 * i] && s[j + i] != s[j + 2 * i]) dec++;
		}
	}
	if (n%2 == 1)
	{
		if(s[0] != s[n/2] && s[0] != s[n-1] && s[n/2] != s[n-1]) dec++;
	}
	cout << r * g * b - dec << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

void swap(int *x, int *y) {
  int tmp = *x;
  *x = *y;
  *y = tmp;
}

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

  for (int k = 0; k <= r; k++) {
    if (k == i + 1) {
      printf("[%d]", a[k]);
    } else {
      printf("%d", a[k]);
    }
    if (k == r) {
      printf("\n");
    } else {
      printf(" ");
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  partition(a, 0, n - 1);
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>

  int main() {

	  int a;
	  int b;
	  int c;

	  std::cin >> a;
	  std::cin >> b;
	  std::cin >> c;

	  if (a == b) {
		  std::cout << c << std::endl;
		  return 0;
	  }
	  else {
		  if (a == c) {
			  std::cout << b << std::endl;
			  return 0;
		  }
		  else {
			  std::cout << a << std::endl;
			  return 0;
		  }
	  }


}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1
#define PI 3.14159265


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

    int n , k;
    cin >> n >> k;
    int arr[n];
    int p;
    for(int i = 0 ; i < n ; i++) {
        cin >> arr[i];
    }
    n -= k;
    k--;

    cout << (n % k == 0 ? n / k + 1 : n / k + 1 + 1) << endl;


    return 0;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<ll> l(m);
  vector<ll> r(m);
  ll ln,rn;
  ln=1;
  rn=100000;
  rep(i,m){
    cin >> l[i] >> r[i];
    ln=max(ln,l[i]);
    rn=min(rn,r[i]);
  }
  if(rn<ln)cout << 0 << endl;
  else cout << rn-ln+1 << endl;
}

Measured memory_bytes: 1792
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

jr = list(itertools.permutations(range(1,N+1),N))

m = 0
P_num = 0
Q_num = 0

#print(P)

for i in jr:
  if list(i) == P:
    P_num = m
  if list(i) == Q:
    Q_num = m
  m += 1
  #print(m)

print(abs(P_num-Q_num))

Measured memory_bytes: 13852
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
ans = 0

for i in range(1,n+1):
    if i%3!=0 and i%5!=0:
        ans+=i

print(ans)

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

using namespace std;

int main() {
  vector<int> A;
  A.reserve(100000);

  int N;
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int M;
  int key;
  int sum = 0;

  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> key;
    if (*lower_bound(A.begin(), A.end(), key) == key) {
      sum++;
    }
  }
  cout << sum << endl;

  return 0;
}


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

template <typename T, typename F>
class SegTree{
  int n; T uni; F f;
  vector<T> dat;
public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n,uni);
  }
  void set(int k, const T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int k, T x) {
    k += n;
    dat[k] += x;
    while(k >>= 1){
      dat[k] = f(dat[2*k],dat[2*k+1]);
    }
  }
  T query(int a, int b) {
    T l = uni, r = uni;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) l = f(l,dat[a++]);
      if(b & 1) r = f(dat[--b],r);
    }
    return f(l,r);
  }
};

int main(){
  int H, W, m;
  cin >> H >> W >> m;
  int h[m], w[m];
  vector<int> numh(H);
  vector<vector<int>> col(H);
  auto f = [](int a, int b){return max(a,b);};
  SegTree<int,decltype(f)> st(W,f,0);
  rep(i,m) {
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
    numh[h[i]]++;
    st.update(w[i],1);
    col[h[i]].push_back(w[i]);
  }
  int ans = 0;
  rep(i,H) {
    int res = numh[i];
    for(auto x : col[i]) st.update(x,-1);
    res += st.query(0,W);
    for(auto x : col[i]) st.update(x,1);
    ans = max(ans,res);
  }
  cout << ans << endl;
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  vector<vector<int32>> to(n-1);
  REP(i,m){
    int32 s,t;
    cin >> s >> t;
    --s;--t;
    to[s].pb(t);
  }
  double ans = n;
  REP(i,n){
    vector<double> dp(n,0);
    FORR(v,n-2,0){
      vector<double> nxt;
      for(auto u : to[v]){
        nxt.pb(dp[u]);
      }
      if(v == i && nxt.size() > 1){
        sort(ALL(nxt));
        nxt.pop_back();
      }
      for(auto x : nxt){
        dp[v] += (x + 1) / nxt.size();
      }
    }
    // REP(j,n)cout << dp[j] << " ";
    // cout << endl;
    ans = min(ans, dp[0]);
  }
  cout << fixed << setprecision(10);
  ANS(ans);
  return 0;
}

Measured memory_bytes: 2560
tp = {}
while 1:
	t,p = map(int,raw_input().split(","))
	if t == p == 0: break
	tp[t] = p
	
plist = sorted([tp[key] for key in tp.keys()],reverse = True)
prank = {}
rank = 1
point = plist[0]
for i in range(len(plist)):
	if plist[i] < point:
		point = plist[i]
		rank += 1
	prank[point] = rank
	
while 1:
	try:
		team = int(raw_input())
	except:
		break
	print prank[tp[team]]

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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int studytime = (60 * (H2 - H1)) + (M2 - M1) - K;
    cout << studytime << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int m,n,k;
	scanf("%d%d%d",&m,&n,&k);
	for(int i=0;i<=n;++i)
		for(int j=0;j<m;++j)
			if((m*i+n*j-2*i*j)==k)
				{printf("Yes");return 0;}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	string s; cin >> s;
	ll len = s.size() - 1;

	if (len % 2 == 1)len--;
	while (len != 0) {
		rep(i, 0, len) {
			if (i == len / 2) {
				cout << len << endl;
				return 0;
			}
			if (s[i] != s[i + len / 2]) {
				break;
			}
		}
		len -= 2;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 998244353
#define SYOU(x) fixed<<setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
using pii=pair<int, int > ;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,x,y;
  string s,w;
  lol a[12000];
  cin >>n>>m;
  s="No";
  lol sum=0;
  for(int i=0;i<n;i++){
    cin >>a[i];
    sum+=a[i];
  }
  sort(a,a+n,greater<lol>());
  if(sum%(4*m)) x=sum/(4*m)+1;
  else x=sum/(4*m);
  if(a[m-1]>=x) cout <<"Yes\n";
  else cout <<"No\n";
      
  return (0);
}


Measured memory_bytes: 256
N,M = map(int,input().split())
AC = [False]*N
wa_cnt = [0]*N
ac_ans = 0
wa_ans = 0
for _ in range(M):
    ps,s = input().split()
    p = int(ps)
    if s == 'WA':
        wa_cnt[p-1] += 1
    if s == 'AC' and AC[p-1] == False:
        wa_ans += wa_cnt[p-1]
        AC[p-1] = True
ac_ans = sum(AC)
print(ac_ans,wa_ans)

Measured memory_bytes: 4596
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

struct point{
    pair<ll,ll> p;
    ll h;
    point(ll x, ll y ,ll H){
        p = make_pair(x,y);
        h = H;
    }
};

int main(){
    ll N;
    cin >> N;
    vector<point> info;
    point ans(0,0,0);
    for(int i = 0; i < N; i++){
        ll x,y,h;
        cin >> x >> y >> h;
        point temp(x,y,h);
        info.emplace_back(temp);
    } 
    for(ll X  = 0; X <= 100 ; X++){
        for(ll Y = 0; Y <= 100; Y++){
            ll H = -1;
            ll min_d = INF;
            bool flag = true;
            for(int i = 0; i < N; i++){
                ll h = info[i].h;
                ll x = info[i].p.first;
                ll y = info[i].p.second;
                ll D = abs(x - X) + abs(y - Y);
                if(h <= 0) min_d = min(min_d , D);
                else{
                    if(H < 0) H = h + D;
                    else if( H != h + D){
                        flag = false;
                        break;
                    } 
                }
            }
            if(flag && H - min_d <= 0){
                cout << X << " " << Y << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256