akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
 
using namespace std;
typedef long long int lli;
const int MAX=1e5;
 
lli f(lli a,lli b,lli c){
	if(a>b){
      lli z=a;
      a=b;
      b=z;
    }
	if(c<a)return b-c;
	else if(c<b)return b-a;
	else return c-a;
}
 
int main(){
	lli H,W;
	cin>>H>>W;
	if(H>W){
		lli Z=H;
		H=W;
		W=Z;
	}
	lli ans=H;
	if(H%3==0||W%3==0){
      cout<<0<<endl;
      return 0;
    }
	if(W%3==1){
		lli n=W/3;
		if(H%2==0)ans=H/2;
		else ans=min(ans,f(H*n,(H/2)*(2*n+1),(H/2+1)*(2*n+1)));
	}
	if(W%3==2){
		lli n=W/3;
		if(H%2==0)ans=H/2;
		else ans=min(ans,f(H*(n+1),(H/2)*(2*n+1),(H/2+1)*(2*n+1)));
	}
	if(H%3==1){
		lli n=H/3;
		if(W%2==0)ans=min(ans,W/2);
		else ans=min(ans,f(W*n,(W/2)*(2*n+1),(W/2+1)*(2*n+1)));
	}
	if(H%3==2){
		lli n=H/3;
		if(W%2==0)ans=min(ans,W/2);
		else ans=min(ans,f(W*(n+1),(W/2)*(2*n+1),(W/2+1)*(2*n+1)));
	}
	cout<<ans<<endl;
}

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

long long gcd2(long long n1, long long n2);
long long gcd3(long long n1, long long n2, long long n3);

int main() {
  long long K;
  cin >> K;

  long long answer = 0;
  for (auto a = 1; a <= K; ++a) {
    for (auto b = 1; b <= K; ++b) {
        for (auto c = 1; c <= K; ++c) {
          answer += gcd3(a, b, c);
      }
    }
  }

  cout << answer << endl;
}

long long gcd2(long long n1, long long n2) {
  long long a = n1, b = n2, r, tmp; // must be a > b
  if (a > b) swap(a, b);

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

  return b;
}


