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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define PI 3.141592653589793238
struct Point3D{
  double x,y,z;
  Point3D(){}
  Point3D(double x,double y,double z):x(x),y(y),z(z){}
  Point3D operator+(Point3D p) {return Point3D(x+p.x,y+p.y,z+p.z);}
  Point3D operator-(Point3D p) {return Point3D(x-p.x,y-p.y,z-p.z);}
  Point3D operator*(double k){return Point3D(x*k,y*k,z*k);}
  Point3D operator/(double k){return Point3D(x/k,y/k,z/k);}
  Point3D operator*(Point3D p){
    return Point3D(y*p.z-z*p.y,z*p.x-x*p.z,x*p.y-y*p.x);
  }
  double operator^(Point3D p){
    return x*p.x+y*p.y+z*p.z;
  }
  double norm(){return x*x+y*y+z*z;}
  double abs(){return sqrt(norm());}
  bool operator < (const Point3D &p) const{
    if(x!=p.x) return x<p.x;
    if(y!=p.y) return y<p.y;
    return z<p.z;
  }
  bool operator == (const Point3D &p) const{
    return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS && fabs(z-p.z)<EPS;
  }
};

double dist(Point3D a, Point3D b) {
  return sqrt((pow(a.x-b.x, 2)+pow(a.y-b.y, 2)+pow(a.z-b.z, 2)));
}

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

int main() {
  int n;
  while ( cin >> n, n ) {
    vector<Point3D> c(n);
    vector<double> r(n);
    for ( int i = 0; i < n; i++ ) {
      cin >> c[i].x >> c[i].y >> c[i].z >> r[i];      
    }

    typedef pair<int, int> P;
    typedef pair<double, P> Edge;
    vector<Edge> edges;
    for ( int i = 0; i < n; i++ ) {
      for ( int j = i+1; j < n; j++ ) {
	edges.push_back(Edge(max(0.0, dist(c[i], c[j])-r[i]-r[j]), P(i, j)));	
      }
    }

    UnionFind uf(n);
    sort(edges.begin(), edges.end());
    int cnt = 0;
    double ans = 0;
    for ( int i = 0; i < (int)edges.size(); i++ ) {
      int a = edges[i].second.first, b = edges[i].second.second;
      double c = edges[i].first;
      if ( uf.same(a, b) ) continue;
      uf.unite(a, b);
      ans += c;
      cnt++;
      if ( cnt >= n-1 ) break;
    }

    printf("%.3lf\n", ans);    
  }
}



Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define nl "\n"
typedef long long ll;
using namespace std;

int main()
{
    io;

    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    ll t;
    cin >> t;
    char s[5]= {0};

    int ac=0,wa=0,re=0,tle=0;
    while(t--)
    {
        cin >> s;

        if(strcmp(s,"AC") == 0)
            ac++;
        if(strcmp(s,"WA") == 0)
            wa++;
        if(strcmp(s,"TLE") == 0)
            tle++;
        if(strcmp(s,"RE") == 0)
            re++;

    }
    cout << "AC x " << ac << nl;
    cout << "WA x " << wa << nl;
    cout << "TLE x " << tle << nl;
    cout << "RE x " << re << nl;

    return 0;
}


