akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10000;
int n, m, a, b, c, ans, A[MAXN];
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> a >> b;
	cout << 6 - a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   string S,a,b;
  cin >> S;
   a = S.substr(0, 2);
   b = S.substr(2, 2);
  if(a=="01" || a=="02" || a=="03" || a=="04" || a=="05" || a=="06" ||
     a=="07" || a=="08" || a=="09" || a=="10" || a=="11" || a=="12"){
    if(b=="01" || b=="02" || b=="03" || b=="04" || b=="05" || b=="06" ||
     b=="07" || b=="08" || b=="09" || b=="10" || b=="11" || b=="12"){
      	cout << "AMBIGUOUS" << endl;
    }
  }
      if(a=="01" || a=="02" || a=="03" || a=="04" || a=="05" || a=="06" ||
     a=="07" || a=="08" || a=="09" || a=="10" || a=="11" || a=="12"){
    if(!(b=="01" || b=="02" || b=="03" || b=="04" || b=="05" || b=="06" ||
     b=="07" || b=="08" || b=="09" || b=="10" || b=="11" || b=="12")){
      	cout << "MMYY" << endl;
    }
  }
    if(!(a=="01" || a=="02" || a=="03" || a=="04" || a=="05" || a=="06" ||
     a=="07" || a=="08" || a=="09" || a=="10" || a=="11" || a=="12")){
    if(b=="01" || b=="02" || b=="03" || b=="04" || b=="05" || b=="06" ||
     b=="07" || b=="08" || b=="09" || b=="10" || b=="11" || b=="12"){
      cout << "YYMM" << endl;
    }
    }
	if(!(a=="01" || a=="02" || a=="03" || a=="04" || a=="05" || a=="06" ||
     a=="07" || a=="08" || a=="09" || a=="10" || a=="11" || a=="12")){
    if(!(b=="01" || b=="02" || b=="03" || b=="04" || b=="05" || b=="06" ||
     b=="07" || b=="08" || b=="09" || b=="10" || b=="11" || b=="12")){
      cout << "NA" << endl;
    }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a[14][14],x,y,k,ans=0,top=0;
    for(int i=0;i<14;i++)
        for(int j=0;j<14;j++)
            a[i][j]=0;
    while(scanf("%d,%d,%d",&x,&y,&k)!=EOF){
        a[x+1][y+2]++;
        a[x+2][y+2]++;
        a[x+3][y+2]++;
        a[x+2][y+1]++;
        a[x+2][y+3]++;
        if(k>1){
            a[x+3][y+3]++;
            a[x+1][y+1]++;
            a[x+3][y+1]++;
            a[x+1][y+3]++;
        }
        if(k>2) {
            a[x+4][y+2]++;
            a[x][y+2]++;
            a[x+2][y]++;
            a[x+2][y+4]++;
        }
    }
    for(int i=2;i<12;i++){
        for(int j=2;j<12;j++){
            if(a[i][j]==0)ans++;
            if(a[i][j]>top)top=a[i][j];
        }
    }
    printf("%d\n%d\n",ans,top);
}

