akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int i = 0; i < n; i++ ){ cout << x[i] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
// const ll MOD = 1e9+7;
ll MOD;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int h, w;

string s[512];

int main(){

  h = in();
  w = in();
  REP( i , h ){
    s[i] = stin();
  }

  REP( i , w ){
    printf( "#" );
  }
  printf( "\n" );
  FOR( i , 1 , h-1 ){
    REP( j , w ){
      if( j % 2 == 0 or s[i][j] == '#' ){
	printf( "#" );
      } else {
	printf( "." );
      }
    }
    printf( "\n" );
  }
  REP( i , w ){
    printf( "." );
  }
  printf( "\n" );

  printf( "\n" );


  REP( i , w ){
    printf( "." );
  }
  printf( "\n" );
  FOR( i , 1 , h-1 ){
    REP( j , w ){
      if( j % 2 == 1 or s[i][j] == '#' ){
	printf( "#" );
      } else {
	printf( "." );
      }
    }
    printf( "\n" );
  }
  REP( i , w ){
    printf( "#" );
  }
  printf( "\n" );

  
  return 0;
}


Measured memory_bytes: 1024
n= gets.strip.to_i
as = gets.strip.split.map(&:to_i)
flag = true
gn = []

as.each do |a|
  if a%2 == 0
    gn.push(a)
  end
end
gn.each do |g|
  if g%3 != 0 && g%5 != 0
    flag = false
    break
  end
end
 
if flag
  puts 'APPROVED'
else
  puts 'DENIED'
end

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int s;cin>>s;
    map<int,bool> m;
    int c=s;
    int count=1;
    while(!m[c]){
        m[c]=true;
        c=(c%2==0?c/2:3*c+1);
        count++;
    }
    cout<<count<<endl;
}

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

