akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
constexpr int INF = 1e9;

struct Edge {
    int to, cap, rev;
    Edge(int t, int c, int r) : to(t), cap(c), rev(r){}
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;



class Flow {
    public:
        Flow(int v){
            mGraph.resize(v);
            mUsed.assign(v,false);
            mVert = v;
        }
        void add_edge(int from, int to, int cap){
            mGraph[from].emplace_back(to,cap,mGraph[to].size()); // directed
            mGraph[to].emplace_back(from,0,mGraph[from].size()-1);
        }

        // use after add all edges
        int bipartite_matching(int x, int y){
            int start = max(x,y)*2;
            int end = max(x,y)*2 + 1 ;
            for(int i = 0; i < x; ++i) add_edge(start, i, 1);
            for(int i = 0; i < y; ++i) add_edge(i+x, end, 1);
            return max_flow(start,end);
        }

        // ford-fulkerson
        int dfs(int v, int t, int f){
            if(v==t) return f;
            mUsed[v] = true;
            for(auto &e : mGraph[v]){
                if(!mUsed[e.to] && e.cap > 0){
                    int d = dfs(e.to,t,min(f,e.cap));
                    if(d > 0){
                        e.cap -= d;
                        mGraph[e.to][e.rev].cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }

        int max_flow(int s,int t){
            int flow = 0;
            while(true){
                mUsed.assign(mVert,false);
                int f = dfs(s,t,INF);
                if(f==0) break;
                flow += f;
            }
            return flow;
        }
        // verify : GRL_6_A


    private:
        Graph mGraph;
        vector<bool> mUsed;
        int mVert;

};

int main(){
    int X,Y,E,u,v,c;
    cin >> X >> Y >> E;
    Flow f(max(X,Y)*2+2);
    for(int i=0; i < E; ++i){
        cin >> u >> v;
        f.add_edge(u,v+X,1);
    }
    cout << f.bipartite_matching(X,Y) << '\n';
    return 0;
}




Measured memory_bytes: 3236
#include <iostream>
#include <string>
int INPUT[4];

bool solve(int i, int sum, std::string str) {
  if (i == 4) {
    if (sum == 7) { std::cout << str << "=7" << std::endl; return true; }
    else return false;
  }
  if (solve(i+1, sum + INPUT[i], str + '+' + std::to_string(INPUT[i]))) return true;
  if (solve(i+1, sum - INPUT[i], str + '-' + std::to_string(INPUT[i]))) return true;
  return false;
}

int main() {
  char tmp;
  for (int i = 0; i < 4; i++) {
    std::cin >> tmp;
    INPUT[i] = tmp - '0';
  }
  solve(1, INPUT[0], std::to_string(INPUT[0]));
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int times(long x, int n){
    if(x < 10){
        n++;
        return n;
    }
    return times(x / 10, n + 1);
}

long sum(vector<long> &num, vector<int> &plus, int n){
    long ans = 0;
    long sump = 0;
    if (n == 0){
        sump = num.at(0);
        for(int i = 0; i < plus.size(); i++){
            if (plus.at(i) == 0){
                sump *= 10;
                sump += num.at(i + 1);
            }
            else{
                ans += sump;
                sump = num.at(i + 1);
            }
        }
        ans += sump;
        return ans;
    }
    if (n > 0){
        plus.at(plus.size() - n) = 0;
        long i = sum(num, plus, n - 1);
        ans += i;
        plus.at(plus.size() - n) = 1;
        i = sum(num, plus, n - 1);
        ans += i;
        return ans;
    }
}

int main() {
    string S;
    cin >> S;
    long s = stol(S);
    int n = times(s, 0);
    vector<long> num(n);
    for (int i = n - 1; i > -1; i--){
        num.at(i) = s % 10;
        s /= 10;
    }
    vector<int> plus(n - 1, 0);
    int a = plus.size();
    long ans = sum(num, plus, a);
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

int v[1001];
ll N;
ll mod = 1e9+7;
bool b[1001];

int main(){
    cin >> N;
    for(int i=2;i<=1000;i++) b[i] = true;
    for(int i=2;i<=1000;i++){
        if(!b[i]) continue;
        for(int j=2;j*i<=1000;j++){
            b[i*j] = false;
        }
    }
    ll t;
    vector<ll> v;
    for(int i=2;i<=1000;i++){
        if(!b[i]) continue;
        t = N;
        ll s = 0;
        while(t > 0){
            t /= i;
            s += t;
        }
        v.push_back(s);
    }
    ll sum = 1;
    for(int i=0;i<v.size();i++){
        sum *= (v[i] + 1);
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ans=5+n//(min(a,b,c,d,e))
if n%min(a,b,c,d,e) == 0:
  ans -= 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD 1000000007
using namespace std;
int main()
{
    fio();
    int n;
    cin>>n;
    int a[n+2];
    a[0]=0;
    a[n+1]=0;
    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n+1;i++)
        sum+=abs(a[i]-a[i-1]);
    for(int i=1;i<=n;i++)
    {
        cout<<sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
    }
}

Measured memory_bytes: 1664
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, Dist[105];
vector <int> Graph[105];

int BFS(){
  fill(Dist, Dist + N + 1, -1);
  queue <int> que; que.push(1);
  Dist[1] = 0;
  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int i = 0; i < Graph[Q].size(); i++){
      int next = Graph[Q][i];
      if (Dist[next] != -1) continue;
      Dist[next] = Dist[Q] + 1;
      que.push(next); 
    }
  }  
  return 0;
}

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    int U, K; scanf("%d%d", &U, &K);
    for (int j = 0; j < K; j++){
      int V; scanf("%d", &V);
      Graph[U].push_back(V);
    }
  }
  BFS();
  for (int i = 1; i <= N; i++){
    printf("%d %d\n", i, Dist[i]);
  }
  
  return 0;
}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
const int m=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}



int32_t main(){
	
	//FIO();
	int n,x,t;cin>>n>>x>>t;
	int ans=(n+x-1)/x*t;
	cout<<ans<<"\n";
		
	


	return 0;
		
}


			

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
void solve(){
  long long mod,ans=0;
  mod=1e9+7;
  int n;
  cin>>n;
  vector<long long> v(n);
  vector<long long> sum(n);
  cin>>v[0];
  sum[0]=v[0];
  for (int i=1 ;i<n;i++){
    cin>>v[i];
    sum[i]=(sum[i-1]+v[i]);
  }
  long long k=sum[n-1];
  for(int i=0;i<n;i++){
    ans+=((v[i]%mod)*((k-sum[i])%mod))%mod;
    ans=ans%mod;
  }
  cout<<(ans%mod)<<endl;
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

bool is_match(vector<string> &ns, vector<string> &ms, int i_, int j_, int m){
  for(int i = 0;i<m;++i){
    for(int j = 0;j<m;++j){
      if(ns[i+i_][j+j_] != ms[i][j]){
	return false;
      }
    }
  }
  return true;
}

string matching(vector<string> &ns, vector<string> &ms, int n, int m){
  for(int i = 0;i < n-m+1;++i){
    for(int j = 0;j < n-m+1;++j){
      if(!is_match(ns, ms, i, j, m)){
	continue;
      }
      else return "Yes";
    }
  }
  return "No";
}

int main(void)
{
  int n,m;
  vector<string> ns, ms;
  cin >> n >> m;
  for(int i = 0;i < n;++i){
    string buf;
    cin >> buf;
    ns.push_back(buf);
  }
  for(int i = 0;i < m;++i){
    string buf;
    cin >> buf;
    ms.push_back(buf);
  }
  cout << matching(ns, ms, n, m) << endl;
  /*
    for(int i = 0;i < n;++i){
    cout << ns[i] << endl;
    }
    for(int i = 0;i < m;++i){
    cout << ms[i] << endl;
    }
  */
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
long long a, b, c;
long long ans = 1e18;
long long calc(long long t)
{
    return abs(a + c * t);
}
int main()
{
    cin >> a >> b >> c;
    a = abs(a);
    //ans = a;
    //long long l = 0;
    //long long r = b;
    long long x = a / c;
    x = min(x, b);
    //ans = min(ans, calc(-x));
    if (x == b)
    {
        ans = min(ans, calc(-x));
        cout << ans;
        return 0;
    }
    if ((b - x) % 2 != 0)
        x++;
    ans = min(ans, calc(-x));
    cout << ans;
    return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;


	for (int i = 0; i < s.length(); i++)
	{
		if ((i + 1) % 2 == 0)
		{
			if ( (s[i] == 'L' || s[i] == 'U' || s[i] == 'D'))
			{
				continue;
			}
			else
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			if ((s[i] == 'R' || s[i] == 'U' || s[i] == 'D'))
			{
				continue;
			}
			else
			{
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
	
}

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

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,cnt=0;
  int n,k;
  cin>>n>>k;
  ll sum=0;
  for(i=1;i<=n-k;i++){
    sum+=n/(k+i)*i+max(n%(k+i)-k+1,0);
  }
  if(k!=0)cout<<sum<<endl;
  else cout<<sum-n<<endl;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	llong N;
	llong C[500], S[500], F[500];
	cin >> N;
	for(int i = 0; i < N-1; i++){
		cin >> C[i] >> S[i] >> F[i];
	}

	llong ans[500] = {};
	for(int i = 0; i < N-1; i++){
		ans[i] = S[i];
		for(int j = i; j < N-1; j++){
			if(ans[i] < S[j])
				ans[i] = S[j];
			if(ans[i]%F[j] == 0)
				ans[i] -= F[j];
			ans[i] += F[j]-(ans[i]%F[j]);
			ans[i] += C[j];
		}
	}

	for(int i = 0; i < N; i++)
		cout << ans[i] << endl;

	return 0;
}

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

using namespace std ;
int main(){
  pair<pair<string,int>,int> m[110];
  
  int a;
  cin>>a;
  for(int i =0;i<a;i++){
    int t ;
    string city;
    
    cin>>city>>t;
    
    m[i] = make_pair(make_pair(city,-t),i);
  }
  sort(m,m+a);
  for(int i =0;i<a;i++){
  
   
      cout<<m[i].second+1<<endl;
    
  } 
}


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

int main()
{
    int a,b;
    string s;
    cin >> a >> b >> s;

    int flag = 1;
    for(int i = 0; i < a + b + a; i++)
        if(i == a && s[i] != '-' || i != a && s[i] == '-') flag = 0;

    cout << (flag == 1 ? "Yes" : "No") << endl;    
    
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,u,v;
    cin >> n >> u >> v;
    u--; v--;
    vvint nei(n);
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        nei[a].pb(b);
        nei[b].pb(a);
    }
    if((int)nei[u].size()==1&&nei[u][0]==v){
        cout << 0 << endl;
        return 0;
    }
    vint taka(n,INF);
    vint aoki(n,INF);
    taka[u] = 0;
    aoki[v] = 0;
    stack<int> st;
    st.push(u);
    while(!st.empty()){
        int now = st.top();
        st.pop();
        for(int i:nei[now]){
            if(taka[i]==INF){
                taka[i]=taka[now]+1;
                st.push(i);
            }
        }
    }
    st.push(v);
    while(!st.empty()){
        int now = st.top();
        st.pop();
        for(int i:nei[now]){
            if(aoki[i]==INF){
                aoki[i]=aoki[now]+1;
                st.push(i);
            }
        }
    }
    int ans = 0;
    REP(i,n){
        if(taka[i]<aoki[i]){
                ans = max(ans,aoki[i]-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6656
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque

MOD = (10 ** 9) + 7

H, W, K = [int(x) for x in input().split()]

dp = [[0] * W * 2 for _ in range(H * 2)]

L = []

ng_mask = 0b11

for i in range(2 ** (W - 1)):
    isOK = True
    for j in range(W - 1 - 1):
        m = ng_mask << j
        if (i & m) == m:
            isOK = False
    if isOK:
        L.append(i)

# for l in L:
#     print("{:08b}".format(l))


def getBit(n, i):
    i = i - 1
    tmp = n & (1 << i)
    return tmp != 0


dp[0][1] = 1

for h in range(1, H+1):
    for w in range(1, W+1):
        for l in L:
            d = 0
            if w == 1:
                if w == W:
                    d = dp[h - 1][w]
                else:
                    if getBit(l, w) == False:
                        d = dp[h - 1][w]
                    else:
                        d = dp[h - 1][w + 1]
            elif w == W:
                if getBit(l, w - 1):
                    d = dp[h - 1][w - 1]
                else:
                    d = dp[h - 1][w]
            else:
                if getBit(l, w - 1):
                    d = dp[h - 1][w - 1]
                elif getBit(l, w):
                    d = dp[h - 1][w + 1]
                else:
                    d = dp[h - 1][w]
            dp[h][w] += d

print(dp[H][K] % MOD)

sys.exit(0)


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

int main() {
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0; i<N; i++) 
        cin>>A[i];
    int cut=0;
    int pace=0;
    for(int i=0; i<N-1; i++) {
        switch(pace) {
        case 0:
        if(A[i]==A[i+1]) ;
        else if(A[i]<A[i+1]) 
            pace=1;
        else pace=-1;
        break;
        case 1:
        if(A[i]==A[i+1]) continue;
        else if(A[i]<A[i+1]) continue;
        else {
            ++cut;
            pace=0;
        }
        break;
        case -1:
        if(A[i]==A[i+1]) continue;
        else if(A[i]<A[i+1]) {
            ++cut;
            pace=0;
        }
        else continue;
        break;
        }
    }
    cout<<++cut<<endl;
}

Measured memory_bytes: 640
A,B,K=list(map(int,input().split()))

if A==0 and B==0:
  pass
elif A>0:
  if A>=K:
  	A = A-K
  elif A+B>K:
    B = B-K+A
    A = 0
  else:
    A=0
    B=0
elif B>K:
  B=B-K
else:
  B=0
print('%d %d' % (A,B))

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

int main(){
    int n;
    cin >> n;
    int u, k;
    vector<vector<bool>> graph(n, vector<bool>(n, false));
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        int v;
        for (int j = 0; j < k; j++){
            cin >> v;
            v--;
            graph[u][v] = true;
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cout << graph[i][j];
            if (j == n - 1)
                cout << endl;
            else
                cout << ' ';
        }
    }
    return 0;
}


Measured memory_bytes: 3092
N = int(input())
P = [int(input()) for i in range(N)]
ind = [0 for i in range(N)]
for i in range(N):
    ind[P[i]-1] = i
ans = 0
now = 1
for i in range(1,N):
    if ind[i] > ind[i-1]:
        now+=1
    else:
        ans = max(ans,now)
        now = 1
ans = max(ans,now)
print(N-ans)

Measured memory_bytes: 71100
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,M;
    cin >> N >> M;
    string A[N],B[M];
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<M;i++) cin >> B[i];

    for(int i=0;i<N-M+1;i++){
        for(int k=0;k<N-M+1;k++){
            bool match=true;
            for(int j=0;j<M;j++){
                if(A[i+j].substr(k,M) != B[j]) match=false;
            }
            if(match){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 2e5+ 2, mod = 1e9 + 7;


void solve() {
	int n;
	cin >> n;
	ll s = 0;
	ll ans = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}
	for (int i = 0; i < n; i++) {
		s -= a[i];
		ans = (ans%mod) + (s%mod)*(a[i]%mod);
		ans %= mod;
	}
	cout << ans;
}

int main() {
	// reopen("input.txt", "r", stdin); 
 //    freopen("output.txt", "w", stdout); 
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case #:" << tc << " ";
		solve();
	}
}

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


int main()
{
	int n,k,d,a,cnt,vis[106]={},ans=0;
	scanf("%d%d",&n,&k);
	while(k--) {
		scanf("%d",&d);
		while(d--) {
			scanf("%d",&a);
			if(!vis[a]) vis[a]=1;
		}
	}
	for(int i=1;i<=n;++i) if(!vis[i]) ans++;
	cout<<ans;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];

    if ((n - 1) % (k - 1) == 0) {
        cout << (n - 1) / (k - 1) << endl;
    } else {
        cout << (n - 1) / (k - 1) + 1 << endl;
    }
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
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);
        Meal solver = new Meal();
        solver.solve(1, in, out);
        out.close();
    }

    static class Meal {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            if (Math.abs(n - a) > Math.abs(n - b)) {
                out.println('B');
            } else {
                out.println('A');
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException ex) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }
}



Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
const ll mod =1e9+7;
vector<int>g[N];
int vis[N];
int sum=0;
void dfs(int x)
{
    int sz=g[x].size();
    for(int i=0;i<sz;i++)
    {
        int v=g[x][i];
        if(vis[v])continue;
        vis[v]=1;
        dfs(v);
    }
}
int main()
{
    int n,m,x,y,z;
    scanf("%d%d",&n,&m);

    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i])
            continue;
        sum++;
        vis[i]=1;
        dfs(i);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#define llt long long int

using namespace std;
int main()
{
    llt n, l;
    cin >> n >> l;

    llt r = n + l - 1;
    llt eat;
    if (r < 0)
        eat = r;
    else if (l > 0)
        eat = l;
    else
        eat = 0;

    llt ans = (r + l) * n / 2 - eat;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <vector>
#include <queue>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;

constexpr int INF = 1 << 30;

void read_graph(int n, vector<vector<pair<int, int>>> & Es){
    int u, k, v, c;
    while (n--){
        cin >> u >> k;
        while(k--){
            cin >> v >> c;
            Es[u].emplace_back(v, c);
        }
    }
}

void dijkstra(int start, const vector<vector<pair<int, int>>> & Es, vector<int> & dist){
    priority_queue<pair<int, int>, vector< pair<int, int> >, greater<pair<int, int> > > pq;
    pq.emplace(0, start);
    int d, u, v, c;
    while(!pq.empty()){
        tie(d, u) = pq.top();
        pq.pop();
        if (dist[u] < d) continue;
        dist[u] = d;
        for (auto p : Es[u]){
            tie(v, c) = p;
            if (d + c < dist[v]){
                dist[v] = d + c;
                pq.emplace(d + c, v);
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    int n = 0;
    cin >> n;
    vector< vector< pair<int, int> > > Es(n);
    vector<int> dist(n, INF);
    
    read_graph(n, Es);
    dijkstra(0, Es, dist);
    
    for (int i = 0; i != n; ++i){
        cout << i << ' ' << dist[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 7836
#include <cstdio>
#include <cstring>

using namespace std;

char s[100'009];
int cnt[26];

int main() {
  int n;
  scanf("%d %s", &n, s);
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; ++i) {
    ++cnt[(int)(s[i] - 'a')];
  }
  const int mod = 1'000'000'007;
  long long ans = 1;
  for (int i = 0; i < 26; ++i) {
    ans *= cnt[i] + 1;
    ans %= mod;
  }
  ans = (ans - 1 + mod) % mod;
  printf("%d\n", (int)ans);
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var P = cin.ReadIntArray(N);

            var count = 0;
            int min = P[0];

            for (int i = 0; i < N; i++)
            {
                bool isOk = true;

                if (min < P[i])
                {
                    isOk = false;

                }
                else min = P[i];

                if (isOk) count++;
            }


            WriteLine(count);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 35468
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;
const int N = (int) 2e5 + 5, mod = (int) 1e9 + 7;
int f[N], fi[N];
int comb(int n, int r) {
  if (n == -1 && r == -1) return 1;
  if (n - r < 0 || r < 0 || n < 0) {
    return 0;
  }
  return (long long) f[n] * fi[r] % mod * fi[n - r] % mod;
}
int distribute(int place, int cnt) {
  return comb(place + cnt - 1, place - 1);
}
int pw(int a, int b) { return b != 0? (long long) pw((long long) a * a % mod, b >> 1) * (b & 1? a: 1) % mod: 1; }
int32_t main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n, c1, c2, c3;
  cin >> n >> c1 >> c2 >> c3;
  if (c2 % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }
  f[0] = 1;
  for (int j = 1; j < N; ++j) {
    f[j] = (long long) f[j - 1] * j % mod;
  }
  fi[N - 1] = pw(f[N - 1], mod - 2);
  for (int j = N - 2; j >= 0; --j) {
    fi[j] = (long long) fi[j + 1] * (j + 1) % mod;
  }
  int res = 0;
  for (int l = 0; l <= c3; ++l) {
    int r = c3 - l;
    for (int j = 0; j <= r; j += 3) {
      int stations = c2 / 2;
      int ways = distribute(stations, l);
      ways = (long long) ways * distribute(stations + 1, r - j) % mod;
      stations += r - j;
      ways = (long long) ways * distribute(stations + 1, j / 3) % mod;
      stations += j / 3;
      ways = (long long) ways * distribute(stations + 1, c1 - r + j) % mod;
      res += ways;
      while (res >= mod) {
        res -= mod;
      }
    }
  }
  cout << res << endl;
}




Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  map<char,int> m;
  string s;
  cin>>s;
  
  for(auto c:s){
  	m[c]++;
  }
  
  if( m.size()==2 ){
  	int cnt=0;
	for(auto k:m){
    	if(k.second != 2) cout << "No" << endl;
      cnt++;
    }
    if(cnt==2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
  }
  else{
  cout << "No" << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (long u = 0; u < 1000; u++)
	{
		long long n;
		long a[13],b[13];

		cin >> n;
		if (n == 0)
		{
			break;
		}

		for (int i = 0; i < 12; i++)
		{
			cin >> a[i] >> b[i];
		}

		int p = 0;

		for (int i = 0; i < 12; i++)
		{
			p += a[i] - b[i];
			if (p >= n)
			{
				cout << i + 1 << endl;
				break;
			}
			if (i == 11)
			{
				cout << "NA" << endl;
				break;
			}
		}
	}
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

struct BinaryIndexedTree {
  vector<int> data;

  BinaryIndexedTree(int sz) { data.assign(++sz, 0); }

  int sum(int k) {
    int ret = 0;
    for (++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, int x) {
    for (++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int q;
  cin >> q;

  vector<BinaryIndexedTree> vb(26, BinaryIndexedTree(n));
  rep(i, n) {
    int d = s[i] - 'a';
    vb[d].add(i, 1);
  }

  rep(_, q) {
    int op;
    cin >> op;
    if (op == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      char bc = s[i];
      s[i] = c;
      vb[c - 'a'].add(i, 1);
      vb[bc - 'a'].add(i, -1);
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      int ans = 0;
      rep(i, 26) {
        int sum = vb[i].sum(r);
        if (l - 1 >= 0) sum -= vb[i].sum(l - 1);
        if (sum > 0) ans++;
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 53636
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}

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


  ll N,M; cin>>N>>M;
  vl A(N); REP(i,N) cin>>A[i];

  REP(i,N) A[i] /= 2;

  vi div(N,0);
  REP(i,N) {
    int t = A[i];
    while(t%2==0) {
      t/=2;
      div[i]++;
    }
  }
  FOR(i,1,N) {
    if (div[0] != div[i]) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll lm = A[0];
  FOR(i,1,N) lm = lcm(lm, A[i]);

  if (lm>M) {
    cout << 0 << endl;
    return 0;
  }
  
  ll ans = M/lm - M/(lm*2);
  cout << ans << endl;


  return 0;
}

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

#define INF (INT64_MAX/2)
#define MAX 100000

struct edge { int to; long long cost; };
typedef pair< long long, int >  P;

int N;
int Q, K;
vector< edge > G[MAX];
long long d[MAX];

void dijkstra( int s )
{
	priority_queue< P, vector<P>, greater<P> > que;
/*
	for( int i = 0; i < N; i++ ) {
		d[i] = INF;
	}
*/
	fill( d, d + N, INF );
	d[s] = 0;
	que.push( P( 0, s ) );
	while( !que.empty() ) {
		P p = que.top(); que.pop();
		int v = p.second;
		if( d[v] < p.first ) continue;
		for( int i = 0; i < G[v].size(); i++ ) {
			edge e = G[v][i];
			if( d[e.to] > d[v] + e.cost ) {
				d[e.to] = d[v] + e.cost;
				que.push( P( d[e.to], e.to ) );
			}
		}
	}
}

int main()
{
	cin >> N;
	for( int i = 0; i < N - 1; i++ ) {
		int a, b;
		long long c;

		cin >> a >> b >> c;

		a--;
		b--;
		edge e;
		e.to = b;
		e.cost = c;
		G[a].push_back( e );
		e.to = a;
		G[b].push_back( e );
	}

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

	return 0;
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == 'R') cnt++;
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  ans = max(ans, cnt);
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define maxn 500010
#define mod 1000000007
int a[1010][1010],n,m,x,y,cnt[1010];
char s[1010][1010];
int main(){
    scanf("%d%d%d%d",&n,&m,&x,&y);
    int s1,s2,f=0;
    for(int i=0;i<=n&&f==0;i++){
        for(int j=0;j<=m&&f==0;j++){
            if(i*x+(n-i)*(m-x)==j*y+(m-j)*(n-y)){
                f=1;
                s1=i,s2=j;
                break;
            }
        }
    }
    if(f==0){
        printf("-1\n");
        return 0;
    }
    //printf("%d %d\n",s1,s2);
    for(int i=0;i<m;i++){
        if(i<s2) cnt[i]=y;
        else cnt[i]=n-y;
    }
    for(int i=0;i<n;i++){
        int sum;
        if(i<s1) sum=x;
        else sum=m-x;
        for(int j=0;j<m&&sum;j++){
            if(cnt[j]){
                sum--;
                cnt[j]--;
                a[i][j]=1;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) s[i][j]='0'+a[i][j];
        s[i][m]='\0';
    }
    for(int i=0;i<n;i++) printf("%s\n",s[i]);
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll cnt = 0;

    rep(i,n-1){
        cnt += a.at(i)/2;
        a.at(i) = a.at(i)%2;
        int temp;
        temp = min(a.at(i),a.at(i+1));
        cnt += temp;
        a.at(i+1) -= temp;
    }
    cnt += a.at(n-1)/2;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main () {
	int W, H, N, b=0, l=0;
	scanf ("%d %d %d", &W, &H, &N);
	for (int i=0; i<N; i++) {
		int x, y, a;
		scanf ("%d %d %d", &x, &y, &a);
		switch (a) {
			case 1:
				if (l<x)
					l = x;
				break;
			case 2:
				if (W>x)
					W = x;
				break;
			case 3:
				if (b<y)
					b = y;
				break;
			case 4:
				if (H>y)
					H = y;
				break;
		}
	}
	int wd = (W>l)?(W-l):0;
	int hg = (H>b)?(H-b):0;
	printf ("%d\n", wd*hg);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    string S;
    cin >> S;
    S="ABC"+S;
    cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

typedef vector<int> vec;
typedef vector<vec> matrix;

typedef int weight;

weight OPT[1 << 7][12*12+10];

weight minimum_steiner_tree(const vector<int>& T, const matrix &g) {
  const int n = g.size();
  const int numT = T.size();
  if (numT <= 1) return 0;

  matrix d(g); // all-pair shortest
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        d[i][j] = min( d[i][j], d[i][k] + d[k][j] );

  for (int S = 0; S < (1 << numT); ++S)
    for (int x = 0; x < n; ++x)
      OPT[S][x] = inf;

  for (int p = 0; p < numT; ++p) // trivial case
    for (int q = 0; q < n; ++q)
      OPT[1 << p][q] = d[T[p]][q];

  for (int S = 1; S < (1 << numT); ++S) { // DP step
    if (!(S & (S-1))) continue;
    for (int p = 0; p < n; ++p)
      for (int E = 0; E < S; ++E)
        if ((E | S) == S)
          OPT[S][p] = min( OPT[S][p], OPT[E][p] + OPT[S-E][p] );
    for (int p = 0; p < n; ++p)
      for (int q = 0; q < n; ++q)
        OPT[S][p] = min( OPT[S][p], OPT[S][q] + d[p][q] );
  }
  weight ans = inf;
  for (int S = 0; S < (1 << numT); ++S)
    for (int q = 0; q < n; ++q)
      ans = min(ans, OPT[S][q] + OPT[((1 << numT)-1)-S][q]);
  return ans;
}

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

int main() {

  for(int H, W; cin >> H >> W && (H|W);) {
    zero(OPT);
    matrix mat(H, vec(W));
    rep(i, H) rep(j, W)
      cin >> mat[i][j];

    vector<int> T;
    rep(i, H) rep(j, W)
      if(mat[i][j])
        T.push_back(i * W + j);

    matrix mat2(H*W, vec(H*W, inf));

    rep(i, H) {
      rep(j, W) {
        mat2[i*W+j][i*W+j] = 0;
        rep(k, 4) {
          const int ni = i + dy[k], nj = j + dx[k];
          if(in_range(ni, nj, H, W)) {
            mat2[i*W+j][ni*W+nj] /*= mat2[ni*W+nj][i*W+j]*/ = 1;
          }
        }
      }
    }

//    rep(i, H*W) rep(j, W)     printf("%10d%c", mat2[i][j], j < W-1 ? ' ' : '\n');

    int ms = minimum_steiner_tree(T, mat2);
    cout << H * W - (1 + ms) << endl;

  }
  
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, a, b;
	cin>>n;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	a = b = 0;
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	for(int i = 0; i < n; ++i){
		if(i % 2 == 0)a += vec[i];
		else b += vec[i];
	}
	cout<<a - b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    printf("%d %d\n", min(a, b), max(a + b - n, 0));
}

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

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;

const int MAX_N = 1e5 + 10;

int Cnt[MAX_N], N, M;
int main() {
	cin >> N >> M;
	while(M--) {
		int a, b; scanf("%d%d", &a, &b);
		Cnt[a]++; Cnt[b]++;
	}
	bool possible = true;
	for(int i=1; i<=N; i++) if(Cnt[i] % 2 == 1) possible = false;
	if(possible) puts("YES"); else puts("NO");
	return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N = int(input())
P = [int(zz) for zz in input().split()]

flag = 0
for i in range(N):
    if i+1 != P[i]:
        flag += 1

if flag == 2 or flag == 0:
    print('YES')
else:
    print('NO')


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

int main(){
  int N;
  cin >> N;
  vector<long long> X(5);
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S.at(0)=='M') X.at(0)++;
    if(S.at(0)=='A') X.at(1)++;
    if(S.at(0)=='R') X.at(2)++;
    if(S.at(0)=='C') X.at(3)++;
    if(S.at(0)=='H') X.at(4)++;
  }
  long long ans=0;
  ans+=X.at(0)*X.at(1)*X.at(2);
  ans+=X.at(0)*X.at(1)*X.at(3);
  ans+=X.at(0)*X.at(1)*X.at(4);
  ans+=X.at(0)*X.at(2)*X.at(3);
  ans+=X.at(0)*X.at(2)*X.at(4);
  ans+=X.at(0)*X.at(3)*X.at(4);
  ans+=X.at(1)*X.at(2)*X.at(3);
  ans+=X.at(1)*X.at(2)*X.at(4);
  ans+=X.at(1)*X.at(3)*X.at(4);
  ans+=X.at(2)*X.at(3)*X.at(4);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & (-x))


using namespace std;

string str;

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin >> str;
    for(i = 0; i < (int) str.size() - 1; i++)
    if(str[i] == 'A' && str[i + 1] == 'C') {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF =10000000;
typedef pair<int,int> P;
      
int main() {
  int MAX = 101010;
  vector<int> is_prime(MAX,1);//素数番目が1の配列を1で初期化
  is_prime[0] = 0;
  is_prime[1] = 0;
  for(int i = 2;i<MAX;i++){
    
    for(int j = i*2;j<MAX;j += i){
      is_prime[j] = 0;
    }
  }
  vector<int> a(MAX,0);
  for(int i = 2;i<MAX;i++){
    if(i%2 ==0) continue;
    if(is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
  }
  vector<int> s(MAX+1,0);
  for(int i = 0;i<MAX;i++) s[i+1] = s[i] +a[i];

  int Q;
  cin >> Q;
  for(int q = 0;q<Q;q++){
    int l,r;
    cin >> l >> r;
    cout << s[r+1]-s[l] << endl;
  }
}

Measured memory_bytes: 1792