Measured memory_bytes: 2624
//Bismillah Hir Rehmanir Rahim
//Allah knows best
using namespace std;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#define mini -10000000000000000
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#define vi              vector<int>
#define si              set<int>
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define rr              return 0
#define ff              first
#define in              insert
#define ss              second
#define setbits(x)      __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)
#define deb(x)          cout << #x << " = " << x << endl
ll mxn=1000001;
ll spf[1000001];
void sieve()
{
    ll i,j,k;
    spf[1]=1;
    for(i=2;i<1000001;i++)
        spf[i]=i;
    for(i=4;i<1000001;i+=2)
        spf[i]=2;
    for(i=3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(j=i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)
                    spf[j]=i;
            }
        }
    }
}
vector<ll> getfact(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
int main()
{
    start;
    sieve();
    ll i,j,k,n,m;
    cin>>n;
    ll a[n];
    f(i,0,n) cin>>a[i];
    set<ll>st,srt;
    bool f=0;
    ll cnt=0;
    ll gcd=a[0];
    for(i=0;i<n;i++)
    {
        vector<ll>p=getfact(a[i]);//f(j,0,p.size()) deb(p[j]);
        ll pk=p.size();
        //deb(pk);
        //deb(cnt);
        srt.in(p.begin(),p.end());
        cnt+=srt.size();
        srt.clear();
        ll pp=st.size();
        //deb(pp);
        st.in(p.begin(),p.end());
        ll mn=st.size();
        if(i!=0)
        {
           gcd=__gcd(a[i],gcd);
        }
    }
    if(cnt==st.size())
        cout<<"pairwise coprime"<<endl;
    else if(gcd==1)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;
    rr;
}


Measured memory_bytes: 22816
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  vector<long> foo(3);
  rep (i, 3) cin >> foo[i];
  sort(foo.begin(), foo.end());
  long K;
  cin >> K;
  while (K--) foo[2] *= 2;

  cout << foo[0] + foo[1] + foo[2] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main()
{
  int a, b;
  cin >> a >> b;
  for (double i = 1; i <= 1000; i++)
  {
    double tba = i * 0.08;
    double tbb = i * 0.1;
    int ta = tba;
    int tb = tbb;
    if (ta == a && tb == b)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
int n,Q;
const int N=2e5+10;
char S[N];
char opt[N];int LR[N];
inline char Gc(){char ch=getchar();while(!(ch>='A'&&ch<='Z')) ch=getchar();return ch;}
inline bool checkL(int p){
	for(int i=1;i<=Q;++i){
		if(opt[i]==S[p]) p+=LR[i];
		if(p<=0) return 1;if(p>n) return 0;
	}return 0;
}
inline bool checkR(int p){
	for(int i=1;i<=Q;++i){
		if(opt[i]==S[p]) p+=LR[i];
		if(p>n) return 1;if(p<=0) return 0;
	}return 0;
}
int main()
{
	init(n),init(Q);scanf("%s",S+1);
	for(int i=1;i<=Q;++i) {char ch=Gc();opt[i]=ch;ch=Gc();LR[i]=(ch=='L')? (-1):1;}
	int l=1,r=n,pos=0;
	while(l<=r){
		int mid=(l+r)>>1;
		if(checkL(mid)) pos=mid,l=mid+1;else r=mid-1;
	}
	int ans=pos;l=pos+1,r=n;pos=n+1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(checkR(mid)) pos=mid,r=mid-1;else l=mid+1;
	}ans+=(n-pos+1);
	cout<<(n-ans)<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int N,M,A,B,X,Y,Z;
    string S,T;
    cin>>X>>Y>>Z;
    swap(X,Y);swap(X,Z);
    cout<<X<<" "<<Y<<" "<<Z<<endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  uf.union(a,b)
print(uf.group_count()-1)

Measured memory_bytes: 12772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int A[30];

int main() {
  int n;
  scanf("%d", &n);
  rep(i, n) scanf("%d", &A[i]);
  int sum = 0;
  for (int i = 1; i < n - 1; i++) {
    int min = std::min(A[i - 1], std::min(A[i], A[i + 1]));
    int max = std::max(A[i - 1], std::max(A[i], A[i + 1]));
    if (A[i] > min && A[i] < max) sum++;
  }
  printf("%d", sum);
}


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

const int M=1e6;
int a[M];

int main(){
       
    int n;
    string s;
    cin >> n >> s;
    
    s = s+s;
    
    for(int i1=0; i1<2; i1++){
        for(int i2=0; i2<2; i2++){
            a[0] = i1;
            a[1] = i2;
            for(int i=2; i<=n+1; i++){
                if(s[i-1]=='o' && a[i-1]==0) a[i] = 1-a[i-2];
                if(s[i-1]=='o' && a[i-1]==1) a[i] = a[i-2];
                if(s[i-1]=='x' && a[i-1]==0) a[i] = a[i-2];
                if(s[i-1]=='x' && a[i-1]==1) a[i] = 1-a[i-2];
            }
            if(a[n]==a[0] && a[n+1]==a[1]){
                for(int i=0; i<n; i++)
                    cout << (a[i]?"S":"W");
                return 0;
            }
        }
    }
    cout << -1;
    return 0;
}


Measured memory_bytes: 1052
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int line[11]={0};
    int d;
    REP(i, 3){
        cin >> d;
        ++line[d];
    }
    if(line[5]==2 and line[7] == 1)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    char a;
    cin>>a;
    if(isupper(a)) cout<<'A';
    else cout<<'a';
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

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

  int n, l;
  cin >> n >> l;

  int mi = INF;
  int m = INF;

  rep(i, n) {
    if (abs(l+i) < m) {
      mi = i;
      m = abs(l+i);
    }
  }

  long sm = 0;
  rep(i, n) {
    if (i != mi) sm+=(l+i);
  }

  cout << sm << endl;
  
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename M>
struct SegmentTree{
    using T = typename M::type;

    int numLeaves;
    std::vector<T> data;
    
    SegmentTree(int n){
        numLeaves = 1;
        while(numLeaves < n){
            numLeaves *= 2;
        }
        
        data.resize(numLeaves * 2);
        std::fill(data.begin() + numLeaves, data.end(), M::identity());
        
        for(int i=numLeaves-1;i>0;--i){
            data[i] = M::bop(data[i*2], data[i*2+1]);
        }
    }

    template <typename F>
    SegmentTree(int n, F f){
        numLeaves = 1;
        while(numLeaves < n){
            numLeaves *= 2;
        }

        data.resize(numLeaves * 2);
        for(int i=0;i<n;++i){
            data[i + numLeaves] = std::move(f(i));
        }
        std::fill(data.begin() + numLeaves + n, data.end(), M::identity());

        for(int i=numLeaves-1;i>0;--i){
            data[i] = M::bop(data[i*2], data[i*2+1]);
        }
    }

    void set(int k, T v){
        k += numLeaves;
        data[k] = v;
        
        while(k > 1){
            k /= 2;
            data[k] = M::bop(data[k*2], data[k*2+1]);
        }
    }
    
    T product(int l, int r){
        l += numLeaves;
        r += numLeaves;
        
        T pl = M::identity(), pr = M::identity();
        for(;l<r;l/=2,r/=2){
            if(l & 1){
                pl = M::bop(pl, data[l]);
                l += 1;
            }
            if(r & 1){
                r -= 1;
                pr = M::bop(data[r], pr);
            }
        }
        
        return M::bop(pl, pr);
    }
    
    T at(int i){
        return data[i + numLeaves];
    }
};

struct M{
    using type = int;
    static type identity(){
        return 0;
    }
    static type bop(type &m1, type &m2){
        return m1 + m2;
    }
};

int N;
int ps[200100];
SegmentTree<M> seg(200100);

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

  std::cin >> N;

  ll res = 0;

  for(int i=0;i<N;++i){
      std::cin >> ps[i];

      seg.set(ps[i], +1);
      
      if(seg.product(1, ps[i]) == 0){
          res += 1;
      }
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(void) {
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    if (n == 0) {
        cout << x << endl;
    } else {
        sort(p.begin(), p.end());
        int idx = 0;
        vector<int> a_list;
        for (int i = 0 ; i < 105; i++) {
            if (p[idx] == i) {
                if (idx+1 < p.size()) {
                    idx++;
                }
            } else {
                a_list.push_back(i);
            }
        }
        int min = 1000;
        for (int i = 0; i < a_list.size(); i++) {
            int dist = abs(x - a_list[i]);
            if (dist < min) min = dist;
            else {
                cout << a_list[i-1] << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3624
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif 80 <= (m + f):
        print("A")
    elif 65 <= (m + f) < 80:
        print("B")
    elif 50 <= (m + f) < 65:
        print("C")
    elif 30 <= (m + f) < 50:
        if 50 <= r:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5592
line = input().split()
N = int(line[0])
M = int(line[1])
broken = []
count = 0
step = []
def check(value):
  if count < M:
    return broken[count]==value
  else:
    return False
for i in range(M):
  a = int(input())
  broken += [a]
if check(1):
  step+=[0]
  count += 1
else:
  step +=[1]
if check(2):
  step += [0]
  count += 1
else:
  step += [1+step[0]]
for j in range(2, N):
  if check(j+1):
    step += [0]
    count += 1
  else:
    step += [step[j-2]+step[j-1]]
ans = step[N-1]%(10**9+7)
print(ans)

Measured memory_bytes: 460020
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int r;
	cin >> r;
	if (r >= 2800) cout << "AGC" << endl;
	else if (r >= 1200) cout << "ARC" << endl;
	else if (r < 1200) cout << "ABC" << endl;
	return 0;
}

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

const int mod = 1000000007;

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

	int n;
	cin >> n;
	vector<int> c(n);
	for (int i = 0; i < n; ++i) cin >> c[i];

	map<int, int> most_recent;
	vector<int> d(n);

	d[0] = 1;
	most_recent[c[0]] = 0;

	for (int i = 1; i < n; ++i) {
		if (most_recent.find(c[i]) != most_recent.end() && i - most_recent[c[i]] >= 2) {
			d[i] = (d[i-1] + d[most_recent[c[i]]]) % mod;
		} else {
			d[i] = d[i-1];
		}
		most_recent[c[i]] = i;
	}

	cout << d[n-1] << "\n";

	return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll,ll>
#define endl "\n"
#define MAXN 200005
using namespace std;

ll n,k,par[MAXN],vis[MAXN],adj[MAXN];
vector<ll> v,v1;

void dfs(ll s)
{
	vis[s]=1;
	if(!vis[adj[s]])
	{
		par[adj[s]]=s;
		dfs(adj[s]);
	}
	else if(vis[adj[s]]==1)
	{
		v.pb(adj[s]);
		return;
	}
	vis[s]=2;
}

void solve()
{
	cin>>n>>k;
	for(ll i=1;i<=n;i++)
	{
		cin>>adj[i];
	}
	dfs(1);
	// cout<<v[0]<<endl;
	int x=adj[v[0]];
	while(x!=v[0])
	{
		v.pb(x);
		x=adj[x];
	}
	// for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
	// cout<<endl;	
	x=v[0];
	ll cnt=0;
	while(x!=1)
	{
		x=par[x];
		cnt++;
		v1.pb(x);
	}
	reverse(v1.begin(),v1.end());
	// for(int i=0;i<v1.size();i++) cout<<v1[i]<<" ";
	// cout<<endl;
	// cout<<cnt<<endl;
	if(k>=cnt)
	{
		k-=cnt;
		k%=v.size();
		cout<<v[k]<<endl;
	}
	else
	{
		cout<<v1[k]<<endl;
	}
}

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


Measured memory_bytes: 16100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc127_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);

            if (a <= 5)
            {
                b = 0;
                Console.WriteLine(b);
            }
            else if (a >= 6 && a <= 12)
            {
                b = b / 2;
                Console.WriteLine(b);
            }
            else
            {
                Console.WriteLine(b);
            }

            Console.Read();
        }
    }
}


Measured memory_bytes: 11220
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
a = [i() for _ in range(n)]

b = sorted(a)
ans1 = b[-1]
ans2 = b[-2]

for i in range(n):
	if a[i] == ans1 :
		print(ans2)
	else:
		print(ans1)

Measured memory_bytes: 19020
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    S1 = input().rstrip('\n')
    S2 = input().rstrip('\n')

    S = [0]
    for i in range(N-1):
        if S1[i+1] == S1[i]:
            S[-1] += 1
        else:
            S.append(0)
    mod = 1000000007
    if S[0] == 0:
        ans = 3
    else:
        ans = 6
    for i in range(len(S)-1):
        if S[i] == 0 and S[i+1] == 0:
            ans = (ans*2)%mod
        elif S[i] == 0 and S[i+1] == 1:
            ans = (ans*2)%mod
        elif S[i] == 1 and S[i+1] == 0:
            pass
        else:
            ans = (ans * 3)%mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul.")))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return result)))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(define-modify-macro minf (new-value)
  (lambda (x y) (min x y)))

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (read))
         (hs (make-array n :element-type '(unsigned-byte 32)))
         (dp (make-array n :element-type '(unsigned-byte 32) :initial-element #xffffffff)))
    (declare ((unsigned-byte 31) n k))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (setf (aref hs i) (read-fixnum)))
    (dotimes (i n)
      (loop for dest from (+ i 1) to (min (+ i k) (- n 1))
            do (minf (aref dp dest)
                     (+ (aref dp i) (abs (- (aref hs i) (aref hs dest)))))))
    (println (aref dp (- n 1)))))

#-swank (main)


Measured memory_bytes: 10856
#include <algorithm>
#include <cstdio>
using namespace std;
int a[32] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    int k;
    scanf("%d", &k);
    printf("%d\n", a[k - 1]);
    return 0;
}

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

int main() {
  string sample[4] = {"dream","dreamer","erase","eraser"};
  string s; cin >> s;
  reverse(s.begin(), s.end());
  for (int i = 0; i < 4; i++) reverse(sample[i].begin(), sample[i].end());
  bool count1 = true;
  for (int i = 0; i < s.size(); ){
    bool count2 = false;
    for (int j = 0; j < 4; j++){
      string xxx = sample[j];
      if (s.substr(i, xxx.size()) == xxx){
        count2 = true;
        i += xxx.size();
      }
    }
    if (!count2){
      count1 = false;
      break;
    }
  }
  if (count1) cout << "YES" << endl;
  else cout << "NO" << endl;
}




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

class union_find  // union find.
{
    int* U;
public:
    union_find(int n){ U = new int [n]; for(int i = 0; i < n; i++) U[i] = i; }
    int root(int a){ if(U[a] == a){ return a; } U[a] = root(U[a]); return U[a]; }
    bool same(int a, int b){ return root(a) == root(b); }
    void join(int a, int b){ int x = root(a), y = root(b); U[x] = y; }
    ~union_find(){ delete [] U; }
};

struct edge{
    int v1, v2, w;
    bool operator < (const edge &e) const{ return w > e.w; }  // const?????????????????????
};

edge init(int ver_1, int ver_2, int weight)
{
	edge e;
	e.v1 = ver_1, e.v2 = ver_2, e.w = weight;
	return e;
}

int main()
{
	int i, j, w, n;
	scanf("%d", &n);

	priority_queue<edge> ES;
	union_find VS(n);

	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			scanf("%d", &w);
			if(i >= j || w < 0) continue;
			ES.push(init(i, j, w));
		}
	}
	int size = 0, sum = 0;
	edge e;
	while(!ES.empty() && size < n - 1){
		e = ES.top();
		ES.pop();
		if(!VS.same(e.v1, e.v2)){
			VS.join(e.v1, e.v2);
			sum += e.w;
			size++;
		}
	};
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  int k; cin >> k;
  int n = s.size();

  set<string> st;
  for(int i = 1; i <= min(5,n); i++){
    rep(j,n-i+1) st.insert(s.substr(j,i));
  }
  auto itr = st.begin();
  rep(i,k-1) itr++;
  cout << *itr;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4744
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

