akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
struct UnionFind {
  vector<int> par;  // parent
  vector<int> num;  // # of node included in the same group
  UnionFind(int n) : par(n), num(n) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
      num[i] = 1;
    }
  }
  int root(int x) {
    if (num[x] <= num[par[x]]) {
      num[x] = num[par[x]];
    } else {
      num[par[x]] = num[x];
    }
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[min(rx, ry)] = max(rx, ry);
    num[rx] += num[ry];
    num[ry] = num[rx];
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { return num[par[x]]; }
};
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  int m;
  cin >> n >> m;
  vector<P> a(m);
  REPe(e, a) {
    cin >> e.first >> e.second;
    e.first--;
    e.second--;
  }
  reverse(all(a));
  vecll ans(m + 1, 0);
  UnionFind uf(n);
  REP(i, m) {
    if (uf.same(a[i].first, a[i].second)) {
      // cout << a[i].first << "," << a[i].second << ": "
      //      << (ll)uf.size(a[i].first) << " " << (ll)uf.size(a[i].second)
      //      << "->";
      ans[i + 1] = ans[i];
      uf.unite(a[i].first, a[i].second);
      // cout << (ll)uf.size(a[i].first) << " " << (ll)uf.size(a[i].second)
      //      << endl;
    } else {
      // cout << a[i].first << "," << a[i].second << ": "
      //      << (ll)uf.size(a[i].first) << " " << (ll)uf.size(a[i].second)
      //      << "->";
      ans[i + 1] = ans[i] + (ll)uf.size(a[i].first) * (ll)uf.size(a[i].second);
      uf.unite(a[i].first, a[i].second);
      // cout << (ll)uf.size(a[i].first) << " " << (ll)uf.size(a[i].second)
      //      << endl;
    }
  }
  reverse(all(ans));
  // REP(i, n) { cout << uf.size(i) << endl; }
  ll tot = (ll)n * (ll)(n - 1) / 2;
  // cout << tot << endl;
  FOR(i, 1, m + 1) { cout << tot - ans[i] << endl; }
}
//////////////////////////////////////////////


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

using namespace std;

int main(){
  int n = 10;
  vector<int> a;

  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  sort(a.begin(), a.end(), greater<int>());

  cout << a[0] << endl;
  cout << a[1] << endl;
  cout << a[2] << endl;
  
  return 0;
}

Measured memory_bytes: 3140
object Main extends App {
  val n = io.StdIn.readLine.split(' ').map(_.toInt)
  val x = n(0)
  val y = n(1)
  
  for(i <- 0 to (x+1)/2.toInt) {
    val j = x - i
    if(i*4 + j*2 == y || i*2 + j*4 == y) {
      println("Yes")
      sys.exit
    }
  }
  println("No")
}

Measured memory_bytes: 54812
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int d, n;in(d),in(n);
  if (n==100) n++;
  if (d==1) n*=100;
  if (d==2) n*=10000;
  print(n);
  return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
string s[1010];
signed main() {
	int n,ans=0;
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		if (s[i] == "E869120")ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
int main(int, char**) {
  int N; cin >> N;
  int V[51];
  int C[51];
  for (int i = 0; i < N; ++i) cin >> V[i];
  for (int i = 0; i < N; ++i) cin >> C[i];
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (V[i] > C[i]) ans += (V[i] - C[i]);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int N,a,b;
    long long res=0;

    cin >> N;

    vector<int> A(N);
    vector<int> B(N);
    vector<vector<int>> v(N,vector<int> (2,0));

    for (int i=0;i<N;i++){
        cin >> a >> b ;
        A[i]=a;
        B[i]=b;
        v[i][0]=i;
        v[i][1]=a+b;
    }


    sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});


    for (int i=0;i<N;i++){
        int k = v[i][0];
        if (i%2==0){
            res += A[k];
        }
        else {
            res -= B[k];
        }
    }
    cout << res << endl;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  bool f = false;
  for(int i = 1; i <= 10000; i++) {
    if(i*a % b == c) f = true;
  }
  cout << (f ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int l[100];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> l[i];
	sort(l, l + n);
	
	int s = 0;
	for (i = 0; i < n - 1; i++) s += l[i];
	if (s > l[n - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	int N;
	char S[101];
	scanf("%d", &N);
	scanf("%s", &S);

	int tmp = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') { tmp++; }
		if (S[i] == 'D') { tmp--; }
		ans = Max(ans, tmp);
	}

	printf("%d\n", ans);



#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) a[i] -= i + 1;
    sort(all(a));
    ll mid = (a[n / 2] + a[(n - 1) / 2]) / 2;
    ll ans = 0;
    rep(i, 0, n) ans += abs(a[i] - mid);
    cout << ans << endl;
}


Measured memory_bytes: 1792
def resolve():
    N = int(input())
    L = list(map(int, input().split()))
    count = 0
    flag = False
    while True:
        for i in range(N):
            if L[i] % 2 == 0:
                L[i] = L[i] // 2
            else:
                flag = True
                break

        if flag:
            break
            
        count += 1
        
    
    print(count)
    
if __name__ == "__main__":
    resolve()

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


 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int x,y;
  cin>>x>>y;
  if(y&1){cout<<"No";}
  else{
   int min = x*2;
   int max = x*4;
   if(y <= max && y >= min ){
       cout<<"Yes";
   }else{
       cout<<"No";
   }
  }
}