long long gcd3(long long n1, long long n2, long long n3) {
  long long tmp = gcd2(n1, n2);
  return gcd2(tmp, n3);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
ll Q, H, S, D, N;
double a[4] = {0.25, 0.5, 1, 2};
ll ans = 0;
int main()
{
    cin >> Q >> H >> S >> D >> N;
    ll FQ = Q * 4;
    ll DH = H * 2;
    ll M = min(FQ, min(DH, S));

    // cout << M << endl;
    if (2 * M < D)
    {
        ans = N * M;
    }
    else
    {
        ans = (N / 2) * D;
        ans += (N % 2) * M;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("Sunny")) System.out.println("Cloudy");
        else if(s.equals("Cloudy")) System.out.println("Rainy");
        else System.out.println("Sunny");
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
  vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << A[K-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	int n;
	cin >> n >> k;
	int ans = 1;
	rep(i, 0, n) {
		if (ans < k) {
			ans = ans * 2;
		}
		else {
			ans = ans + k;
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll L,R;
int main(){
  cin >> L >> R;
  if (R/2019!=L/2019){
    cout << 0 << endl;
    return 0;
  }
  L=L%2019;
  R=R%2019;
  ll ans=2018;
  for (ll i=L;i<R;i++){
    for (ll j=i+1;j<=R;j++){
      if (ans>i*j%2019) ans=i*j%2019;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 504
#include <stdio.h>
#define n 10
int main()
{
    long long int a[n],i,j,k;
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=i;j<n-1;j++)
        {
            if(a[i]<a[j+1])
            {
                k=a[i];
                a[i]=a[j+1];
                a[j+1]=k;
            }
        }
    }
    for(i=0;i<3;i++)
    {
        printf("%lld\n",a[i]);
    }
    return 0;
}

Measured memory_bytes: 600
// Tazoe

#include <iostream>
using namespace std;

void trans(int n)
{
	if(n/4!=0){
		trans(n/4);
	}

	cout << n%4;
}

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==-1)
			break;

		trans(n);
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b) { 
	return*(ll*)a<*(ll*)b ? -1 : *(ll*)a>*(ll*)b ? 1 : 0; 
}
void sortup(ll*a, int n) { 
	qsort(a, n, sizeof(ll), upll); 
}
#define MOD 1000000007
ll m[200010], p[200010];
int mm_c, p_c;
int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	rep(i, 0, n) {
		int t;
		scanf("%d", &t);
		if (t >= 0)p[p_c++] = t;
		else m[mm_c++] = -t;
	}
	sortup(m, mm_c);
	sortup(p, p_c);
	if (q == n) {
		ll ans = 1;
		rep(i, 0, mm_c)ans = ans * (MOD - m[i]) % MOD;
		rep(i, 0, p_c)ans = ans * p[i] % MOD;
		printf("%lld", ans);
		return 0;
	}
	if (q % 2 == 1 && mm_c == n) {
		ll ans = 1;
		rep(i, 0, q)ans = ans * (MOD - m[i]) % MOD;
		printf("%lld", ans);
		return 0;
	}
	ll ans = 1;
	while (q) {
		if (q >= 2 && mm_c >= 2 && (p_c <= 1 || (p_c >= 2 && m[mm_c - 1] * m[mm_c - 2] >= p[p_c - 1] * p[p_c - 2]))) {
			ans = ans * m[--mm_c] % MOD;
			ans = ans * m[--mm_c] % MOD;
			q -= 2;
		}
		else {
			ans = ans * p[--p_c] % MOD;
			q--;
		}
	}
	printf("%lld", ans);
}


Measured memory_bytes: 6056
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 100005;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}

template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

int n, dep[N], sz[N];
bool flag = true;

struct node {
	int id;
	long long dist;
	bool operator < (node rhs) const {
		return dist < rhs.dist;
	}
} vec[N];
long long d[N];
vector<pair<int, int> > tree;

int main () {
	read(n);
	for (int i = 1; i <= n; i++) vec[i].id = i, read(vec[i].dist);

	sort(vec + 1, vec + n + 1);
	for (int i = 1; i <= n; i++) d[i] = vec[i].dist, sz[i] = 1;

	for (int i = n; i > 1; i--) {
		int pos = lower_bound(d + 1, d + i, d[i] - (n - sz[i]) + sz[i]) - d;
		if (pos >= i || d[pos] != d[i] - (n - sz[i]) + sz[i]) {
			flag = false;
			break;
		}
		tree.push_back(make_pair(vec[i].id, vec[pos].id));
		sz[pos] += sz[i];
	}

	if (flag) {
		dep[vec[1].id] = 0;
		for (int i = n - 2; i >= 0; i--) dep[tree[i].first] = dep[tree[i].second] + 1;
		for (int i = 1; i <= n; i++) d[1] -= dep[i];
		if (d[1]) flag = false;
	}
	if (!flag) write(-1), putchar('\n');
	else {
		for (int i = 0; i < tree.size(); i++) {
			write(tree[i].first), putchar(' ');
			write(tree[i].second), putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 5492
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, size_t second_itr) {
	std::string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++) {
		tmp.push_back(str.at(i));
	}
	return tmp;
}

int main(){
	int a,b,c;cin>>a>>b>>c;
	cout<<max(c-a+b,0)<<endl;
	return 0;
}

Measured memory_bytes: 384
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
#include <vector>
#include <string.h>

typedef long long ll;
typedef long double lg;

using namespace std;

int main()
{
  char a,b;
  cin>>a>>b;

  string first = "",second = "";

  long long bnumber = b-'0';
  long long anumber = a-'0';

  for(int i=0;i<bnumber;i++){
      first += a;
  }

  for(int i=0;i<anumber;i++){
      second += b;
  }

  if(first < second)
  cout<<first<<endl;
  else
  cout<<second<<endl;


    return 0;
}


Measured memory_bytes: 3580
x = int(input())
def createC(x, z):
  tmp = []
  for y in range(x):
    p = pow(y+1, z)
    if p <= x:
      tmp.append(p)
    else:
      return tmp

c = []
z = 2
max_c = 1
while True:
  if x == 1:
    break
  c_tmp = createC(x, z)
  if len(c_tmp) != 1:
    s = sorted(c_tmp)
    if max_c < s[-1]:
      max_c = s[-1]
    z += 1
  else:
    break
print(max_c)


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

using namespace std;

const int INF = 1 << 29;

int main()
{
  int N, Q, M;
  int graph[11][11];
  int dp[1 << 11][11];

  while(cin >> N, N) {

    vector< map< string, int > > value(N);
    for(int i = 0; i < N; i++) {
      int k;
      cin >> k;
      while(k--) {
        string name;
        int v;
        cin >> name >> v;
        value[i][name] = v;
      }
    }

    cin >> Q;
    vector< string > need(Q);
    for(int i = 0; i < Q; i++) {
      cin >> need[i];
    }

    cin >> M;
    fill_n(*graph, 11 * 11, INF);
    for(int i = 0; i < M; i++) {
      int s, t, d;
      cin >> s >> t >> d;
      graph[s][t] = graph[t][s] = d;
    }

    ++N;
    for(int k = 0; k < N; k++) {
      for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
          graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
        }
      }
    }

    fill_n(*dp, 11 * (1 << 11), INF);
    dp[0][0] = 0;
    for(int i = 0; i < (1 << N); i++) {
      for(int j = 0; j < N; j++) {
        if(dp[i][j] == INF) continue;
        for(int k = 0; k < N; k++) {
          if((i >> k) & 1) continue;
          dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + graph[j][k]);
        }
      }
    }

    pair< int, int > ret(INF, INF);
    for(int i = 0; i < (1 << N); i++) {
      vector< int > vv(Q, INF);
      for(int j = 1; j < N; j++) {
        if((i >> j) & 1) {
          for(int k = 0; k < Q; k++) {
            if(value[j - 1].count(need[k])) {
              vv[k] = min(vv[k], value[j - 1][need[k]]);
            }
          }
        }
      }
      if(count(begin(vv), end(vv), INF) > 0) continue;
      ret = min(ret, {accumulate(begin(vv), end(vv), 0), dp[i][0]});
    }

    if(ret.first == INF) cout << "impossible" << endl;
    else cout << ret.first << " " << ret.second << endl;
  }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */

void max_self(ll &a,ll b){
	a = max(a,b);
}


int main(){
	FAST;
	int n,W;
	scanf("%d%d",&n,&W);
	vector <ll> dp(W+1,0); //0,1,2...W

	for(int item = 0;item<n;++item){
		int weight, value;
		scanf("%d%d",&weight,&value);
		for(int weight_already = W - weight;weight_already>=0;--weight_already){
			max_self( dp[weight_already+weight] , dp[weight_already] + value);
		}
	}
	ll answer = 0;
	for(int i=0; i<=W;++i){
		max_self(answer, dp[i]);
	}
	printf("%lld",answer);
	
	
	return 0;
}

	

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


public class Main {

    public static void main(String[] args) throws Exception {

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws Exception {

        int t = 1;
        while (t > 0) {
            solve();
            //out.println();
            t--;
        }

        out.flush();
        out.close();
    }


    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.000000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[1000];

    void solve() throws IOException {

        int n = in.nextInt();

        String s = in.nextLine();
        
        if (s.indexOf("Y") >= 0)
            out.println("Four");
        else
            out.println("Three");
        
    }

    int gcd(int a, int b) {

        if (b == 0) return a;
        return gcd(b, a%b);
    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (b > p.b) return 1;
            if (b < p.b) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }


        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}

Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;


int main() {
	int n;
	cin >> n;
	int x[109];
	rep(i, n)
	{
		cin >> x[i];
	}

	int ans = -1;
	rep(i, 101)
	{
		int cost = 0;
		rep(j, n)
		{
			int t = (x[j] - i);
			cost += t*t;
		}
		if (ans == -1 || cost < ans)
			ans = cost;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void fuk() { puts("IMPOSSIBLE"); exit(0); }
void fg(vector<int> G[], int a, int b) { G[a].eb(b); G[b].eb(a); }

const int MAXN = 100005;

vector<int> GT[MAXN];
vector<int> GA[MAXN], GB[MAXN];
vector<pii> EV;

bitset<MAXN> isC;

int CA[MAXN], CB[MAXN];
int A[MAXN], B[MAXN];

int Ans[MAXN];
int N, RA, RB;

void f(vector<int> G[], int C[], int i) {
	C[i] = int(isC[i]);
	for(int v : G[i]) {
		f(G, C, v);
		C[i] += C[v];
	}
}

void g(vector<int> G[], vector<pii> &EV, int &li, int i) {
	int a = 0, b = 0;
	for(int v : G[i]) {
		g(G, EV, b, v);
		if(a) {
			EV.eb(a, b);
			a = b = 0;
		} else {
			a = b;
		}
	}
	li = isC[i] ? i : a;
}

void dfs(int i) {
	for(int v : GT[i]) if(!Ans[v]) {
		Ans[v] = -Ans[i];
		dfs(v);
	}
}

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

	cin >> N;
	for(int i = 1; i <= N; i++) {
		cin >> A[i];
		if(A[i] < 0) {
			RA = i;
			continue;
		}
		GA[A[i]].eb(i);
	}
	for(int i = 1; i <= N; i++) {
		cin >> B[i];
		if(B[i] < 0) {
			RB = i;
			continue;
		}
		GB[B[i]].eb(i);
	}

	for(int i = 1; i <= N; i++)
		if((sz(GA[i]) & 1) != (sz(GB[i]) & 1)) fuk();

	for(int i = 1; i <= N; i++)
		if(!(sz(GA[i]) & 1)) isC[i] = true;
	
	f(GA, CA, RA); f(GB, CB, RB);

	for(int i = 1; i <= N; i++)
		if(!(CA[i] & 1) || !(CB[i] & 1)) fuk();
	
	{ int _; g(GA, EV, _, RA); }
	{ int _; g(GB, EV, _, RB); }

	for(auto v : EV) 
		fg(GT, v.first, v.second);
	
	for(int i = 1; i <= N; i++) if(isC[i] && !Ans[i]) {
		Ans[i] = 1;
		dfs(i);
	}

	puts("POSSIBLE");
	for(int i = 1; i <= N; i++)
		printf("%d ", Ans[i]);
	puts("");
	return 0;
}

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

using namespace std;

#define ll long long
#define PI acos(-1.0)

string ch, bh,ash = "";
int len1, len2;
int dp[3005][3005];

int func(int i, int j)
{
	if(i >= len1 || j >= len2) return 0;
	if(dp[i][j] != -1) return dp[i][j];
	int ans = 0;
	if(ch[i] == bh[j])
	{
		ans = 1 + func(i+1,j+1);
	}
	else
	{
		ans = max(func(i+1,j), func(i,j+1));
	}
	return dp[i][j] = ans;
}

void path_print(int i, int j)
{
	if(i >= len1 || j >= len2)
	{
		cout << ash << endl;
		return;
	}
	if(ch[i] == bh[j])
	{
		ash += ch[i];
		path_print(i+1,j+1);
	}
	else
	{
		if(dp[i+1][j] > dp[i][j+1]) path_print(i+1,j);
		else path_print(i,j+1);
	}
}

int main()
{	
	cin >> ch >> bh;
	len1 = ch.size(),len2 = bh.size();
	memset(dp,-1,sizeof(dp));
	func(0,0);
	path_print(0,0);
	return 0;
}


Measured memory_bytes: 35840
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
string s[2010];
int a[2010][2010],b[2010][2010];
int numa[2010*2010],numb[2010*2010];
int main()
{
	int i,j,k,n,m,x,y,h=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for(i=0;i<n;i++)
	{
		x=0;
		for(j=0;j<m;j++)
		{
			if(s[i][j]=='#')
			{
				if(x>0)
				{
					numa[h]=x;
					x=0;
					h++;
				}
			}
			else
			{
				a[i][j]=h;
				x++;
			}
		}
		if(x>0)
		{
			numa[h]=x;
			h++;
		}
	}
	h=0;
	for(i=0;i<m;i++)
	{
		x=0;
		for(j=0;j<n;j++)
		{
			if(s[j][i]=='#')
			{
				if(x>0)
				{
					numb[h]=x;
					x=0;
					h++;
				}
			}
			else
			{
				b[j][i]=h;
				x++;
			}
		}
		if(x>0)
		{
			numb[h]=x;
			h++;
		}
	}
	int ma=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			ma=max(ma,numa[a[i][j]]+numb[b[i][j]]-1);
		}
	}
	printf("%d",ma);
	return 0;
}



Measured memory_bytes: 49800
import sys
N = int(input())
array = [ I for I in range(1,10) ]

if not ( 1 <= N <= 100 ): sys.exit()

if N >= 82:
    print('No'); sys.exit()
else:
    for J in array:
        if (N % J) == 0 and (N // J) <= 9 : print('Yes'); sys.exit()
print('No')

Measured memory_bytes: 9104
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC055
{
    public class QuestionB
    {
        public static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var m = (long)Math.Pow(10, 9) + 7;

            var result = 1L;
            for (int i = 0; i < n; i++)
            {
                result = result * (i + 1) % m;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27492
while(True):
    m,n = map(int,input().split())
    if not m: break
    a = list(range(1,m+1))
    b = [input() for _ in range(n)]
    t = [str(i+1) for i in range(n)]
    t[2::3]   = ["Fizz"]*len(t[2::3])
    t[4::5]   = ["Buzz"]*len(t[4::5])
    t[14::15] = ["FizzBuzz"]*len(t[14::15])
    i=0
    for j in range(n):
        if len(a) <2: break
        if b[j] != t[j]: del a[i]; i = i%len(a); continue
        i += 1
        i = i%len(a)
    print(" ".join(str(e) for e in a))


Measured memory_bytes: 7444
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Path struct {
	y1 int
	x1 int
	y2 int
	x2 int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	h := scanInt(sc)
	w := scanInt(sc)

	paths := make([]Path, 0)
	moves := make([]int, w)

	for y := 0; y < h-1; y++ {
		for x := 0; x < w; x++ {
			coins := scanInt(sc) + moves[x]
			moves[x] = coins % 2
			if moves[x] == 1 {
				paths = append(paths, Path{y, x, y + 1, x})
			}
		}
	}

	y := h - 1
	for x := 0; x < w; x++ {
		coins := scanInt(sc) + moves[x]
		if coins%2 == 1 && x < w-1 {
			moves[x+1] += coins % 2
			paths = append(paths, Path{y, x, y, x + 1})
		}
	}

	wtr := bufio.NewWriter(os.Stdout)
	fmt.Fprintln(wtr, len(paths))
	for _, p := range paths {
		fmt.Fprintln(wtr, p.y1+1, p.x1+1, p.y2+1, p.x2+1)
	}
	_ = wtr.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 16384
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for(int i = a; i <= b; i++){
            if((c%i == 0)){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26252
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		String A[] = new String[N];
		int count = 1;
		for (int i = 0; i < N; i++) {
			A[i] = scanner.next();
		}
		Arrays.sort(A);

		for (int i = 0; i < N - 1; i++) {
			if (!(A[i].equals(A[i + 1]))) {
				count += 1;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 70460
#include<stdio.h> 
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF){
		int a[n];
		for(int i=0;i<n;i++)
			scanf("%d",&a[i]);
		int max=0;
		int min=0;
		for(int i=1;i<n;i++)
			if(a[i]>a[max])
				max=i;
		for(int i=1;i<n;i++)
			if(a[i]<a[min])
				min=i;
		printf("%d\n",a[max]-a[min]);
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, K;
    cin >> N >> K;
    vector<ull> a(N);
    REP(i, N) cin >> a[i];

    vector< bitset<60> > b(N*(N+1)/2, bitset<60>());
    ull ans = 0;
    int idx = 0;
    REP(i, N) {
        ull tmp = 0ull;
        FOR(j, i, N-1) {
            tmp += a[j];
            auto bits = bitset<60>(tmp);
            REP(bit, 60) b[idx][bit] = bits[bit];
            idx++;
            // cerr << b[idx-1].to_string() << endl;
        }
    }

    int n = N*(N+1)/2;
    REP(bit, 60) {
        int cnt = 0;
        vector<ull> values;
        REP(i, n) {
            if(b[i][60-1-bit] == 1) {
                cnt++;
                ull tmp = b[i].to_ullong();
                values.push_back(tmp);
            }
        }
        if(cnt >= K) {
            sort(ALL(values));
            reverse(ALL(values));
            ans += (1LL << (60-1-bit));
            // REP(i, cnt) cerr << "values[" << i << "] = " << values[i] << endl;
            vector< bitset<60> > b_next(cnt, bitset<60>());
            REP(i, cnt) b_next[i] = bitset<60>(values[i]);
            b = b_next;
            n = cnt;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6008
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;


int main(){
	ios_base::sync_with_stdio(false);
	int r = 0;
	for (int i = 0; i < 5; i++) {
		int x;
		cin >> x;
		if (x == 0) r = i + 1;
	}
	cout << r << endl;
}



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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;

int N;
double dp[310][310][310];
vector<int> a;

double rec(int i, int j, int k){
    if(dp[i][j][k]>=0) return dp[i][j][k];
    if(i==0&&j==0&&k==0)return 0.0;
    double res = N;
    if(i>0) res += rec(i-1,j,k)*i;
    if(j>0) res += rec(i+1,j-1,k)*j;
    if(k>0) res += rec(i,j+1,k-1)*k;
    res /= (double)(i+j+k);
    return dp[i][j][k] = res;
}

int main(){
    cin>>N;
    a.reserve(N);
    rep(i,N)cin>>a[i];
    rep(i,310)rep(j,310)rep(k,310)dp[i][j][k]=-1;
    int i = 0,j = 0,k = 0;
    rep(n,N){
        if(a[n]==1)i++;
        else if(a[n]==2)j++;
        else if(a[n]==3)k++;
    }
    
    cout<<setprecision(10)<<rec(i,j,k)<<endl;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int H,W;
    vector<string> s;
    cin >> H >> W;

    rep(i,H)
    {
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
 
    vector<vector<int> >dp(H, vector<int>(W, INF));
    dp[0][0] = 0;
    if( s[0][0] == '#' ) dp[0][0]++;
    
    rep(i,H)
    {
        rep(j,W)
        {
            if( i > 0 )
            {
                if( s[i][j] == '#' && s[i-1][j] != '#' ) chmin( dp[i][j], dp[i-1][j]+1 );
                else chmin( dp[i][j], dp[i-1][j] );
            }
            if( j > 0 )
            {
                if( s[i][j] == '#' && s[i][j-1] != '#' ) chmin( dp[i][j], dp[i][j-1]+1 );
                else chmin( dp[i][j], dp[i][j-1] );
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 256
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>
#include <random>
#include <ctime>
#include <fstream>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;


const int D = 365;
const int si = 26;
vector<int> c(si);
vector<vector<int>> s(D, vector<int>(si));

struct cand {
    int score;
    int hist[D];
    int cc;
    vector<int> last;
    cand(int _cc) {
        score = 1000000;
        cc = _cc;
        last = vector<int>(si);
    }
};

bool operator<(const cand &left, const cand &right) {
	return left.score < right.score;
}

random_device r;
MaxHeap<cand> ans_heap;
int cc = 0;
const int width = 100, branch = 26, reading = 1;
int times = 1;
cand example(0);

void input() {
    int n; cin >> n;
    rip(i,si,0) {
        cin >> c[i];
        cc += c[i];
    }
    rip(i,D,0) rip(j,si,0) cin >> s[i][j];
}

cand gen_next(cand now, int day, int aa) {
	rip(i, reading, 0) {
		int a = aa%26;
        now.hist[day + i] = a;
        now.score += s[day+i][a];
        now.cc += cc-c[a]*(day+i-now.last[a]);
        now.last[a] = day+i;
        now.score -= now.cc;
	}
	return now;
}

void beem(int day) {
	MaxHeap<cand> cand_heap;
	rip(i, width, 0) {
		cand now = ans_heap.top();
		ans_heap.pop();
		rip(j, branch, 0) {
			cand next = gen_next(now, day, i);
			cand_heap.push(next);
		}
    }
    swap(ans_heap, cand_heap);
}

void output(cand ans) {
    rip(i, D, 0) printf("%d\n", ans.hist[i]+1);
}

int main() {
    input();
	rip(i, width, 0) {
		ans_heap.push(example);
	}
	rip(i, D/reading, 0) {
		beem(i*reading);
		times++;
	}
	output(ans_heap.top());
	// cout << ans_heap.top().score << endl;
}

Measured memory_bytes: 28604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

const int maxN = 311;
const int mod = 998244353;

int n, k;
char s[maxN];
vector<int> groups;
int dp[maxN][maxN][maxN];

void upd(int& dest, int sour, int coef = 1) {
  dest += (1LL * sour * coef) % mod;
  if (dest >= mod) dest -= mod;
}

void getGroups() {
  int curr = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      curr++;
    } else {
      groups.pb(curr);
      curr = 0;
    }
  }
  groups.pb(curr);
}

void compute() {
  dp[0][0][0] = 1;
  for (int i = 0; i < groups.size(); i++) {
    int nextCount = groups[i];

    for (int active = 0; active <= k; active++) {
      for (int used = active; used <= k; used++) {
         if (dp[i][active][used] == 0) continue;

         int limit = min(nextCount, active);
         for (int taken = 1; taken <= limit; taken++)
           upd(dp[i + 1][active - taken][used], dp[i][active][used]);

         limit = k - used;
         for (int added = 1; added <= limit; added++)
           upd(dp[i + 1][active + added][used + added], dp[i][active][used]);

        upd(dp[i + 1][active][used], dp[i][active][used]);
      }
    }
  }
}

int main()
{
  //freopen("test.in", "r", stdin);

  scanf("%s %d", s, &k);
  n = strlen(s);
  k = min(k, n);
  getGroups();
  compute();

  int answer = 0;
  for (int i = 0; i <= k; i++)
    upd(answer, dp[groups.size()][0][i]);

  cout << answer;


  return 0;
}


Measured memory_bytes: 59288
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

LL calc(LL a, LL b){
    LL tmp=__gcd(a,b);
    if(tmp==1){
        return a-1;
    }else{
        return tmp*calc(a/tmp,b/tmp);
    }
}

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

    LL a,b;
    cin >> a >> b;

    cout << 3*calc(a,b) << endl;

    return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, a, b) = (line[0], line[1], line[2]);
    let x = read_as_vec::<usize>();
    let mut ans: usize = 0;
    for i in 1..n{
        ans += cmp::min(a*(x[i]-x[i-1]), b);
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int count = 0;
    for (int i = 0; i < 3; i++)
      if (S.charAt(i) == T.charAt(i))
        count++;
    System.out.println(count);
  }
}

Measured memory_bytes: 23764
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int t = sc.nextInt();
			int n = sc.nextInt();
			
			if(t == 0 && n == 0){
				break;
			}

			final int offset = 100;
			boolean obst[][] = new boolean[2*offset + 2][2*offset + 2];

			for(int i = 0; i < n; i++){
				int x = sc.nextInt();
				int y = sc.nextInt();

				obst[x + offset][y + offset] = true;
			}

			int startX = sc.nextInt();
			int startY = sc.nextInt();
			
			int dist[][] = new int[2*offset + 2][2*offset  + 2];
//			int result = 1;
			
			ArrayDeque<Point> que = new ArrayDeque<Point>();
			que.add(new Point(startX, startY));
			
			int dx[] = {0,1,1,0,-1,-1};
			int dy[] = {1,1,0,-1,-1,0};
			while(!que.isEmpty()){
				Point p = que.remove();
				
				if(dist[p.x + offset][p.y + offset] > t){
					break;
				}
				
//				dist[p.x + offset][p.y + offset] = true; 
				
//				System.out.println("x "+p.x + " y "+p.y+" "+que.size());
				for(int i = 0; i < 6; i++){
					int tmpX = p.x + dx[i];
					int tmpY = p.y + dy[i];
					
					if(tmpX == startX && tmpY == startY){
						continue;
					}
					
					if(tmpX < -offset || tmpX > offset || tmpY< -offset || tmpY > offset){
						continue;
					}
					
					if(!obst[tmpX + offset][tmpY + offset] && dist[tmpX + offset][tmpY + offset] == 0){
						que.add(new Point(tmpX, tmpY));
						dist[tmpX + offset][tmpY + offset] = dist[p.x + offset][p.y + offset] + 1;
//						result++;
					}
				}
			}
			
			int result = 1;
			for(int i = 0; i < dist.length ; i++){
				for(int j = 0 ; j < dist[0].length; j++){
//					System.out.print(dist[i][j]+" ");
					if(dist[i][j] > 0 && dist[i][j] <= t){
//						System.out.println((i - offset)+","+(j - offset)+" dist "+dist[i][j]);
						result++;
					}
				}
//				System.out.println();
			}
			System.out.println(result);
		}
	}

}

class Point{
	int x;
	int y;
	
	Point(int x, int y){
		this.x = x;
		this.y = y;
	}
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    v_int ans;

    irep(i, s.size()) {
        if(s[i] == 'B') {
            if(!ans.empty()) { ans.pop_back(); }
        } else if(s[i] == '1') {
            ans.push_back(1);
        } else {
            ans.push_back(0);
        }
    }

    irep(i, ans.size()) {
        cout << ans[i];
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 1:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
print(con)

Measured memory_bytes: 9188
using System;
internal class Program
{
    private static void Main(string[] args)
    {
        string text = Console.ReadLine();
        char[] obj = new char[1];
        obj[0] = ' ';
        string[] array = text.Split(obj);
        int num = int.Parse(array[0]);
        int num2 = int.Parse(array[1]);
        string text2 = Console.ReadLine();
        char[] obj2 = new char[1];
        obj2[0] = ' ';
        string[] array2 = text2.Split(obj2);
        int[] array3 = new int[num];
        for (int i = 0; i < num; i++)
        {
            array3[i] = int.Parse(array2[i]);
        }
        Array.Sort(array3);
        Array.Reverse(array3);
        while (num2 > 0)
        {
            array3[0] /= 2;
            num2--;
            if (num2 <= 0)
            {
                break;
            }
            for (int j = 1; j < num; j++)
            {
                if (array3[0] > array3[j])
                {
                    Array.Sort(array3);
                    Array.Reverse(array3);
                    break;
                }
                array3[j] /= 2;
                num2--;
                if (num2 <= 0)
                {
                    break;
                }
            }
        }
        long num3 = 0L;
        for (int k = 0; k < num; k++)
        {
            num3 += array3[k];
        }
        Console.WriteLine(num3);
    }
}


Measured memory_bytes: 26844
H = int(input())


def iterated_power(z: int, n: int, mod=None) -> int:
    """ 繰り返し二乗法でn**kを求める（再帰処理は使わない）
    >>> p = Prime()
    >>> p.iterated_power(3, 10)
    59049
    >>> p.iterated_power(3, 10, 10)
    9
    """
    beta = bin(n)[2:]

    Z, q, t = z, 0, len(beta)
    while beta[t - q - 1] == '0':
        Z = Z * Z
        if mod is not None:
            Z = Z % mod
        q += 1
    result = Z

    for k in range(q + 1, t):
        Z = Z * Z
        if mod is not None:
            Z = Z % mod
        if beta[t - k - 1] == '1':
            result = result * Z
            if mod is not None:
                result = result % mod

    if mod is not None:
        result = result % mod

    return result


ans = iterated_power(2, H.bit_length()) - 1
print(ans)

Measured memory_bytes: 38384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const ll MOD = 998244353;
const ll INF = 1e9 + 7;

int n;
string s, ls, rs;

//check int vs ll and precision
//check logic
int main(){ FAST


	stack<char> st;
	cin >> n >> s;
	F0R(i,n){
		if (!st.empty() && st.top() == '(' && s[i] == ')') {
			st.pop();
		}
		else {
			st.push(s[i]);
		}
	}
	int lc = 0, rc = 0;
	while (!st.empty()) {
		char cur = st.top();
		lc += (cur == '(');
		rc += (cur == ')');
		st.pop();
	}
	F0R(i,rc) ls += '(';
	F0R(i,lc) rs += ')';
	string ans = ls + s + rs;
	finish(ans);


		






    return 0;
}
	


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

int main(){
  int A, B, K;
  cin>>A>>B>>K;
  int C=A+K;
  int D=B-K+1;
  if(C<D){
  for(int i=A; i<C; i++) cout<<i<<endl;
  for(int i=D; i<=B; i++) cout<<i<<endl;
  }
  else{
    for(int i=A; i<=B; i++) cout<<i<<endl;
  }
}


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

using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	
	string s3="RRR",s21="RRS",s22="SRR",s0="SSS",s;
	cin>>s;
	if(s==s3) cout<<"3";
	else if(s==s21||s==s22) cout<<"2";
	else if(s==s0) cout<<"0";
	else cout<<"1";
	
	return 0;
} 

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

int main(){
      int n;cin >> n;
      vector<int> arr;
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            arr.push_back(t);
      }
      sort(arr.rbegin(), arr.rend());
      int a = 0;
      int b = 0;
      for(int i = 0;i < n;i++){
            if(!(i & 1))a += arr[i];
            else b += arr[i];
      }
      cout << max(a, b) - min(a, b);
}

Measured memory_bytes: 256