lint dist[64][2501];
int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M, S;
    cin >> N >> M >> S;
    VEC(VEC(VEC(int))) graph(N);
    VEC(int) C(N), D(N);
    FOR(i, 0, M) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;v--;
        VEC(int) edge1(3), edge2(3);
        edge1[0] = v;edge2[0] = u;
        edge1[1] = edge2[1] = a;
        edge1[2] = edge2[2] = b;
        graph[u].push_back(edge1);
        graph[v].push_back(edge2);
    }

    FOR(i, 0, N)
        cin >> C[i] >> D[i];


    queue<Pii> bfsq;
    memset(dist, -1, sizeof dist);

    auto addQ = [&bfsq](int node, lint newdist, int silver) {
        silver = min(silver, 2500);
        lint& t = dist[node][silver];
        if (t < 0 || t > newdist) {
            t = newdist;
            bfsq.push(Pii(node, silver));
        }
    };

    addQ(0, 0, S);

    while (!bfsq.empty()) {
        Pii cur = bfsq.front();
        bfsq.pop();
        int node = cur.first, silver = cur.second;
        lint curdist = dist[node][silver];
        // Either spend time getting extra silver here or take a train.

        addQ(node, curdist + D[node], silver + C[node]);
        for(auto& edge : graph[node]) {
            int oend = edge[0], scost = edge[1], time = edge[2];
            if (silver >= scost)
                addQ(oend, curdist + time, silver - scost);
        }
    }

    FOR(i, 1, N) {
        lint minTime = 1LL << 60;
        FOR(s, 0, 2501)
            minTime = min(minTime, dist[i][s]);
        cout << minTime << endl;
    }

    return 0;
};


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