Measured memory_bytes: 3644
from typing import List

def gacha_kinds(N: int, S_i: List[str]) -> int:
    kinds = set(S_i)
    return len(kinds)

if __name__ == '__main__':
    N = int(input())
    S_i = [input() for i in range(N)]

    res = gacha_kinds(N, S_i)
    print(res)


Measured memory_bytes: 36704
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int r,c,n;
struct P{
    int x,y;
};
struct L{
    P a,b;
};
bool onEdge(P a)
{
    return a.x==0||a.x==r||a.y==0||a.y==c;
}
int main()
{
    cin>>r>>c>>n;
    vc<L> all(n);
    vc<P> D,U,L,R;
    for(int i=0;i<n;i++)
    {
        cin>>all[i].a.x>>all[i].a.y>>all[i].b.x>>all[i].b.y;
        if(onEdge(all[i].a)&&onEdge(all[i].b))
        {
            if(all[i].a.x==0)
                U.push_back(P{all[i].a.y,i});
            else if(all[i].a.x==r)
                D.push_back(P{all[i].a.y,i});
            else if(all[i].a.y==0)
                L.push_back(P{all[i].a.x,i});
            else if(all[i].a.y==c)
                R.push_back(P{all[i].a.x,i});
            if(all[i].b.x==0)
                U.push_back(P{all[i].b.y,i});
            else if(all[i].b.x==r)
                D.push_back(P{all[i].b.y,i});
            else if(all[i].b.y==0)
                L.push_back(P{all[i].b.x,i});
            else if(all[i].b.y==c)
                R.push_back(P{all[i].b.x,i});
        }
    }
    sort(D.begin(),D.end(),[&](P i,P j){return i.x>j.x;});
    sort(L.begin(),L.end(),[&](P i,P j){return i.x>j.x;});
    sort(R.begin(),R.end(),[&](P i,P j){return i.x<j.x;});
    sort(U.begin(),U.end(),[&](P i,P j){return i.x<j.x;});
    stack<int> cc;
    for(auto u:D) 
    {
        if(!cc.empty()&&cc.top()==u.y) cc.pop();
        else cc.push(u.y);
    }
    for(auto u:L) 
    {
        if(!cc.empty()&&cc.top()==u.y) cc.pop();
        else cc.push(u.y);
    }
    for(auto u:U) 
    {
        if(!cc.empty()&&cc.top()==u.y) cc.pop();
        else cc.push(u.y);
    }
    for(auto u:R) 
    {
        if(!cc.empty()&&cc.top()==u.y) cc.pop();
        else cc.push(u.y);
    }
    if(cc.empty()) cout<<"YES\n";
    else cout<<"NO\n";


}

Measured memory_bytes: 4056
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	long long N, A, B;
	cin >> N >> A >> B;
	
	long long  ans=0;

	if(A>B){
		ans = 0;
	}else if(N==1){
		if(A==B){
			ans = 1;	
		}else{
			ans = 0;
		}
	}else{
		ans = (B-A)*(N-2)+1;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  string S;
  cin >> S;
  if (S=="SSS") {
    cout << 0 << endl;
  }
  else if (S=="SRS" || S=="RSR" || S=="SSR" || S=="RSS") {
    cout << 1 << endl;
  }
  else if (S=="RRR") {
    cout << 3 << endl;
  }
  else {
    cout << 2 << endl;
  }
}
                                  