Measured memory_bytes: 3608
/**
*    author:  yuya1234
*    created: 07.07.2020 09:52:55
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

    int n,m;
    cin>>n>>m;

    vector<int> s[m];
    REP(i,m)
    {
        int k;
        cin>>k;
        REP(j,k)
        {
            int ss;
            cin>>ss;
            ss--;
            s[i].emplace_back(ss);
        }
    }

    int p[m];
    REP(i,m)cin>>p[i];

    int res=0;
    for(int bit=0;bit<(1<<n);bit++)
    {
        int ans=0;
        REP(i,m)
        {
            int cnt=0;
            REP(j,SZ(s[i]))
            {
                if(bit&(1<<s[i][j]))cnt++;
            }
            if(cnt%2==p[i])ans++;
        }
        if(m==ans)res++;
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ios       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,a,n) for (ll i = a; i < (ll)(n); i++)
#define fon(i,n) for (ll i = (ll)n-1; i >=0; i--)
#define vi          vector<ll>
#define vii vector<pair<ll,ll>>
#define all(a)      (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ciin(v) forn(i,0,v.size()) cin>>v[i]
#define coutt(v) forn(i,0,v.size()) cout<<v[i]<<" "
using namespace std; 
int main(){
    ios
    ll t;
    t=1;
    //cin>>t;
    while(t--){
       ll n;
       cin>>n;
       cout<<1000*(n/500)+ 5*((n%500)/5);
        
        

    }}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    int N;
    string S;
    cin>>N;
    cin>>S;

    if (N%2==1){
        cout<<"No"<<endl;
        return 0;
    }

    for (int i = 0; i < int(N/2); ++i) {
        if(S[i]!=S[int(N/2)+i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;


}


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

using namespace std;

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ((r <= x && x <= W - r) && (r <= y && y <= H - r)) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
cout << endl;
}


Measured memory_bytes: 3104
a,b,k = map(int,input().split())

for i in range(k):
    if   i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += a//2
        a = a//2
    elif i%2 == 1:
        if b%2 == 1:
            b -= 1
        a += b//2
        b = b//2
print(a,b)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <string>
#include <tuple>
#include <climits>
#include <cmath>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
const int INF = 987654321;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int main(){
    char c;
    cin >> c;
    if('a'<=c && c<='z')
        printf("a\n");
    else
        printf("A\n");
    return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B, C);
  print((A * 100 + B * 10 + C) % 4 == 0 ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; typedef pair<int, P2> P3;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	int n; cin >> n; long long s = 0, mi = LINF;
	for(int i = 0; i < n; i++){
		long long a, b; cin >> a >> b;
		s += a;
		
		if(a > b) mi = min(mi, b);
	}
	
	if(mi == LINF) cout << 0 << endl;
	else cout << s - mi << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = [deque() for i in range(3)]
for i in range(3):
    a = input()
    for t in a:
        tmp = ord(t)-ord('a')
        s[i].append(tmp)
now = 0
while True:
    if s[now]:
        now = s[now].popleft()
    else:
        print(chr(ord('A') + now))
        break


Measured memory_bytes: 5324
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n, k;
    cin >> n >> k;
    vector <int> a(n);

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

    for (int t = 0; t < k; ++t) {
        bool alln = 1;
        for (int i = 0; i < n; ++i)
            alln &= a[i] == n;
        if (alln)
            break;

        vector <int> l, r;
        for (int i = 0; i < n; ++i) {
            l.app(i - a[i]);
            r.app(i + a[i]);
        }   

        sort(all(l)); sort(all(r));

        for (int i = 0; i < n; ++i) {
            int bad = 0;
            {
            auto t = upper_bound(all(l), i);
            bad += l.end() - t;
            }
            {
            auto t = lower_bound(all(r), i);
            bad += t - r.begin();
            }
            a[i] = n - bad;
        }   
    }   

    for (auto e : a)
        cout << e << ' ';
    cout << endl;
}

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

using namespace std;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a + b + c == 17 && a * b * c == 175){
        printf("YES");
    } else {
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int n,k,d,sum=0;
    ll sum1=0,sum2=0,sum3=0,sum4=0;
    in(n,k);
    vector<int> vec(n);
    rep(i,n){
        in(vec[i]);
        sum1+=(ll)(vec[i]-1);
        sum2+=(ll)(vec[i]-1)/2;
        sum3+=(ll)(vec[i]-1)/3;
        sum4+=(ll)(vec[i]-1)/4;
    }
    if(sum1<=k){
        out(1);
        return 0;
    }
    if(sum2<=k){
        out(2);
        return 0;
    }
    if(sum3<=k){
        out(3);
        return 0;
    }
    if(sum4<=k){
        out(4);
        return 0;
    }
    sort(all(vec));
    int l=4,r=vec[n-1],m=(l+r)/2;
    while(m!=l){
        sum=0;
        for(int i=1;1;i++){
            d=n-(int)(upper_bound(all(vec),(ll)i*m)-vec.begin());
            if(d==0)break;
            sum+=d;
        }
        if(sum<=k)r=m;
        else l=m;
        m=(l+r)/2;
    }
    out(m+1);
}

Measured memory_bytes: 3992
N=int(input())
S=tuple(map(ord,input()))
Q=int(input())
K=map(int,input().split())
D,M,C=map(ord,'DMC')

for k in K:
    ans=0
    d=m=dm=0
    for i in range(min(k-1,N)):
        c=S[i]
        if c==D:
            d+=1
        elif c==M:
            m+=1
            dm+=d
        elif c==C:
            ans+=dm
    for i in range(k-1,N):
        c=S[i]
        if c==D:
            d+=1
        elif c==M:
            m+=1
            dm+=d
        elif c==C:
            ans+=dm
        c=S[i-(k-1)]
        if c==D:
            d-=1
            dm-=m
        elif c==M:
            m-=1
    print(ans)

Measured memory_bytes: 117724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,j,i,sum=0;
    cin >> n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
     for(int i=0;i<n;i++)
    {
        cin >> b[i];
    }
     for(int i=0;i<n-1;i++)
    {
        cin >> c[i];
    }
    int l=0,p=-2;
     for(i=0;i<n;i++)
    {
        j=a[i];
        sum=sum+b[j-1];
        if(j==p+1)
            {
                sum=sum+c[p-1];
            }
        p=j;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
a_list = list(map(int, input().split()))
f_list = list(map(int, input().split()))

a_list.sort()
f_list.sort(key=lambda x :-x)

ng = -1
# 完食時間の最大はA=10**6, F=10**6の時。
ok = 10**12+1

def isok(x):
    # 最大の完食時間がxになるように修行する
    # その場合の修行回数の合計を求める
    # そしてそれがK回以下ならTrueを返す
    cnt = 0
    for a, f in zip(a_list,f_list):
        aprime = x // f
        cnt += max(a - aprime,0)
        
        if cnt > K:
            return False
    return True

while abs(ok-ng)>1:
    x = (ok+ng) // 2
    
    if isok(x):
        # train_cntが限界より多い場合、目指す最大の完食時間が短すぎる
        # よって完食時間を増やすべき
        # Kに等しい場合ももしかしたらもっといい
        ok = x
    else:
        ng = x
        
        
print(ok)

Measured memory_bytes: 122572
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

long long n;

map<long long, int> mem;

int slv(long long num);
int judge(long long num);

int main(){
  ios_base::sync_with_stdio(false);

  cin >> n;

  cout << slv(0) << endl;

  return 0;
}

int slv(long long num){
 
  if(mem.count(num) == 1){
    return mem.at(num);
  }
  
  if(num > n){
    return 0;
  }

  int ret = 0; 

  num *= 10; 
  ret = (slv(num+7) + slv(num+5) + slv(num+3));  

  mem.insert(make_pair(num, ret + judge(num)));
  return mem.at(num);
}

int judge(long long num){

  int f = 0;

  while(num){
    if(num % 10 == 7){
      f = f | 1;
    } else if(num % 10 == 5){
      f = f | 2;
    } else if(num % 10 == 3){
      f = f | 4;
    }
    num /= 10;
  }

  if(f == 7){
    return 1;
  } else {
    return 0;
  }

}


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

int main(){

    int n;
    cin >> n;

    int a[7],A = 1;
    for(int i= 0;i<7;i++){
        a[i] = A;
        A *= 2;
    }
    int ans;
    for(int i = 6;i>=0;i--){
        if(n >= a[i]){
            ans = a[i];
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
q = int(input())

cnt_reverse = False
left = ''
for i in range(q):
  query = input()
  
  if query[0] == '1':
    cnt_reverse = not cnt_reverse
  elif (query[2] == '1' and not cnt_reverse) or (query[2] == '2' and cnt_reverse):
    left = left + query[4]

  else:
    s  = s + query[4]
s = left[::-1] + s
if cnt_reverse:
  s = s[::-1]
print(s)


Measured memory_bytes: 4192
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
 
 
int main(){
  ll A, B;
  cin >> A >> B;
  cout << A * B << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;cin>>r;
    cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

    ll i,j,k,l,m,n,a,b,c,d,cnt=0;
    string s;
    cin>>k>>s;
    l=s.length();
    if(l<=k)
        cout<<s<<endl;
    else
    {
        for(i=0;i<k;i++)
            cout<<s[i];
        cout<<"..."<<endl;

    }

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

ll dp[10005][105][2];

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

    dp[0][0][true] = 0;
    dp[0][0][false] = 1;

    for(int i=1; i<=s.size();i++)
    {
        int cur = s[i-1]-'0';
        for(int remainder=0; remainder<d; remainder++)
        {
            bool ar[2];
            ar[0] = true;
            ar[1] = false;
            for(bool small:ar) 
                for(int j=0;j<10;j++)
                {
                    if(j > cur && !small)
                    {
                        break;
                    }
                    dp[i][(remainder+j)%d][small ||  j<cur] = (dp[i][(remainder+j)%d][small || j<cur ]
                                            + dp[i-1][remainder][small])%mod ;
                }
        }
    }
	
  int ans = (dp[s.size()][0][true] + dp[s.size()][0][false])%mod;
  ans--;
  if(ans<0)
  	ans+=mod;
   cout << ans << endl;

}


Measured memory_bytes: 16640
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
dp = [mod for i in range(2*n)]
dp[0] = 0
p_6 = []
p_9 = []
tmp = 1
while tmp <= n:
    p_6.append(tmp)
    tmp *= 6
tmp = 1
while tmp <= n:
    p_9.append(tmp)
    tmp *= 9


for i in range(n):
    for j in p_6:
        if i+j <= n:
            dp[i+j] = min(dp[i+j],dp[i]+1)
    for k in p_9:
        if i+k <= n:
            dp[i+k] = min(dp[i+k],dp[i]+1)

print(dp[n])


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    long p[n + 1]; REP(i, 1, n + 1) cin >> p[i];

    long ans = 0;
    long m = p[1];
    for(int i = 1; i <= n; i++){
        m = min(m, p[i]);
        if(p[i] <= m) ans++;
    }
    OP(ans);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long int N;
    vector <string> str;
    long long int A = 0,B = 0,AB=0,BA=0;
    string t;
    cin >> N;

    FOR(i,0,N){
        cin >> t;
        if(t[t.length()-1] == 'A' && t[0] != 'B'){
            A++;
        }else if(t[t.length()-1] != 'A' && t[0] == 'B'){
            B++;
        }else if(t[t.length()-1] == 'A' && t[0] == 'B'){
            BA++;
        }
        FOR(j,0,t.length()-1)
            if(t[j]=='A' && t[j+1] == 'B')
                AB++;

    }
    if((A==0 && B==0) && BA!=0) {
        cout << AB + min(A, B) + BA-1;
    }else {
        cout << AB + min(A, B) + BA;
    }
    return 0;
}

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

string str;

char sw(char c) {
    if('A'<=c && c<='Z')return c-'A'+'a';
    if('a'<=c && c<='z')return c-'a'+'A';
    return c;
}

int main(){
	cin.tie(0);
	
	getline(cin, str);
	
	const int l = str.size();
	
	rep(i, l)cout<<sw(str.at(i));
	cout<<endl;
	
	return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

vector<ll> w;
vector<vector<int>> e;
vector<vector<int>> ch;
vector<int> p;

void fail() {
    cout << "NO\n";
    exit(0);
}

void win() {
    cout << "YES\n";
    exit(0);
}

void dfs(int u, int pr) {
    p[u] = pr;
    for (int i : e[u]) {
        if (i == pr) continue;
        ch[u].eb(i);
        dfs(i, u);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    w.resize(n);
    forn(i, 0, n) cin >> w[i];
    e.resize(n);
    forn(i, 1, n) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        e[a].eb(b);
        e[b].eb(a);
    }
    p.resize(n);
    ch.resize(n);
    if (n == 2) {
        if (w[0] == w[1]) win();
        else fail();
    }

    int root = 0;
    while (e[root].size() == 1) ++root;
    dfs(root, -1);
    vector<int> deg(n);
    forn(i, 0, n) deg[i] = e[i].size();
    stack<int> q;
    forn(i, 0, n) if (deg[i] == 1) q.push(i);
    while (!q.empty()) {
        int u = q.top();
        int v = p[u];
        //cerr << u << '\n';
        q.pop();
        --deg[v];
        if (deg[v] == 1 - (v == root)) {
            ll y = w[v];
            ll x = 0;
            for (int i : ch[v]) x += w[i];
            ll b = x - y;
            ll a = y - b;
            //cerr << v << ' ' << a << ' ' << b << '\n';
            if (a < 0 || b < 0) fail();
            w[v] = a;
            ll rest = 0;
            for (int i : ch[v]) {
                if (w[i] > b) {
                    rest += w[i] - b;
                    if (rest > a) {
                        //cerr << "WHAT??" << ' ' << v << '\n';
                    }
                    if (rest > a) fail();
                }
            }
            if (v != root) q.push(v);
            else {
                //win();
                if (w[root] == 0) win();
                else fail();
            }
        }
    }
}


Measured memory_bytes: 18048
N = int(input())

T = 0
X = 0
Y = 0

for i in range(N):
    t, x, y = map(int, input().split())
    dt = t - T
    dx = abs(X - x)
    dy = abs(Y - y)
    dis = dx + dy
    if dt < dis:
        print("No")
        break
    if (dt - dis) % 2 == 1:
        print("No")
        break
    T = t
    X = x
    Y = y
else:
    print("Yes")


Measured memory_bytes: 9212
#include<iostream>
#include<queue>
#include<vector>
#define INF (int)1e9 + 7
using namespace std;
int n;
vector<pair<int, int> > adj[10000];
void dijkstra();
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v; //vertex cost
            cin >> v;
            adj[u].push_back(make_pair(1, v));
        }
    }
    dijkstra();
    return 0;
}
void dijkstra() {
    int dist[n + 1];
    dist[1] = 0;
    for (int i = 2; i <= n; i++) {
        dist[i] = INF;
    }
    priority_queue<pair<int, int> > q;
    q.push(make_pair(0, 1));
    while (!q.empty()) {
        int u = q.top().second;
        //int co = -q.top().first;
        q.pop();
        for (int i = 0; i < adj[u].size(); i++) {
            int v = adj[u][i].second; //adj[u]のi番目の番号
            int co2 = adj[u][i].first;
            if (dist[u] + co2 < dist[v]) {
                dist[v] = co2 + dist[u];
                q.push(make_pair(-dist[v] ,v));
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << i << " ";
        if (dist[i] == (int)1e9 + 7) {
            cout << -1 << endl;
        } else {
            cout << dist[i] << endl;
        }
    }
}



Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);
  int n;
  cin>>n;
  vector<int> x(n),y(n);
  for(int i =0;i<n;i++)
  {
    cin>>x[i]>>y[i];
  }
        long long ans = 0, smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0] + 0;
                for (int i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i];
                    ans = max(ans, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
  cout<<ans;
return 0;
}


Measured memory_bytes: 4780
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; int k; cin >> n >> k;
  vector<int> d(k);
  rep(i,k) cin >> d[i];
  set<int> st={0,1,2,3,4,5,6,7,8,9};
  rep(i,k){
    st.erase(d[i]);
  }
  for(int i=n;i<100000;i++){
    string s=to_string(i);
    bool flag=1;
    int l=s.size();
    rep(j,l){
      if(!(st.count(s[j]-'0'))) flag=0;
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

Counts = []
for i in range(len(S)-len(T)+1):
    cnt = 0
    Q = S[i:i + len(T)]
    for j in range(len(T)):
        if T[j] == Q[j]:
            cnt += 1
    Counts.append(cnt)

ans = len(T) - max(Counts)
print(ans)

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
signed main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	int x=a/d;
	if(a%d!=0)
	{
		x++;
	}
	int y=c/b;
	if(c%b!=0)
	{
		y++;
	}
	if(x>=y)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  string s,t,u;
  s="Sunny",t="Cloudy",u="Rainy";
  string h;
  cin >> h;
  if(h==s) cout << t << endl;
  if(h==t) cout << u << endl;
  if(h==u) cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
int pre[200005][25], nxt[200005][25], dp_l[800005], dp_r[800005], arr[200005];
int main()
{
	// freopen("AGC012-F.in", "r", stdin);
	int n, v, len = 0;
	scanf("%d%d", &n, &v);
	for (int i = 1; i <= n; i++)
		scanf("%d", arr + i);
	while (true)
	{
		pre[0][len] = pre[1][len] = 0;
		for (int i = 2; i <= n; i++)
			pre[i][len] = arr[i] - arr[i - 1] <= v ? pre[i - 1][len] : i - 1;
		nxt[n + 1][len] = nxt[n][len] = n + 1;
		for (int i = n - 1; i >= 1; i--)
			nxt[i][len] = arr[i + 1] - arr[i] <= v ? nxt[i + 1][len] : i + 1;
		len++;
		if (!v)
			break;
		v >>= 1;
	}
	for (int i = 0; i < 1 << len; i++)
	{
		dp_l[i] = 1;
		dp_r[i] = n;
	}
	for (int i = 0; i < 1 << len; i++)
	{
		for (int j = 0; j < len; j++)
		{
			if (i & (1 << j))
				continue;
			dp_l[i | (1 << j)] = std::max(dp_l[i | (1 << j)], nxt[dp_l[i]][j]);
			dp_r[i | (1 << j)] = std::min(dp_r[i | (1 << j)], pre[dp_r[i]][j]);
		}
	}
	if (dp_l[(1 << len) - 1] <= n)
	{
		for (int i = 0; i < n; i++)
			puts("Impossible");
		return 0;
	}
	for (int l = 1; l <= n; l = nxt[l][0])
	{
		bool flg = false;
		for (int i = 0; i < 1 << len && !flg; i++)
		{
			if (i & 1)
				continue;
			if (l <= dp_l[i] && dp_r[(1 << len) - 1 ^ i ^ 1] < nxt[l][0])
				flg = true;
		}
		for (int i = l; i < nxt[l][0]; i++)
			puts(flg ? "Possible" : "Impossible");
	}
	return 0;
}


Measured memory_bytes: 48384
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
 
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++);
#define F0R(i, a) for (int i=0; i<(a); i++);
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;

 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int M[10][10];
	for(int i=0; i<3; i++)
	{
		for(int j=0; j<3; j++)
		{
			cin>>M[i][j];
		}
	}
	
	int n; cin>>n;
	int N[11];
	for(int i=0; i<n; i++)
	{
		cin>>N[i];
	}
	for(int i=0; i<3; i++)
	{
		for(int j=0; j<3; j++)
		{
			for(int k=0;k<n;k++)
			{
				if(N[k]==M[i][j])
				{
					M[i][j]=-1;
				}
			}
		}
	}
	if(M[0][0]==-1 && M[0][1]==-1 && M[0][2]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(M[1][0]==-1 && M[1][1]==-1 && M[1][2]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(M[2][0]==-1 && M[2][1]==-1 && M[2][2]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(M[0][0]==-1 && M[1][0]==-1 && M[2][0]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(M[0][1]==-1 && M[1][1]==-1 && M[2][1]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(M[0][2]==-1 && M[1][2]==-1 && M[2][2]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(M[0][0]==-1 && M[1][1]==-1 && M[2][2]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(M[0][2]==-1 && M[1][1]==-1 && M[2][0]==-1 )
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10 for i in range(n)]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i - j]))
print(dp[n-1])


Measured memory_bytes: 89764
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
 
int32_t main()
{
    IOS;
    cin>>n;
    set<string> st;
    forn(i,n){
      string s;
      cin>>s;
      st.insert(s);
    }
    cout<<st.size()<<ln;
}


Measured memory_bytes: 19204
//
//  main.cpp
//  179-C
//
//  Created by Parsa Alimohammadi on 6/31/1399 AP.
//  Copyright © 1399 Parsa Alimohammadi. All rights reserved.
//

#define ll long long
#define ldu long double
#define pb push_back
#define pop pop_back()
#define du double
// --------------------------------------------------------------
/*
 #define paii pair<int , int>
 #define pasi pair<string,int>
 #define F first
 #define S second
 */