int dy[] = {0, 1, 1, 1};
int dx[] = {1, 0, 1, -1};
char c[10][10];

char solve(){
	for(int i = 3; i < 6; ++i)
	for(int j = 3; j < 6; ++j)
	for(int k = 0; k < 4; ++k){
		int t = 1;
		for(int d = 1; d < 3; ++d){
			if(c[i][j] == c[i + dy[k] * d][j + dx[k] * d]){
				++t;
			}
		}
		if(c[i][j] != 's' && t == 3){ return c[i][j]; }
	}

	return 'd';
}

int main(){
	while(1){
		for(int i = 0; i < 3; ++i){
			for(int j = 0; j < 3; ++j){
				if(scanf(" %c", &c[i + 3][j + 3]) == EOF){
					return 0;
				}
			}
		}
		printf("%c\n", solve());
	}
}

Measured memory_bytes: 968
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
int ar[200001];
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  for(int i = 0; n-1 > i; i++){
    int t;cin>>t;
    ar[t-1]++;
  }
  for(int i = 0; n > i; i++){
    cout << ar[i] << endl;
  }
}

Measured memory_bytes: 4420
A,B,C = map(int,input().split())
sum = 0
remainder_list = []

while True:
    sum += A
    remainder = sum % B
    if remainder not in remainder_list:
        remainder_list.append(remainder)
    else:
        break