Measured memory_bytes: 3624
import bisect
#input
n = int(input())
list1 = list(map(int,input().split()))
list1.sort()

cout = 0 #最終的な三角形の個数

for i in range(n-2): #リストから三角形が作れなくなるまでループ
	o = list1[i] #1辺を確定、そのままリストから消去
	for j in range(i+1,n-1): #残りの二辺のループ(iで使っている次の値から)
		p = list1[j] #２辺目を確定

		b = o+p -1 #昇順にソートしてあるので、c<a+b条件のみ計算

		d = bisect.bisect_right(list1[j+1:],b) #３辺目を確定
		
		cout += d

print(cout)

Measured memory_bytes: 53068
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
 //    String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);

//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);


String res=nyu.replaceAll(" ","");

if(Integer.parseInt(res)%4==0){
//double res=Math.ceil((AB)/2);

System.out.println("YES");
//}else if((C-B)<A){
//System.out.println("safe");

}else{
System.out.println("NO");

}




	}
}

Measured memory_bytes: 21844
import math

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt1, cnt2 = 0, 0
for i in range(N):
    if a[i] > b[i]:
        cnt1 += a[i] - b[i]
    elif a[i] < b[i]:
        cnt2 += math.ceil((b[i]-a[i])/2)

cnt = sum(b) - sum(a)
if cnt1 <= cnt and cnt2 <= cnt:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 10512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();

            int ans = s.length();
            for (int i = 0; i < 26; i++) {
                char c = (char) ('a' + i);
                String[] tmp = s.split("" + c);

                int max = 0;
                if (tmp.length > 0) {
                    for (String t : tmp) {
                        max = Math.max(max, t.length());
                    }
                }

                ans = Math.min(ans, max);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

bool isprime(int a);

int main() {
	int i, n, a, count = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a;
		if (isprime(a) == true)count++;
	}
	cout << count << endl;
	return 0;
}

bool isprime(int a) {
	int i;
	bool flag;
	for (i = 2; i < sqrt(a); i++) {
		if (a % i == 0)break;
	}
	if (i > sqrt(a))return true;
	else return false;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




int main() {
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(i%3==0)continue;
        if(i%5==0)continue;
        ans+=i;
    }

    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var n, m, l int
	fmt.Scan(&n, &m, &l)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}
	b := make([][]int, m)
	for i := range b {
		b[i] = make([]int, l)
		for j := range b[i] {
			fmt.Scan(&b[i][j])
		}
	}
	// fmt.Println(a)
	// fmt.Println(b)

	c := make([][]int, n)
	for i := range c {
		c[i] = make([]int, l)
	}
	// fmt.Println(c)

	for i := 0; i < n; i++ {
		for j := 0; j < l; j++ {
			for k := 0; k < m; k++ {
				c[i][j] += a[i][k]*b[k][j]
			}
		}
	}
	// fmt.Println(c)
	for i := 0; i< n; i++ {
		for j := 0; j < l; j++ {
			if j == l - 1 {
				fmt.Printf("%d\n", c[i][j])
			} else {
				fmt.Printf("%d ", c[i][j])
			}
		}
	}
}


Measured memory_bytes: 2596
#include <cstdio>
#define MAX (1000000)
using namespace std;

bool prime[MAX + 1];

int main()
{
	prime[0] = prime[1] = false;
	for (int i = 2; i <= MAX; i++){
		prime[i] = true;
	}
	for (int i = 2; i * i <= MAX; i++){
		for (int j = i * i; j <= MAX; j += i){
			prime[j] = false;
		}
	}
	
	int n;
	while (scanf("%d", &n), n){
		int num = 0;
		for (int i = 2; i <= n; i++){
			if (prime[i]){
				int sum = 0;
				int j = i;
				while (1){
					if (prime[j]){
						sum += j;
						if (sum == n){
							num++;
							break;
						}
						else if (sum > n){
							break;
						}
					}
					j++;
				}
			}
		}
		
		printf("%d\n", num);
	}
	
	return 0;
}

Measured memory_bytes: 2004
L, R = list(map(int, input().split()))

a = 0
ans = 10 ** 9
r = min((L + 2018), R)

for i in range(L, r):
    n = min((i + 2019), R)
    for j in range(i + 1, n + 1):
        a = (i * j) % 2019
        # print(a)
        ans = min(a, ans)