// --------------------------------------------------------------
#define input_txt freopen("input.txt" , "r" , stdin);
#define output_txt freopen("output.txt" , "w" , stdout);
#define Shield  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug cout << "REAlY!! ";
// #define ashar cout << fixed << setprecision(tedad ashaar) << adadet ke bayad double bashe << endl;

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
// #include<bits/stdc++.h>

using namespace std;

const int maxn = 1e6 * 1 + 2;
int n;


int main()
{
    Shield
    cin >> n;
    ll int ans=0;
    for (int i=1; i<n; i++)
        ans += (((n+(i-1))/i)-1);
    cout << ans;
    
    return 0;
}



Measured memory_bytes: 3660
#include <complex>
#include <vector>
#include <cstdio>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int main(){
	double x,y;
	int q;
	scanf("%lf%lf",&x,&y);P p0(x,y);
	scanf("%lf%lf%d",&x,&y,&q);P p1(x,y);
	for(;q--;){
		scanf("%lf%lf",&x,&y);P p(x,y);
		P t=(p1-p0)*dot(p1-p0,p-p0)/norm(p1-p0)+p0;
		P s=p+(t-p)*2.0;
		printf("%.9f %.9f\n",real(s),imag(s));
	}
}

Measured memory_bytes: 1116
use std::error::Error;
use std::io::{self, BufReader};
use std::io::prelude::*;
use std::str::{self, FromStr};