if C in remainder_list:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        long A = reader.nextLong();
        long B = reader.nextLong();
        long K = reader.nextLong();
        long a = Math.min(A, K);
        A -= a;
        K -= a;
        B -= K;
        B = Math.max(B, 0);
        System.out.println(A+" "+B);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		for (int i = 0; i < 5000; i++) {
			if (a * i % b == c) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}

}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    int n;
    int b, f, r, v;
    int count[4][3][10];
    for(int i=0;i<4;i++)
        for(int j=0;j<3;j++)
            for(int k=0;k<10;k++)
        count[i][j][k]=0;
        
        cin>>n;
        
        for(int i=0;i<n;i++){
            cin>>b>>f>>r>>v;
            count[b-1][f-1][r-1]+=v;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<3;j++){
                for(int k=0;k<10;k++)
                cout<<" "<<count[i][j][k];
                cout<<endl;
            }
            if(i!=3)printf("####################\n");
        }
    
    
}



Measured memory_bytes: 3100
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const ll MOD = 998244353;

ll fac[MAX], finv[MAX], inv[MAX];
void COMint() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n,ll k) {
    if (k == 0)return 1;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    COMint();
    ll n, m, k; cin >> n >> m >> k;
    ll sum = 0,hoge;
    rep(i, k + 1) {
        hoge = (m * mod_pow(m - 1, n - i - 1, MOD)) % MOD;
        sum += (hoge * COM(n - 1, i)) % MOD;
        sum %= MOD;
    }cout << sum % MOD << endl;
}