print(ans)

Measured memory_bytes: 3060
open Scanf ;;
open Printf ;;

let divisors n =
  let rec f i =
    if i * i > n then []
    else if n mod i = 0 then i :: f (i + 1)
    else f (i + 1)
  in
  f 1
  ;;

let min_list a = List.fold_left min max_int a ;;

let () =
  let n = scanf "%d" (fun x -> x) in
  let ans = divisors n |> List.map (fun x -> x + n / x - 2) |> min_list in
  printf "%d\n" ans
  ;;




Measured memory_bytes: 640
import java.util.Scanner

fun main(args: Array<String>){
    val scanner = Scanner(System.`in`)
    val quantity = scanner.nextInt()
    val result = D0427B(
                    quantity   = quantity // N
                   ,valueArray = Array(quantity){ scanner.nextInt() }
                   ,costArray  = Array(quantity){ scanner.nextInt() }
                 ).judge()
    println(result)
}

class D0427B(
  val quantity: Int
 ,val valueArray: Array<Int>
 ,val costArray:  Array<Int>
){
    val profitabilityArray = Array(quantity){ valueArray[it] - costArray[it] }
    fun judge(): Int{
        return profitabilityArray.filter { it > 0 }.sum()
    }
}

Measured memory_bytes: 31644
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    dp = [True] * (10 ** 6 + 1)
    counter = Counter(A)

    A.sort()
    ans = 0
    for a in A:
        if dp[a]:
            if counter[a] == 1:
                ans += 1
            i = a
            while i <= 10 ** 6:
                dp[i] = False
                i += a
    
    print(ans)

if __name__ == '__main__':
    solve()


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

int main()
{
	int a,b,c,d,s,s2,y,y2;
	cin>>a>>b>>c>>d;
	
	s=c/b;
	y=c%b;
	if(y!=0)
		s++;
	
	s2=a/d;
	y2=a%d;
	if(y2!=0)
		s2++;
	
	if(s>s2)
	{
		cout<<"No";
	}
	else
	{
		cout<<"Yes";
	}
	return 0;
}

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  int A[H][W];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }
  int ans = 100000000;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int s = 0;
      for(int k = 0; k < H; k++){
        if(k == i) continue;
        for(int l = 0; l < W; l++){
          if(l == j) continue;
          s += min(abs(i - k), abs(j - l)) * A[k][l];
        }
      }
      ans = min(ans, s);
    }
  }
  
  cout << ans 
  << "\n";
  return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>