int main() {
#ifdef DEBUG
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int a, b; cin >> a >> b;
    if (b == 1) {
        cout << "0\n";
        return 0;
    }
    int sum = a, cnt = 1;
    while (sum < b) {
        sum += a - 1;
        cnt++;
    }
    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 256
s = input()
k = int(input())
cnt = 0
cntw = 0
cntwflg = False
i = 0

if len(s) == 1:
    print(k//2)
    exit()

if len(list(set(s))) == 1:
    print((k*len(s))//2)
    exit()
while True:
    # print('i, s[i] ', i, s[i])
    if len(s)-1 < i:
        break
    if len(s)-1 == i:
        if s[i] == s[0]:
            cntw = 1
            if s[i-1]==s[i-2]:
                j = 0
                while s[j] == s[j+1]:
                    if j%2 == 0:
                        cntw = 0
                    else:
                        cntw = 1
                    j += 1
    elif s[i] == s[i+1]:
        cnt+= 1
        i += 1
    i += 1


ans = cnt*k+cntw*(k-1)
print(ans)

Measured memory_bytes: 38756
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int a[512], p;

int dfs(int n, int c){
  if(n > 21) return 0;
  if(c == p) return n;
  if(a[c] == 1) return max(dfs(n+1, c+1), dfs(n+11, c+1));
  if(a[c] > 10) return dfs(n+10, c+1);
  return dfs(n+a[c], c+1);
}

int main(){
  char str[512];
  while(fgets(str, sizeof(str), stdin) && str[0] != '0'){
    memset(a, 0, sizeof(a));
    char *tp;
    p = 0;
    tp = strtok(str, " ");
    while(tp != NULL){
      a[p++] = atoi(tp);
      tp = strtok(NULL, " ");
    }

    printf("%d\n", dfs(0, 0));
  }
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;

	int ans = 0;
	rep(i, N - 1) {
		for (int j = i + 1 + ans; j < N - ans; j++) {
			for (int l = ans + 1; l <= min(j - i, N - j); l++) {
				bool chk = true;
				rep(k, l) {
					if (S[i + k] != S[j + k]) {
						chk = false;
						break;
					}
				}
				if (chk) {
					ans = max(ans, l);
				}
				else {
					break;
				}
			}
		}
	}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s, t;
  cin >> s >> t;
  bool ok = true;
  if(s.size() + 1 != t.size()) ok = false;
  t.pop_back();
  if(s != t) ok = false;
  cout << (ok ? "Yes" : "No") << endl;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {

  vector<mint> fact, ifact;

  combination(int n):fact(n+1),ifact(n+1) {

    assert(n < mod);

    fact[0] = 1;

    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;

    ifact[n] = fact[n].inv();

    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;

  }

  mint operator()(int n, int k) {

    if (k < 0 || k > n) return 0;

    return fact[n]*ifact[k]*ifact[n-k];

  }

};

int main(){
int x,y; cin >> x >> y;
int n;
n=x+y;
if(!(n%3)){
    int mi=min(x,y);
    int ma=max(x,y);
  	int mii = mi*2;
    if(mii>=ma){
        combination c(x+y);
        int times = n/3;
        int bi = ma-mi;
        int fl = (mi-bi)/3;
        mint ans = c(times,fl);
        cout << ans.x << endl;
    }
    else {
        cout << 0 << endl;
    }
}
else{
    cout << 0 << endl;
}
return 0;
}


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

using namespace std;

typedef long long int64;

int64 combination[61][61];

int main()
{
  for(int i = 0; i < 61; i++) {
    combination[i][0] = combination[i][i] = 1;
    for(int j = 1; j < i; j++) {
      combination[i][j] = combination[i - 1][j - 1] + combination[i - 1][j];
    }
  }

  int64 N, M;
  while(cin >> N >> M, N) {
    int bit = 0;
    while(M - combination[N][bit] > 0) {
      M -= combination[N][bit++];
    }
    while(N--) {
      if(bit > 0 && M - combination[N][bit] > 0) {
        M -= combination[N][bit];
        --bit;
        cout << 1;
      } else {
        cout << 0;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3020
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template <int size>
class UnionFind {
public:
    UnionFind() {
        for (int i = 0; i < size; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (parent[x] == x) {
            return x;
        } else {
            return parent[x] = find(parent[x]);
        }
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        parent[y] = x;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

private:
    int parent[size];
};

UnionFind<100000> uf;

int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<int, int>> br(m);
    for (auto &e: br) cin >> e.first >> e.second;

    reverse(br.begin(), br.end());
    vector<ll> ans(m);
    ans[0] = n * (n-1) / 2;

    vector<int> cc(n+1, 1);
    for (int i = 0; i < m-1; ++i) {
        if (uf.same(br[i].first, br[i].second)) {
            ans[i+1] = ans[i];
            continue;
        }
        int a = uf.find(br[i].first);
        int b = uf.find(br[i].second);
        ans[i+1] = ans[i] - cc[a] * cc[b];
        uf.unite(br[i].first, br[i].second);
        cc[a] += cc[b];
    }

    for (auto it = ans.rbegin(); it != ans.rend(); ++it) {
        cout << *it << endl;
    }

    return 0;
}


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

int main() {
	int N[3], five = 0, seven = 0;
	cin >> N[0] >> N[1] >> N[2];
	for (int i = 0;i < 3;i ++) {
		if (N[i] == 5) five ++;
		else if (N[i] == 7) seven ++;
	}
	if (five == 2 && seven == 1) cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nab = scanner.nextLine().split(" ", 3);
        int n = Integer.parseInt(nab[0]);
        int a = Integer.parseInt(nab[1]);
        int b = Integer.parseInt(nab[2]);

        int plan1 = a * n;
        int plan2 = b;
        System.out.println(Math.min(plan1, plan2));
    }
}


Measured memory_bytes: 21844
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
X=[A,B,C,D,E]
Y=[]
for i in range(5):
  Y.append((((-1)*X[i])//10)*(-10))

ans=sum(Y)
for i in range(5):
  x=sum(Y)-Y[i]+X[i]
  ans=min(ans,x)
print(ans)

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

struct cake
{
  int64_t x, y, z;
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<cake> v(n);

  for (auto&& e : v) {
    cin >> e.x >> e.y >> e.z;
  }

  int64_t ans = 0;

  for (uint i = 0; i < 8; i++) {
    vector<int64_t> sum(n);
    int64_t a = (i & 1) == 0 ? 1 : -1;
    int64_t b = (i & 2) == 0 ? 1 : -1;
    int64_t c = (i & 4) == 0 ? 1 : -1;
    for (auto j = 0; j < n; j++) {
      sum[j] = a * v[j].x + b * v[j].y + c * v[j].z;
    }
    sort(begin(sum), end(sum), greater<>());
    int64_t x = 0;
    for (auto k = 0; k < m; k++) {
      x += sum[k];
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

	string s,t;
	cin >> s >> t;
	int cnt = 0;
	rep(i,s.size()){
		if(s[i]!=t[i])cnt++;
	}

	cout << cnt << endl;


	return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
int pa[111111],id[111111],cnt;
bool used[111111];
int n,m,x,y,z;
vector<pair<int,int> > g[1111111];
vector<int> gra[1111111];
void Init(int i)
{
	pa[i]=i;
	used[i]=0;
	id[i]=-1;	
}
int root(int x)
{
	if (pa[x]!=x) pa[x]=root(pa[x]);
	return pa[x];
}
void Union(int x,int y)
{
	int rx=root(x),ry=root(y);
	if (rx==ry) return;
	pa[rx]=ry;
}
queue<int> q;
int dist[1111111];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		g[z].push_back(make_pair(x,y)); 
	}
	cnt=n;
	memset(id,-1,sizeof(id));
	for (int i=1;i<=1000000;i++)
	{
		for (int j=0;j<g[i].size();j++)
		{
			Init(g[i][j].first);
			Init(g[i][j].second);
		}
		for (int j=0;j<g[i].size();j++)
		{
			Union(g[i][j].first,g[i][j].second);
		}
		for (int j=0;j<g[i].size();j++)
		{
			x=g[i][j].first;y=g[i][j].second;
			if (!used[x])
			{
				int r=root(x);
				if (!~id[r]) id[r]=++cnt;
				used[x]=1;
				gra[x].push_back(id[r]);
				gra[id[r]].push_back(x); 
			}
			if (!used[y])
			{
				int r=root(y);
				if (!~id[r]) id[r]=++cnt;
				used[y]=1;
				gra[y].push_back(id[r]);
				gra[id[r]].push_back(y);  
			}
		}
	}
	memset(dist,-1,sizeof(dist));
	q.push(1);dist[1]=0;
	while(!q.empty())
	{
		x=q.front();q.pop();
		for (int i=0;i<gra[x].size();i++)
		{
			int to=gra[x][i];
			if (!~dist[to])
			{
				dist[to]=dist[x]+1;
				q.push(to); 
			}
		}
	}
	if (!~dist[n]) printf("-1\n");
	else printf("%d\n",dist[n]/2);
	return 0;
}

Measured memory_bytes: 73600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int N,M;    cin>>N>>M;
    vector<int> k(M,0);
    vector<vector<int>> s(11,vector<int> (11,0));
    for(int i=0;i<M;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(M,0);
    for(int i=0;i<M;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int bit=0;bit<(1<<N);bit++){    //全通り
        int countp=0;
        for(int i=0;i<M;i++){   //電球i
            int counts=0;
            for(int j=0;j<k[i];j++){    //スイッチごと
                if(bit >> s[i][j]&1) {
                    counts++;
                }
            }
            if(counts%2==p[i]){
                countp++;
            }
        }
        if(countp==M){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

int main(){
    ll k,ans;
    cin>>k;
    queue<ll> q;
    rep(i,1,10) q.push(i);
    rep(i,0,k){
        ans=q.front();
        q.pop();
        if(ans%10)q.push(ans*10+ans%10-1);
        q.push(ans*10+ans%10);
        if(ans%10!=9)q.push(ans*10+ans%10+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
s=input()

while True:
    if s.endswith('dream'):
        s = s[:-5]
    elif s.endswith('dreamer'):
        s = s[:-7]
    elif s.endswith('eraser'):
        s = s[:-6]
    elif s.endswith('erase'):
        s = s[:-5]
    else:
      print("NO")
      quit()
    if s=="":
      break
print("YES")      

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;

    vector<int>B(M);

    for(int i=0; i<M; i++){
        cin >> B[i];
    }

    vector<int>A(M);

    int A_sum=C, ans=0;

    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cin >> A[j];
            A_sum += A[j]*B[j];
        }
        if( A_sum > 0 ) ans++;
        A_sum = C;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,a[101];
int main(){
    I(n);
    REP(i,n) I(a[i]);
    int ret = 0;
    REP(i,n-1){
        if(a[i] == a[i+1]){
            ret++; i++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
n, a, b = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)

if b <= a
  puts b * (n - 1)
  exit
else
  res = 0
  d = b / a
  x.each_cons(2) do |i, j|
    if j - i <= d
      res += a * (j - i)
    else
      res += b
    end
  end
  puts res
end

Measured memory_bytes: 21796
#include<stdio.h>
#include <cmath>
#include<string.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    long ans = 0;
    int n = s.size();
    for (int x =0 ; x < 1 << (n-1); ++x) {
        long acc = 0;
        for (int i=0; i<n;i++) {
            acc *= 10;
            acc +=s[i] - '0';
            if ((x&(1<<i)) ==0) {
                ans += acc;
                acc = 0;
            }
        }
        ans += acc;
    }
    cout << ans << endl;
}

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

n, m = map(int, input().split(' '))

WAs = [0] * n
correct = 0
penalty = 0
for i in range(m):
    p, s = input().strip().split(' ')
    p = int(p) - 1
    if WAs[p] == -1:
        continue
    if s == 'AC':
        penalty += WAs[p]
        correct += 1
        WAs[p] = -1
    else:
        WAs[p] += 1

print(correct, penalty)


Measured memory_bytes: 41744
#include "bits/stdc++.h"
using namespace std;

int main() {

        int n; scanf("%d", &n);

        for(int i = 1; i <= n; i++) {
                double x = 1.08 * (double)i;
                x = floor(x);

                if( x == (double) n ) {
                        printf("%d\n", i);
                        return 0;
                }
        }
        puts(":(");

        return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			int N = in.nextInt();
			int P = in.nextInt();
			if(N == P && N == -1)break;
			List<Integer> list = new ArrayList<Integer>();
			N++;
			while(list.size() < 100){
				boolean flg = true;
				if(N == 1)flg = false;
				for(int k = 2; k * k <= N; k++){
					if(N % k == 0){
						flg = false;
						break;
					}
				}
				if(flg)list.add(N);
				N++;
			}
			//		for(int i = 0; i < list.size(); i++){
			//			System.out.println(list.get(i));
			//		}
			List<Integer> array = new ArrayList<Integer>();
			for(int i = 0; i < list.size(); i++){
				for(int k = 0; k <= i; k++){
					array.add(list.get(i) + list.get(k));
				}
			}
			Collections.sort(array);
			//		for(int i = 0; i < array.size(); i++){
			//			System.out.println(array.get(i));
			//		}
			System.out.println(array.get(P - 1));
		}
	}
}

Measured memory_bytes: 102752
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	int k;
	cin >> k;
	queue<string> que;
	rep2(i,1, 10) que.push(to_string(i));
	rep(i,k-1){
		string a = que.front();
		que.pop();
		if (a.back() == '0')
		{
			que.push(a+to_string(a.back() - '0'));
			que.push(a+to_string(a.back() - '0' + 1));
		}
		else if (a.back() == '9')
		{
			que.push(a+to_string(a.back() - '0' - 1));
			que.push(a+to_string(a.back() - '0'));
		} else {
			que.push(a+to_string(a.back() - '0' - 1));
			que.push(a+to_string(a.back() - '0'));
			que.push(a+to_string(a.back() - '0' + 1));
		}
	}
	cout << que.front() << endl;
	return 0;
}

Measured memory_bytes: 10752
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  long N;
  in(N);
  long sum=0;
  long i=1;
  for(;;){
    sum+=i;
    if(sum>=N){
      long e=sum-N;
      rep(j,i){
        if(j+1==e)continue;
        out(j+1);
      }
      return;
    }
    i++;
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int cnt = 0;
			while(sc.hasNext()) {
				String str = sc.next();
				StringBuffer sb = new StringBuffer(str);
				if(str.equals(sb.reverse().toString())) {
					cnt++;
				}
			}
			System.out.println(cnt);

			
		}
	}
}






Measured memory_bytes: 25880
H,W,D = map(int,input().split())
A = [[]]
for i in range(H):
  A.append([0]+list(map(int,input().split())))
la = [[] for o in range(H*W+1)]
for i in range(1,H+1):
  for j in range(1,W+1):
    la[A[i][j]].append(i)
    la[A[i][j]].append(j)
Q = int(input())
q = []
for i in range(Q):
  q.append(list(map(int,input().split())))

l = [[0]+[0 for i in range((H*W-j)//D)] for j in range(D)]
#あまり0は特別扱い
i = 0
v = l[i]
for j in range(1,len(l[0])-1):
  mae = i + D*j
  ato = i + D*(j+1)
  v[j+1] = v[j] + abs(la[mae][0]-la[ato][0]) + abs(la[mae][1]-la[ato][1])
#あまり1~D-1まで
for i in range(1,D):
  v = l[i]
  for j in range(len(v)-1):
    mae = i + D*j
    ato = i + D*(j+1)
    v[j+1] = v[j] + abs(la[mae][0]-la[ato][0]) + abs(la[mae][1]-la[ato][1])

for i in range(Q):
  L,R = q[i][0],q[i][1]
  amari = L%D
  haji = (L-amari)//D
  owari = (R-amari)//D  
  print(l[amari][owari]-l[amari][haji])

Measured memory_bytes: 51212
#include <stdio.h>
int main(){

  int a, b, r, tmp;
  scanf("%d %d",&a,&b);

  if(a < b){
    tmp = a;
    a =b;
    b = tmp;
  }

  r = a % b;

  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }

  printf("%d\n",b);
  return 0;
}

Measured memory_bytes: 592
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

char field[8][8];

int main(){
	rep(i, 8)rep(j, 8) cin >> field[i][j];
	cout << 90 << endl;
	rep(i, 8){
		rep(j, 8) cout << field[7-j][i];
		cout << endl;
	}
	cout << 180 << endl;
	rep(i, 8){
		rep(j, 8) cout << field[7-i][7-j];
		cout << endl;
	}
	cout << 270 << endl;
	rep(i, 8){
		rep(j, 8) cout << field[j][7-i];
		cout << endl;
	}
	return 0;
}
		

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int X;
    int N;
    cin >> X;
    cin >> N;
    vector<int> v(N);
    REP(i,N) cin >> v[i];
    int mini = INF;
    int ans = INF;
    FOR(i,0,102) {
        bool found = false;
        for(const auto &it: v) if(it == i) found = true;
        if (found) continue;
        if(chmin(mini,abs(i-X))) ans = i;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


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

int main(int argc, char **argv)
{
	ll N, C, K; cin >> N >> C >> K;
	vector<ll> T(N); for (ll i = 0; i < N; ++i) cin >> T[i];

	sort(T.begin(), T.end());
	
	ll left;
	ll c_bus{0};
	for (ll i = 0; i < N;)
	{
		left = T[i];
		ll j = i+1;
		ll c{1};
		for (; j < N; ++j)
		{
			if (c+1 > C) break;
			if (T[j] - left > K) break;
			++c;
		}
		i = j;
		++c_bus;
	}
	std::cout << c_bus << std::endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
 using namespace std;
#define ll long long
int main(){
    int n,w;
    cin>>n>>w;
    int a[2][n];
    ll dp[w+1];
    for(int i=0;i<n;i++)cin>>a[0][i]>>a[1][i];
    for(int i=0;i<=w;i++) dp[i]=0;
    ll mx=0;
    for(int i=0;i<n;i++)
    {  
        for(int j=w;j>=1;j--){
            if(j>a[0][i] && dp[j-a[0][i]]!=0 ){ dp[j]=max(dp[j],dp[j-a[0][i]]+(ll)a[1][i]); }
            else if(j==a[0][i] ) dp[j]=max(dp[j],(ll)a[1][i]); 
                        mx=max(mx,dp[j]);
        }
    }
    cout<<mx<<endl;
    return 0;
}

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

int main(){
    int n[4],f[10]={};
    for(int i=0;i<4;i++){
        scanf("%d",&n[i]);
        f[n[i]]=1;
    }
    if(f[1]&&f[9]&&f[4]&&f[7]){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace CF2016A_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLine();
            for (int i = 0; i < 12; i++)
            {
                Write(s[i]);
                if (i == 3) Write(" ");
            }
            Console.WriteLine();
        }

        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
}


Measured memory_bytes: 2648
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final int[] array = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = scanner.nextInt();
        }

        int count = 0;
        for (int i = 1; i < n; i++) {
            if (array[i] == i) {
                int tmp = array[i];
                array[i] = array[i + 1];
                array[i + 1] = tmp;
                count++;
            }
        }
        if (array[n] == n) {
            count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 52416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
int main()
{
	int a[5];int maxx=0;int sum=0;
	for(int i=0;i<5;i++) 
	{
		cin>>a[i];int tmp=a[i]%10;
		if(tmp<(a[maxx]%10) && tmp!=0) maxx=i;
	}
	for(int i=0;i<5;i++)
	{
		if(i==maxx) sum+=a[i];
		else 
		{
			sum+=((a[i]-1)/10+1)*10;
		}
	}
	cout<<sum<<endl;
 } 

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, x) for (int i = 1, _##i = (x); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repi(i, x) for (auto &i : (x))


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pdd;
typedef pair<ll, ll> pll;

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N, K;
int A[100];

int test(int a, int b) {
    if (a+b > K or a+b > N) return -INF;
    vector<int> s;
    rep(i, a) s.pb(A[i]);
    rep(i, b) s.pb(A[N-1-i]);

    int rem = K-a-b;
    sort(s.begin(), s.end());

    int tot = accumulate(s.begin(), s.end(), 0);

    rep(i, min(rem, sz(s))) if (s[i] < 0) {
        tot -= s[i];
    } else break;

    return tot;
}

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> K;
    rep(i, N) cin >> A[i];

    int mv = -INF;
    rep(i, N+1) rep(j, N+1) get_max(mv, test(i, j));

    cout << mv << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1 + (int) 1e6;

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

    sort(A,A+N);
    int ans=0;

    int AA[NMAX]={};

    for(int i=0; i<N; i++){
        bool flag = true;
        if(i>0){
            AA[A[i-1]]++;
        }
        if(A[i]==A[i+1]) continue;
        int k = (int) sqrt((double) A[i]);
        for(int j=1; j<= k ; j++){
            if( AA[j] > 0 && A[i]%j == 0 ){
                flag=false;
                //cout << "A[i] " << A[i] << " \% " << j << " =0: not counted" << endl;
            }
            if( A[i]%j==0 && AA[A[i]/j] > 0 ){
                flag=false;
                //cout << "A[i] " << A[i] << " \% " << A[i]/j << " =0: not counted" << endl;
            }
        }
        if(flag){
            //cout << "ans A[i] " << ans << " " << A[i] << endl;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8380
#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>;

void solve() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int k = 0;
    rep(i, n) {
        if (p[i] != i+1) k++;
    }
    if (k <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
//ABC 050-C
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int N, A;
	vector<int> Line(100000, 0);
	int crack = pow(10, 9) + 7, ans = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		if ((N - A) % 2 == 0) {
			ans = 0;
			break;
		}
		Line[A]++;
		if (Line[A] > 2) {
			ans = 0;
			break;
		}
		if (Line[0] > 1) {
			ans = 0;
			break;
		}
	}
	if (ans != 0){
		for (int i = 0; i < N/2; i++) {
			ans = 2*ans % crack;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 640
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
         
        if(x==1){
           System.out.println("Hello World");
        }else{
        int y = sc.nextInt();
        int z = sc.nextInt();
        System.out.println(y+z);
        }
       
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include<unordered_map>
#include <vector>
#include <queue>
#include <climits>
using namespace std;


#define ll long long int

void readFile() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


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

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

	int dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
	}
	cout << dp[n - 1] << endl;
}





Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
    public static long C(int n, int r)
    {
        var p = 1L;
        for (var i = 1; i <= r; i++) p = p * (n - i + 1) / i;
        return p;
    }
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var s = io.S;

        var cnt = new int[26];
        foreach (var c in s) cnt[c - 'a']++;

        var ans = C(s.Length, 2) - cnt.Select(x => C(x, 2)).Sum() + 1;
        io.Write(ans);
    }
}

Measured memory_bytes: 15968
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <bitset>
#include <utility>
#include <sstream>
#include <fstream>
#include <stack>
#include <cstdlib>
#include <complex>
#include <set>

using namespace std;

#define INF 1070000000LL
#define pb push_back
#define irep(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) irep(i,0,n)

typedef long long lint;
typedef pair<int, int> pint;
struct Edge{
    int to,weight;
};
typedef vector<vector<Edge> > Graph;


int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
	if(s[i] == t[i])++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
inter = []
for i in range(n):
    a, b = map(int, input().split())
    inter.append([a-b, a+b])
inter = sorted(inter, key=lambda x: x[1])
ans = 1
rmost = inter[0][1]
for i in range(1, n):
    if inter[i][0] >= rmost:
        rmost = inter[i][1]
        ans+=1
print(ans)



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

int main()
{
	int n, ans;
	cin >> n;
	for (int i = n; i <= n + 110; i++)
		if(i % 111 == 0)
		{
			ans = i;
			break;
		}
	cout << ans << endl; 
	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var nk=arr.shift().split(" ").map(Number);
var n=nk[0];
var k=nk[1];
var obj={};
for(var i=0;i<k;i++){
   var ab=arr.shift().split(" ").map(Number);
   obj[ab[0]]=ab[1]-1;
}
var dp=[];
for(var i=0;i<=n;i++){
   dp[i]=[];
   for(var j=0;j<3;j++){
      dp[i][j]=[];
      for(var k=0;k<3;k++){
         dp[i][j][k]=0;
      }
   }
}
dp[1][0][1]=1;
dp[1][1][1]=1;
dp[1][2][1]=1;

for(var i=1;i<=n;i++){
   dp[i][0][2]+=dp[i-1][0][1]%10000;
   dp[i][1][2]+=dp[i-1][1][1]%10000;
   dp[i][2][2]+=dp[i-1][2][1]%10000;

   dp[i][1][1]+=dp[i-1][0][1]%10000;
   dp[i][1][1]+=dp[i-1][0][2]%10000;
   dp[i][2][1]+=dp[i-1][0][1]%10000;
   dp[i][2][1]+=dp[i-1][0][2]%10000;

   dp[i][0][1]+=dp[i-1][1][1]%10000;
   dp[i][0][1]+=dp[i-1][1][2]%10000;
   dp[i][2][1]+=dp[i-1][1][1]%10000;
   dp[i][2][1]+=dp[i-1][1][2]%10000;

   dp[i][0][1]+=dp[i-1][2][1]%10000;
   dp[i][0][1]+=dp[i-1][2][2]%10000;
   dp[i][1][1]+=dp[i-1][2][1]%10000;
   dp[i][1][1]+=dp[i-1][2][2]%10000;
   if(obj.hasOwnProperty(i)){
      for(var v=0;v<3;v++){
         if(obj[i]!=v){
            dp[i][v][1]=0;
            dp[i][v][2]=0;
         }
      }
   }
}
var sum=0;
for(var i=0;i<3;i++){
   for(var j=1;j<=2;j++){
      sum+=dp[n][i][j];
   }
}
console.log(sum%10000);

Measured memory_bytes: 15544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
	
	ll dist = abs(b - a);
	ll speed = v - w;
	
	if (t * speed >= dist)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
    
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  for (int i = 2; i < s.size(); i += 2) {
    string t = s.substr(0, s.size() - i);
    if (t.substr(0, t.size() / 2) == t.substr(t.size() / 2)) {
      cout << s.size() - i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;
#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
ll a,b,n;
ll x;
int main()
{
	cin>>a>>b>>n;
	if(n<b) x=n;
	else x=b-1;
	cout<<floor((double)a*(double(x)/b-floor(double(x)/b)))<<endl;
	return 0;
}

Measured memory_bytes: 3780
a,b,c,x,y = map(int,input().split())
min_pizza = a*x + b*y
for i in range(1,max(x,y)+1):
  pizza = 2*c*i +max(0,x-i)*a + max(0,y-i)*b
  if pizza < min_pizza:
    min_pizza = pizza
print(min_pizza)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			int r = scan.nextInt();
			
			if(n==0&&r==0)break;
			
			int p, c;
			int[] Y = new int[50];
			int[] pp = new int[50];
			int[] cc = new int[50];

			for (int i = 0; i < n; i++) {
				Y[i] = n - i;
			}

			for (int i = 0; i < r; i++) {
				p = scan.nextInt();
				c = scan.nextInt();
				for (int j = 0; j < (p - 1); j++) {
					pp[j] = Y[j];
				}
				for (int j = 0; j < c; j++) {
						cc[j] = Y[j+p-1];
				}
				for (int j = 0; j < c; j++) {
					Y[j] = cc[j];
				}
				for (int j = 0; j < p-1; j++) {
						Y[j+c] = pp[j];
				}
			}
			System.out.println(Y[0]);
		}
	}
}

Measured memory_bytes: 30832
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  LL n, a[5];
  cin>>n;
  LL work=LINF;
  REP(i, 5) {
    cin>>a[i];
    work=min(a[i], work);
  }

  LL ans=(4 + (n+work-1)/work);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int ans=1000000000;
  for(int i=0;i<s.size()-2;i++)
  {
    
    int sum=(s.at(i)-'0')*100+(s.at(i+1)-'0')*10+(s.at(i+2)-'0');
    ans=min(ans,abs(753-sum));
  }
  cout<<ans;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int x; cin >> x;
	int upper, lower;
	int uy=0, um = 0,ly = 0,lm = 0;//mm-yy

	upper = x / 100;
	lower = x - upper * 100;

	if (1 <= upper&& upper <= 12) {
		um = 1;
	}
	if (0 <= upper && upper <= 99) {
		uy = 1;
	}
	if (1 <= lower && lower <= 12) {
		lm = 1;
	}
	if (0 <= lower && lower <= 99) {
		ly = 1;
	}
	//cout << upper << " " << lower;

	if ((uy == 1 && lm == 1) && (um == 1 && ly == 1)) {
		cout << "AMBIGUOUS" << endl;
	}
	else {
		if (uy == 1 && lm == 1) cout << "YYMM" << endl;
		else if (um == 1 && ly == 1) cout << "MMYY" << endl;
		else if ((um == 1 && ly == 0)|| (uy == 1 && lm == 0) || (um == 0 && ly == 1) || (uy == 0 && lm == 1)|| (um == 0 && ly ==0) || (uy == 0 && lm == 0)) cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256