Measured memory_bytes: 15592
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s.find("AA") != string::npos)
	{
		cout << "NO" << endl;
		return 0;
	}
	if (s.find("KIH") == string::npos)
	{
		cout << "NO" << endl;
		return 0;
	}
	string t = "";
	for (char c : s)if (c != 'A')t += c;
	if (t == "KIHBR")cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main() {
    int x, th, nokori, fh;
    cin >> x;
    th     = x / 500;
    nokori = x % 500;
    fh     = nokori / 5;
    cout << 1000 * th + 5 * fh << endl;
}

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;
int dp[10001][2][101];
int d;
int solve(string &s,int idx,int n,int sum,bool isSmalled,int num)
{
    if(idx==n)
    {
//        if(sum%d==0)
//        cout<<num<<" "<<sum<<endl;
        return sum%d==0;
    }
    if(dp[idx][isSmalled][sum]!=-1)
        return dp[idx][isSmalled][sum];
    int ans=0;
    if(isSmalled)
    {
        for(int i=0;i<10;i++)
        {
            ans+=solve(s,idx+1,n,(sum+i)%d,true,num*10+i);
            ans=ans%mod;
        }
    }
    else{
        int Num=s[idx]-'0';
        for(int i=0;i<Num;i++)
        {
            ans+=solve(s,idx+1,n,(sum+i)%d,true,num*10+i);
            ans%=mod;
        }
        ans+=solve(s,idx+1,n,(sum+Num)%d,false,num*10+Num);
        ans%=mod;
    }
    return dp[idx][isSmalled][sum]=ans;
}
int32_t main() {
    nitin;
    string s;
    cin>>s;
    for(int i=0;i<=10000;i++)
    {
        for(int j=0;j<2;j++)
        {
            for(int k=0;k<101;k++)
                dp[i][j][k]=-1;
        }
    }
    int n=s.length();
    cin>>d;
    cout<<(solve(s,0,n,0,false,0)-1+mod)%mod;
    return 0;
}