int main()
{
  int a,b,c,d=0,x=0;
  
  scanf("%d%d%d",&a,&b,&c);

  for(x=a;x<=b;x++)
    {
      if(c%x==0)d++;
    }

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

  return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(K<=A)
  {
    cout << K << endl;
  }
  else if(A<K&&K<=A+B)
  {
    cout << A << endl;
  }
  else
  {
    cout << A-C+(A+B+C-K) << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

int main(int argc, char* pArgv[])
{
  std::string s, t, u;
  int a = 0, b = 0;
  std::cin >> s >> t;
  std::cin >> a >> b;
  std::cin >> u;

  if (u == s) {
    a --;
  } else {
    b --;
  }
  std::cout << a << " " << b << std::endl;
  return 0;
}



Measured memory_bytes: 256
import heapq


XYZK = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

hq = []
pushed = []
heapq.heappush(hq, (-(A[0]+B[0]+C[0]), 0, 0, 0))
for _ in range(XYZK[3]):
    a = heapq.heappop(hq)
    print(-a[0])
    i, j, k = a[1:]
    if i < XYZK[0]-1:
        if not (i+1, j, k) in pushed:
            heapq.heappush(hq, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
            pushed.append((i+1, j, k))
    if j < XYZK[1]-1:
        if not (i, j+1, k) in pushed:
            heapq.heappush(hq, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
            pushed.append((i, j+1, k))
    if k < XYZK[2]-1:
        if not (i, j, k+1) in pushed:
            heapq.heappush(hq, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
            pushed.append((i, j, k+1))



Measured memory_bytes: 4468
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
int main(void){
  int h,w,k;
  scanf("%d%d%d",&h,&w,&k);
  char A[h][w];
  for(int i=0;i<h;i++){
    scanf("%s",A[i]);
  }
  
  int ans=0;
 
  for(int bit1=0;bit1<(1<<h);bit1++){//行の評価
    for(int bit2=0;bit2<(1<<w);bit2++){//列の評価
      int count=0;
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if((bit1 & (1<<i)) || (bit2 & (1<<j))){
            continue;
          }
          if(A[i][j]=='#'){
            count++;
          }
 
        }
      }
 
      if(count==k){
        ans++;
      }
    }
  }
 
  printf("%d\n",ans);
 
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  /* code start */

  string str;
  cin >> str;
  if (str == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  /* code end   */
  return 0;
}

/* === 2 dimention arr sort ===

struct data{
        int val1;
        int val2;
};

// functions for sort judge
bool comp1(data x, data y){
        return x.day > y.day ? true : false;
}
bool comp2(data x, data y){
        return x.rew > y.rew ? true : false;
}

// How to use
        vector<data> arr;
        arr.push_back({_data1,_data2});
        sort(arr.begin(), arr.end(),comp1);
*/

// === GCD function ===
/* how to use
__gcd(a,b);
*/


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

public class Main{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
  int a = s.nextInt();
  int b = s.nextInt();
  int result =0;
  
  if(a>b){
  result = a + Math.max(a-1,b);
  }
  else if(b>a){
    result = b + Math.max(a,b-1);
  }
  else{
  result = 2*a;
  }
  
  System.out.print(result);
  
}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if (H%h==0 && W%w==0) {
		cout<<"No\n"<<endl;
		return 0;
	}
	
	cout<<"Yes\n";
	
	const int T=501;
	rep(i,0,H) rep(j,0,W) {
		if (H%h!=0) {
			if (i%h==0) {
				cout<<T*(h-1)-1;
			} else {
				cout<<-T;
			}
		} else {
			if (j%w==0) {
				cout<<T*(w-1)-1;
			} else {
				cout<<-T;
			}
		}
		cout<<" \n"[j+1==W];
	}
}


Measured memory_bytes: 1536
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let n = scanner.NextI32()
    let k = scanner.NextI32()
    let _ = scanner.ArrayI32(n)
    let a = (n-1) / (k-1)
    if (n-1) % (k-1) = 0 then 0 else 1
    |> (fun x -> x + a)
    |> printfn "%i"

    0


Measured memory_bytes: 25816
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int flag = 1;
	long i, N, t_old, t_new, x_old, x_new, y_old, y_new, dt, dx, dy;
	scanf("%ld",&N);
	t_old = x_old = y_old = 0;
	for(i=1; i<=N;i++)
	{
		scanf("%ld %ld %ld", &t_new, &x_new, &y_new);
		dt = t_new-t_old;
		dx = (x_new - x_old > 0)? x_new-x_old:x_old-x_new;
		dy = (y_new - y_old > 0)? y_new-y_old:y_old-y_new;
		if(dx+dy <= dt)
		{
			if((dt-(dx+dy))%2 != 0)
			{
				flag = 0;
				break;
			}
			else
			{
				x_old = x_new;
				y_old = y_new;
				t_old = t_new;
			}
		}
		else
		{
			flag = 0;
			break;
		}
	}
	printf("%s\n",(flag == 1)? "Yes":"No");
	return 0;
}



Measured memory_bytes: 128
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * AtCoder Beginner Contest 129<br>
 * B - Balance<br>
 * <br>
 * <a href="https://atcoder.jp/contests/abc129/tasks/abc129_b">AtCoderへのリンク</a><br>
 */
public class Main {

    /**
     * エントリポイント
     */
    public static void main(String[] args) {
        // 入力
        Model m = input(System.in);
        // 演算
        int result = proc(m);
        // 出力
        System.out.println(result);
    }

    /**
     * 入力モデル
     */
    static class Model {
        /** オモリの数 */
        int N;
        /** オモリの重さリスト */
        List<Integer> list = new ArrayList<Integer>();
    }

    /**
     * 入力値より入力モデルを作成する
     */
    private static Model input(InputStream in) {
        Model m = new Model();
        try (Scanner sc = new Scanner(in)) {
            String[] line1 = sc.nextLine().split(" ");
            String[] line2 = sc.nextLine().split(" ");

            m.N = Integer.parseInt(line1[0]);
            for (String str : line2) {
                m.list.add(Integer.parseInt(str));
            }
        }
        return m;
    }

    /**
     * 演算を行う
     */
    static int proc(final Model m) {
        //int result = 0;
        // TODO:実装する
        
        int sum = 0;
        int s1 = 0;
        int s2 = 0;
        // intの最大許容数をセット
        int min = Integer.MAX_VALUE;
        
        // 全要素合計算出
        for (int i=0; i<m.list.size(); i++) {
            sum += m.list.get(i);
        }
        
        for (int i=0; i<m.N; i++) {
            s1 = 0;
            s2 = 0;
            for (int j=0; j<=i; j++) {
                s1 += m.list.get(j);
            }
            s2 = sum - s1;
            if (min > Math.abs(s1 - s2)) {
                min = Math.abs(s1 - s2);
            }
        }

        return min;
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
#include <string>
#include <cstdint>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <unordered_map>

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Int int_fast64_t

int main()
{
    FAST_IO;

    string s,t;
    cin>>s >> t;
    Int count=0;
    for(Int i=0;i<s.length();++i) {
        if(s[i]!=t[i]) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  int H, W;
  cin >> H >> W;
  int dp[1010][1010];
  char grid[1010][1010];
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) cin >> grid[i][j];
  }
  // dp初期化
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (grid[i][j] == '#') {
        dp[i][j] = -1;
      } else {
        dp[i][j] = 0;
      }
    }
  }
  dp[1][1] = 1;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (dp[i][j] == -1) continue;
      if (dp[i][j + 1] != -1) dp[i][j + 1] += dp[i][j] % MOD;
      if (dp[i + 1][j] != -1) dp[i + 1][j] += dp[i][j] % MOD;
    }
  }
  cout << dp[H][W] % MOD << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;