fn exec() {
    let mut sc = Scanner::new(io::stdin());
    let n: usize = sc.ne();
    let a: Vec<i32> = (0..n).map(|_| sc.ne()).collect();
    let (mut cnt2, mut cnt4) = (0, 0);
    for &x in &a {
        if x % 4 == 0 {
            cnt4 += 1;
        } else if x % 2 == 0 {
            cnt2 += 1;
        }
    }
    let other = n - cnt4 - cnt2;
    if other <= cnt4 || (cnt2 == 0 && other == cnt4 + 1) {
        println!("Yes");
    } else {
        println!("No")
    }
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
pub struct Scanner<R> {
    bufread: BufReader<R>,
    id: usize,
    buf: Vec<u8>,
}
impl<R: Read> Scanner<R> {
    pub fn new(resource: R) -> Scanner<R> {
        Scanner {
            bufread: BufReader::new(resource),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.bufread.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    pub fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.is_empty() {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert_ne!(self.buf[l], b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!(
                    "parse error, {:?}",
                    String::from_utf8(self.buf[l..r].to_owned())
                )
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    pub fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 10620
#include<stdio.h>
int main(void){
    int N,R,L;
    scanf("%d %d",&N,&R);
    if(N<10){
        L=R-100*N+1000;
        printf("%d",L);
    }
    else
    {
        printf("%d",R);
    }
    return 0;
}

Measured memory_bytes: 128
n, k =map(int, input().split()) 
s = input()
count = 0
even =0
for i in range(n-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        even +=1

for i in range(k):
        if even >= 2:
            count +=2
            even -= 2
        elif even ==1:
            count+=1
            even -=2
print(str(count))

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                int x = list[i], y = list[j], z = list[k];
                if (x == y || y == z || z == x)
                    continue;
                if (x < y + z && y < x + z && z < x + y)
                    ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(a,x.size()) cout << x[a] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

int main() {
    ll k, a, b; cin >> k >> a >> b;
    k++;
    if (b <= a+2) cout << k << endl;
    else {
        k -= a;
        ll ans = a;
        while (true) {
            ll ct = ans/a;
            ct = min(ct,k/2);
            if (ct == 0) break;
            k -= 2*ct;
            ans = (ans-ct*a)+ct*b;
        }
        cout << ans+k << endl;
    }
}

Measured memory_bytes: 3572
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

count = 0

for i in range(N):
  A = list(map(int, input().split()))
  
  if sum([a * b for a, b in zip(A, B)]) + C > 0:
    count += 1
    
print(count)
      	
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+5, M = 1e4+5, OO = 0x3f3f3f3f;
typedef  long long LL;
typedef  long double LD;
#define PI 3.14159265358979323846
#define INF LONG_MAX
const int  MOD = 1e9+7;
int main()
{
    int a[3]; cin>>a[0]>>a[1]>>a[2];
    swap(a[0],a[2]);
    swap(a[1],a[2]);
    for (int i=0; i<3; ++i) cout<<a[i]<<" ";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >> s;

  int ans = 1;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s.at(i) != s.at(i + 1)) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(s: str):
    print(s[0::2])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define umii unordered_map<ll,ll> 
#define umib unordered_map<ll,bool>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	ll D,T,S;
	cin>>D>>T>>S;
	double sp = D/(T*1.0);
	if(sp>S)
	{
	    cout<<"No"<<'\n';
	    
	}
	else
	{
	    cout<<"Yes"<<'\n';
	}
	
	
	return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
stack<int>st;
signed main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (st.empty())st.push(s[i]);
		else if (st.top() == 'S'&&s[i] == 'T') {
			st.pop();
		}
		else {
			st.push(s[i]);
		}
	}
	cout << st.size() << endl;
}

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

const long long mod = 1e9 + 7;

long long s (long long n) {
	return (n * (n + 1)) / 2LL;
}

signed main () {
	long long n, k;
	cin >> n >> k;
	long long ans = 0;
	while (k <= n + 1) {
		if (k == n + 1)
			(ans += 1) %= mod;
		else 
			(ans += (s(n) - s(n - k)) - s(k - 1) + 1) %= mod;
		++k;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0)break;
        for(int i = 0; i < H; i++ ){
            for(int j = 0; j < W; j++ ){
                if((i+j)%2==0){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }cout << endl;
        }
        cout << endl;
    }
    return 0;
}


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

int main() {
  bool n = false,s = false,w = false,e = false;
  string st;
  cin >> st;
  for(int i = 0;i < st.size();i++){
    if(st[i] == 'N') n = true;
    if(st[i] == 'S') s = true;
    if(st[i] == 'W') w = true;
    if(st[i] == 'E') e = true;
  }
  if((n && !s)||(!n && s)){
    cout << "No" << endl;
    return 0;
  }
  if((w && !e)||(!w && e)){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int is_siritori(char f[10], char s[10])
{
  int i = 0;
  while(f[i])
  {
    i++;
  }
  i -= 1;
  if (f[i] != s[0])
  {
    printf("NO");
    return (0);
  }
  else
    return (1);
}

int main()
{
  char a[10],b[10],c[10];
  scanf("%s%s%s",&a,&b,&c);
  if (!(is_siritori(a,b)))
    return (0);
  if (!(is_siritori(b,c)))
    return(0);
  printf("YES");
    
}

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

long double radian(long double degree) {
  return degree * (M_PI / 180.0l);
}

int main(){
  long double a, b, h, m;

  cin >> a >> b >> h >> m;
  long double hrad = radian((h * 30.0l)+(30.0l*(m/60.0)));
  long double mrad = radian(m * 6.0l);

  long double ax = a * cos(hrad);
  long double ay = a * sin(hrad);

  long double bx = b * cos(mrad);
  long double by = b * sin(mrad);

  cout << std::setprecision(20) << hypot(ax-bx, ay-by) << endl;
  return 0;
}


Measured memory_bytes: 4188