Measured memory_bytes: 20544
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define ort ((bas+son+1ll)/2ll)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;

long long n;

int main() {
	
	cin >> n;
	
	if(n % 2 == 0)
	 cout << n/2-1;
	else
	 cout << (n-1) / 2;
	 
	
	return 0;
}


Measured memory_bytes: 256
/* -------------------------------- Template -------------------------------- */
 
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
 
using ll = long long;
using ld = long double;
 
template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
 
template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;
 
struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};
 
void solve();
 
int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}
 
using namespace std;
 
/* -------------------------------- Library -------------------------------- */
 
class UnionFind {
  vector<int> p;
public:
  UnionFind (int n) : p(n, -1) {}
  int root(int x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    return true;
  }
};
 
/* ---------------------------------- Main ---------------------------------- */
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int n;
 
int get_id(int i, int j) {
  return i * n + j;
}
 
void solve() {
  cin >> n;
  UnionFind uf(n * n);
  vector<pair<int,int>> res;
  for (int num = 4; num >= 2; --num) {
    REP(i,n) REP(j,n) {
      if ((i + j) % 2 == 0) continue;
      set<int> roots;
      vector<int> x;
      REP(dir,4) {
        int ni = i + dx[dir];
        int nj = j + dy[dir];
        if (ni < 0 || nj < 0 || ni >= n || nj >= n) continue;
        x.push_back(get_id(ni, nj));
      }
      for (int k: x) {
        roots.insert(uf.root(k));
      }
      if (int(roots.size()) >= num) {
        res.emplace_back(i, j);
        for (int k: x) {
          uf.unite(k, x[0]);
        }
      }
    }
  }
  cout << res.size() << endl;
  for (auto p: res) cout << p.first << " " << p.second << endl;
  return;
}


Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;int i;cin>>S;
  do{
    S.erase(S.size()-2);
    for(i=0;i<S.size()/2;i++){if(S.at(i)!=S.at(i+S.size()/2))break;}
    if(i==S.size()/2)break;
  }while(1);   
  cout<<S.size()<<endl;
}

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

int main(){
  long N,M,ans;
  scanf("%ld%ld",&N,&M);
  ans=(N-2)*(M-2);

  if (N==1||M==1)
  {
    printf("%d",abs(ans));
  }else{
    printf("%ld",ans);
  }

  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char a[300005],b[300002];
ll r[1000005],w[1000005];
int main()
{
    ll t,n,d,ans=0,i,flag,j,k;

    scanf("%lld",&n);

    scanf("%s",a+1);
    ll x=1,y=1;
    for(i=1; i<=n; i++)
    {
        if(a[i]=='W')
        {
            w[x++]=i;
        }
        if(a[i]=='R')
        {
            r[y++]=i;
        }
    }
    //printf("%lld,%lld\n",x,y);
    for(i=1,j=y-1; i<x; i++)
    {
        if(w[i]<r[j]&&j>1)
        {
            swap(a[w[i]],a[r[j]]);
            j--;

        }
        else
        {
            break;
        }
        ans++;
       //printf("%s %lld %lld \n",a+1,w[i],r[j]);

    }
    flag=0;
    for(i=1; i<=n; i++)
    {
        if(a[i]=='W')
        {
            flag=1;
        }
        if(a[i]=='R'&&flag==1)
        {
            ans++;
        }
    }
    printf("%lld\n",ans);
}


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


int main(){
	std::vector<int> c(9);
    for(int i=0;i<9;i++){
        cin >> c[i];
    }

    if((c[0]+c[4]==c[1]+c[3]) && (c[0]+c[8]==c[2]+c[6]) && (c[4]+c[8]==c[5]+c[7])
    && (c[2]+c[4]==c[1]+c[5]) && (c[2]+c[6]==c[0]+c[8]) && (c[4]+c[6]==c[3]+c[7]) )
            cout << "Yes" << endl;
    else    cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  vector<vector<int>> hss(N, vector<int>(3)), dp(N + 1, vector<int>(3)); for (auto &hs : hss) for (auto &h : hs) cin >> h;
  for (int i = 0; i < N; ++i)
    {for (int j = 0; j <= 2; ++j)
      {for (int k = 0; k <= 2; ++k)
        {if (j != k) dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + hss[i][j]);}}}
  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;}

Measured memory_bytes: 11136