int main(){
    
    lint n,k;
    cin >> n >> k;
    cout << min(n%k, abs(k-n%k)) << endl;
    
    return 0;
}

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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 65, M = 2505;

struct E {
    int to, w, cost;
    E(int to=0, int w=0, int cost=0):to(to), w(w), cost(cost) {}
};

LL dis[N][M + 50];
vector<E> G[N];

struct node {
    int u, s;
    LL t;
    node(int u=0, int s=0, LL t=0): u(u), s(s), t(t) {}
    bool operator > (const node &other) const {
        return t > other.t;
    }
};

int n, m, s;
int c[N], d[N];





void solve() {
    scanf("%d%d%d", &n, &m, &s);
    s = min(s, M-1);
    for (int i=0; i<m; ++i) {
        int u, v, a, b;
        scanf("%d%d%d%d", &u, &v, &a, &b);
        G[u].emplace_back(v, b, a);
        G[v].emplace_back(u, b, a);
    }

    for (int i=1; i<=n; ++i) {
        scanf("%d%d", &c[i], &d[i]);
    }

    for (int i=1; i<=n; ++i) {
        memset(dis[i], 0x3f3f3f3f, sizeof (dis[i][0]) * (M + 1));
    }

    dis[1][s] = 0;
    priority_queue<node, vector<node>, greater<node>> q;
    q.emplace(1, s, 0);
    while (!q.empty()) {
        auto now = q.top(); q.pop();
        int u = now.u, s = now.s;
        LL t = now.t;
        if (t > dis[u][s])
            continue;
        int ns = min(M-1, s + c[u]);
        if (dis[u][ns] > t + d[u]) {
            dis[u][ns]= t+ d[u];
            q.emplace(u, ns, dis[u][ns]);
        }

        for (const auto & e : G[u]) {
            int v = e.to, w = e.w, cost = e.cost;
            int ns = s - e.cost;
            if (ns >= 0 && dis[v][ns] > t + w) {
                dis[v][ns] = t + w;
                q.emplace(v, ns, dis[v][ns]);
            }
        }
    }

    for (int i=2; i<=n; ++i) {
        printf("%lld\n", *min_element(dis[i], dis[i] + M));
    }
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
const int mod = 1e9+7;
const int MAX_V = 100010;
struct edge {int to, cost;};
vector<edge> tree[MAX_V];
long long depth[MAX_V];

void dfs(int v, int p, long long d) {
  depth[v] = d;
  for(auto &e: tree[v]) {
    if(e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}

int main() {
  int N; cin >> N;
  for(int i = 0; i < N-1; i++) {
    int a, b, c; cin >> a >> b >> c; a--, b--;
    tree[a].push_back({b, c});
    tree[b].push_back({a, c});
  }

  int Q, K; cin >> Q >> K; K--;
  dfs(K, -1, 0);

  for(int i = 0; i < Q; i++) {
    int x, y; cin >> x >> y; x--, y--;
    cout << depth[x] + depth[y] << endl;
  }
}


Measured memory_bytes: 12800
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 K = 0;
	SINT32 cnt = 0;

	cin >> N;
	cin >> K;

	vector<SINT32> DATA(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];
	}

	while (1) {
		cnt++;
		N = N-K;
		if (N <= 0) {
			break;
		}
		N++;
	}
	cout << cnt << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 640
#include <iostream>

int main(){
	int a, b;
	std::cin >> a >> b;
	if (a < b){
		std::cout << "a < b\n";
	}
	else if (a > b){
		std::cout << "a > b\n";
	}
	else{
		std::cout << "a == b\n";
	}

	return 0;
}



Measured memory_bytes: 3028
void main() {
	auto N = ri;
	int[] d;
	foreach(_; 0..N) d ~= ri;
	d.sort().uniq.array.length.writeln;
 }

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define INFTY 100000000

void dijkstra(void);

int n,G[N][N];

int main(){
  int i,j,u,v,k,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j]=INFTY;
    }
  }
  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d%d",&v,&c);
      G[u][v] = c;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int i,u,v,d[N],p[N],color[N],min;
  for(i = 0;i < n;i++){
    p[i]=-1;
    color[i]=WHITE;
    d[i]=INFTY;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1){
    min = INFTY;

    for(i = 0;i < n;i++){
      if(color[i] != BLACK && d[i] < min){
        min = d[i];
        u = i;
      }
    }
    if(min == INFTY)break;
    color[u]= BLACK;

    for(v = 0;v < n;v++){
      if(color[v] != BLACK && G[u][v] != INFTY && G[u][v]+d[u] < d[v]){
        d[v] = G[u][v] + d[u];
        p[v] = u;
        //printf("%d \n",d[v]);
        color[v] = GRAY;
      }
    }
  }
  for(v = 0;v < n;v++){
    printf("%d %d\n",v,d[v]);
  }
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    string A = in<string>(),B = in<string>(),C = in<string>();
    int answer = 0;
    REP(i,N){
        if(A[i]!= B[i] && B[i]!= C[i] && C[i] != A[i]){
            answer+=2;
        }else if(A[i]== B[i] && B[i] == C[i]){
            answer += 0;
        }else{
            answer += 1;;
        }
    }
    cout << answer << "\n";
}

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

int main()
{
  // Input
  int N;
  std::cin >> N;
  assert(1 <= N and N <= 100);
  std::vector<int> b(1 + N);
  for (int i = 1; i <= N; ++i) {
    std::cin >> b[i];
    assert(1 <= b[i] and b[i] <= N);
  }

  // Main part
  std::vector<int> answer;
  while (b.size() > 1) {
    bool hit = false;
    for (int i = b.size() - 1; i >= 1; --i) {
      if (b[i] == i) {
        hit = true;
        answer.push_back(i);
        b.erase(b.begin() + i);
        break;
      }
    }
    if (not hit) {
      answer = {};
      break;
    }
  }

  // Output
  if (answer.size() >= 1) {
    for (int i = answer.size() - 1; i >= 0; --i)
      std::cout << answer[i] << std::endl;
  } else {
    std::cout << "-1" << std::endl;
  }

  return 0;
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define spc        ' '
#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define pb         push_back
#define mp         make_pair
#define GCD(x,y)   __gcd(x,y)
#define PI         2*acos(0.0)
#define lb         lower_bound
#define bs         binary_search
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;   vector<long long> v,v1;
    
    string s;
    cin>>s;
    n=s.length();
    for(i=0;i<n;i++)
    {
        cnt+=s[i]-'0';
    }
    if(cnt%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    /*freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);*/

    ll tt;
    /*cin>>tt;
    while(tt--)*/
        solve();

    return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include<string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int N = S.size();

    int sum =0;
    int c =0;
    for(int i=0;i<N;i++){
        if(S[i] == '1'){
            if(i !=0 && sum < 0){
                c++;
            }
            sum ++;
        }
        else{
            if(i !=0 && sum > 0){
                c++;
            }
            sum --;
        }
    }

    cout << 2 * c <<endl;

    return 0;

}

Measured memory_bytes: 512