akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  boolean[] list = new boolean[10];

  int n;

  int dfs(String str) {
    int d = Integer.parseInt(str);
    if (d >= n) {
      return d;
    }
    if (str.length() > 6) {
      return 1 << 28;
    }
    int min = 1 << 28;
    for (int i = 0; i < 10; ++i) {
      if (list[i]) continue;
      min = Math.min(min, dfs(str + i));
    }
    return min;
  }

  void run() {
    n = ni();
    int k = ni();
    for (int i = 0; i < k; ++i) {
      int d = ni();
      list[d] = true;
    }
    System.out.println(dfs("0"));
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#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 rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

#define MAX_V 200005
V G[MAX_V];
ull c[MAX_V] = { 0 };
ull sum[MAX_V] = { 0 };

void dfs(int from, int now) {
	if (from != -1) {
		sum[now] = sum[from] + c[now];
	}
	else {
		sum[now] = c[now];
	}

	rep(j, G[now].size()) {
		if (G[now][j] != from) {
			dfs(now, G[now][j]);
		}
	}
}

void solve_abc_d() {
    ll n, q;
    cin >> n >> q;

	ll a, b;
	rep(i, n - 1) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	ll p, x;
	rep(i, q) {
		cin >> p >> x;
		c[p] += x;
	}

	sum[1] = c[1];
	dfs(-1, 1);
	rep1(i, n) {
		cout << sum[i] << " ";
	}
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_d();

	return 0;
}


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

using namespace std;

const int MOD = 1e9+7;

char tab[1010][1010];
int dp[1010][1010];

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    for(int i=0;i<=n;++i) tab[i][0] = '.';
    for(int i=0;i<=m;++i) tab[0][i] = '.';

    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            cin >> tab[i][j];

    dp[1][0] = 1;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j){
            if(tab[i-1][j] == '.')
                dp[i][j] = dp[i-1][j];
            if(tab[i][j-1] == '.')
                dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
        }

    cout << dp[n][m] << '\n';

    return 0;
}

Measured memory_bytes: 5248
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int M1 = sc.nextInt();
        int D1 = sc.nextInt();
        int M2 = sc.nextInt();
        int D2 = sc.nextInt();
        
        if(M1 != M2){
            System.out.println('1');
        }else{
            System.out.println('0');
        }
    }
}


Measured memory_bytes: 35648
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end(), std::greater<char>());

    if (s < t) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			@SuppressWarnings("unused")
			int n = scanner.nextInt(), m = scanner.nextInt(), x = scanner.nextInt();
			int[] a = IntStream.range(0, m).map(i -> scanner.nextInt()).toArray();
			System.out.println(
					Math.min(Arrays.stream(a).filter(i -> i > x).count(), Arrays.stream(a).filter(i -> i < x).count()));
		}
	}
}


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

int n;
vector < int > scr;
int k;
int q;
vector < int > sk;

int solve(){
    for(int i=0;i<q;++i){
        scr[sk[i]]+=1;
    }
    for(int i=1;i<=n;++i){
        bool sv= k - q + scr[i] > 0 ;
        cout<<(sv?"Yes":"No")<<"\n";
    }
}

void _prepare(){
    cin>>n>>k>>q;
    scr.resize(n+1);
    sk.resize(q);
    for(int i=0;i<q;++i)cin>>sk[i];
}

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


Measured memory_bytes: 1408
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String B = sc.nextLine();
    int max = 0; //the longest sequence of ACGT.
    int count = 0; //the longest current sequence of ACGT.
    for(int i=0; i<B.length(); i++) {
      if(B.charAt(i) == 'A' || B.charAt(i) == 'C' || B.charAt(i) == 'G' || B.charAt(i) == 'T') {
        count++;
      } else {
        
        max = Math.max(max, count);
        count = 0;
      }
    }
    max = Math.max(max, count);
    System.out.println(max);
  }
}


Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main() {
  int a[3][3];
  rep(i, 3) {
    rep(j, 3) { cin >> a[i][j]; }
  }

  int n;
  cin >> n;

  rep(k, n) {
    int b;
    cin >> b;
    rep(i, 3) {
      rep(j, 3) {
        if (b == a[i][j]) {
          a[i][j] = -1;
        }
      }
    }
  }
  rep(i, 3) {
    if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  rep(i, 3) {
    if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) {
    cout << "Yes" << endl;
    return 0;
  }
  if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


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

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

	int N, M, Q; cin >> N >> M >> Q;
	vector<int> a[550];
	int l, r;
	for (int i = 0; i < M; i++) {
		cin >> l >> r;
		a[l].push_back(r);
	}
	for (int i = 1; i <= N; i++) {
		sort(a[i].begin(),a[i].end());
	}
	int ans[110000];
	fill(ans, ans + N, 0);
	for (int d = 0; d < Q; d++) {
		cin >> l >> r;
		for (int i = l; i <= r; i++) {
			int n = a[i].size();
			int cnt = 0;
			while (cnt + 1000 < n && a[i][cnt + 1000] <= r) {
				ans[d] += 1000;
				cnt += 1000;
			}
			while (cnt+100 < n && a[i][cnt+100] <= r) {
				ans[d] += 100;
				cnt += 100;
			}
			while (cnt + 10 < n && a[i][cnt+10] <= r) {
				ans[d] += 10;
				cnt += 10;
			}
			while (cnt < n && a[i][cnt] <= r) {
				ans[d]++;
				cnt++;
			}
		}
	}
	for (int i = 0; i < Q; i++) {
		cout << ans[i] << endl;
	}
}

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

#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define endl '\n'
#define exists(s, e) (s.find(e)!=s.end())
#define WHILE(n)
#define pb push_back
#define f first
#define s second
#define UNI(vec) vec.erase(std::unique(vec.begin(), vec.end()),vec.end());
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<int, pii> piii;

const int INF = 0x3f3f3f3f;
#define MAXN 100001
using namespace std;
int n,m,ans;
int a[MAXN];
int dp[MAXN];

int main(){
    MEM(dp, INF);
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i =0; i < n; i++){
        cin>>a[i];
    }
    dp[0] = 0;
    for(int i = 0 ; i < n-1; i++){
        dp[i+1] = min(dp[i] + abs(a[i+1] - a[i]), dp[i+1]);
        if(i < n-2){
            dp[i+2] = min(dp[i] + abs(a[i+2] - a[i]), dp[i+2]);
        }
    }
    cout<<dp[n-1];



}


Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  long n, k;
  readf("%s %s", &n, &k);

  auto t = n % k;
  bool[long] cnt;
  while (!cnt.get(t, false)) {
    cnt[t] = true;
    t = abs(t - k);
  }
  auto keys = cnt.keys;
  sort(keys);
  keys[0].writeln;
}


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

int main()
{
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  cout << a[n / 2] - a[n / 2 - 1] << endl;

  return 0;
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << ", ";
#define ll long long
#define pb push_back
using namespace std;
#define FAST_IO                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
vector<int> v[MAX];
int add(int a, int b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
    return a;
}
void mult(int &a, int b)
{
    a = (long long)a * b % MOD;
}
pair<int, int> dfs(int curr, int par)
{
    int w = 1, ba = 1;
    for (int b : v[curr])
    {
        if (b == par)
        {
            continue;
        }
        pair<int, int> his = dfs(b, curr);
        mult(ba, his.second);
        mult(w, add(his.first, his.second));
    }
    return {ba, w};
}
int main()
{
    FAST_IO
    int n;
    cin >> n;
    // cout << n << endl;
    for (int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    pair<int, int> ww = dfs(1, -1);
    int ans = add(ww.first, ww.second);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12672
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] n={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=sc.nextInt()-1;
		System.out.println(n[k]);
	}
}


Measured memory_bytes: 23124
import math
a,b,h,m = map(int,input().split())
hkaku = 30*h+30*m/60
mkaku = m*6
aidakaku = abs(hkaku-mkaku)
if aidakaku >180:
    aidakaku = 360-aidakaku
kaku = aidakaku*2*math.pi/360
answer = math.sqrt((a**2+b**2-2*a*b*math.cos((math.radians(aidakaku)))))
print(answer)

Measured memory_bytes: 9576
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

typedef struct {
  int MEMBER00 [ 16 ] ;
  int MEMBER01 ;
  int MEMBER02 ;
} STRUCT00 ;

int VAR00 [ 16 ] [ 16 ] ;

STRUCT00 VAR01 ;
int VAR02 [ 4 ] = { 4 , 1 , -1 , -4 } ;

int FUNC00 ( int ARG00 , int ARG01 , int ARG02 ) ;
int FUNC01 ( STRUCT00 ARG03 ) ;
int FUNC02 ( STRUCT00 ARG04 ) ;

int main ( void ) {
  int VAR03 , VAR04 , VAR05 = 0 ;
  char VAR06 , VAR07 ;
  STRUCT00 VAR08 ;

  for ( VAR03 = 0 ; VAR03 < 15 ; VAR03 ++ ) for ( VAR04 = 0 ; VAR04 < 16 ; VAR04 ++ ) VAR00 [ VAR03 + 1 ] [ VAR04 ] = abs ( VAR03 / 4 - VAR04 / 4 ) + abs ( VAR03 % 4 - VAR04 % 4 ) ;





  for ( VAR03 = 0 ; VAR03 < 16 ; VAR03 ++ ) {








    scanf ( "%d" , & VAR08 . MEMBER00 [ VAR03 ] ) ;
    if ( VAR08 . MEMBER00 [ VAR03 ] == 0 ) VAR08 . MEMBER01 = VAR03 ;
  }

  VAR05 = 3 - VAR08 . MEMBER01 / 4 ;
  for ( VAR03 = 0 ; VAR03 < 15 ; VAR03 ++ ) for ( VAR04 = VAR03 + 1 ; VAR04 < 16 ; VAR04 ++ ) if ( VAR08 . MEMBER00 [ VAR03 ] > VAR08 . MEMBER00 [ VAR04 ] && VAR08 . MEMBER00 [ VAR04 ] != 0 ) VAR05 ++ ;
  if ( VAR05 % 2 == 1 ) printf ( "impossible\n" ) ;
  else {

    VAR08 . MEMBER02 = FUNC02 ( VAR08 ) ;

    printf ( "%d\n" , FUNC01 ( VAR08 ) ) ;
  }

  return 0 ;
}

int FUNC02 ( STRUCT00 ARG05 ) {
  int VAR09 , VAR10 = 0 ;
  for ( VAR09 = 0 ; VAR09 < 16 ; VAR09 ++ ) if ( ARG05 . MEMBER00 [ VAR09 ] != 0 ) VAR10 += VAR00 [ ARG05 . MEMBER00 [ VAR09 ] ] [ VAR09 ] ;
  ARG05 . MEMBER02 = VAR10 ;
  return VAR10 ;
}
int FUNC01 ( STRUCT00 ARG06 ) {
  int VAR11 = -1 , VAR12 ;
  for ( VAR12 = 1 ; VAR12 <= 80 ; VAR12 ++ ) {
    VAR01 = ARG06 ;
    VAR11 = FUNC00 ( VAR12 , 0 , -10 ) ;
    if ( VAR11 != -1 ) break ;
  }
  return VAR11 ;
}
int FUNC00 ( int ARG07 , int ARG08 , int ARG09 ) {

  int VAR13 , VAR14 = -1 , VAR15 ;
  STRUCT00 VAR16 = VAR01 ;

  if ( VAR16 . MEMBER02 == 0 ) return ARG08 ;

  if ( VAR01 . MEMBER02 + ARG08 >= ARG07 ) return -1 ;
  for ( VAR13 = 0 ; VAR13 < 4 ; VAR13 ++ ) {
    if ( VAR16 . MEMBER01 % 4 == 0 && VAR13 == 2 ) continue ;
    if ( VAR16 . MEMBER01 % 4 == 3 && VAR13 == 1 ) continue ;
    VAR01 = VAR16 ;

    VAR01 . MEMBER01 += VAR02 [ VAR13 ] ;

    if ( VAR01 . MEMBER01 >= 0 && VAR01 . MEMBER01 < 16 && ARG09 + VAR13 != 3 ) {

      VAR01 . MEMBER02 -= VAR00 [ VAR16 . MEMBER00 [ VAR01 . MEMBER01 ] ] [ VAR01 . MEMBER01 ] ;
      VAR01 . MEMBER02 += VAR00 [ VAR16 . MEMBER00 [ VAR01 . MEMBER01 ] ] [ VAR16 . MEMBER01 ] ;

      VAR01 . MEMBER00 [ VAR16 . MEMBER01 ] = VAR16 . MEMBER00 [ VAR01 . MEMBER01 ] ;
      VAR01 . MEMBER00 [ VAR01 . MEMBER01 ] = 0 ;




      VAR14 = FUNC00 ( ARG07 , ARG08 + 1 , VAR13 ) ;
      if ( VAR14 != -1 ) break ;
    }
  }
  return VAR14 ;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c){
    cout<<"Yes"<<endl;
  }
  else if(a+c==b){
    cout<<"Yes"<<endl;
  }
  else if(b+c==a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.14
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=10123;

int n;
char s[nmax];

int main()
{
    scanf("%d%s",&n,s);
    for(int i=0;s[i];++i){
       int tmp=s[i]-'A';
       tmp=(tmp+n)%26;
       s[i]='A'+tmp;
    }
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 256
/* ex9_1
   reo012 */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 11

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの削除
void pop(stack *stk){
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        stk->top++;
        stk->count--;
        return;
    }
}

int main(void){
    stack stk;
    char input_s[11], *ptr;
    scanf("%s", input_s);

    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    //スタックへのデータの追加・削除
    ptr = input_s;
    while(*(ptr)!='\0'){
        if(*(ptr)=='0' || *(ptr)=='1'){ //0か1が入力されたとき
            push(&stk, *(ptr)); //スタックに０、1を追加
        }else if(stk.count > 0){    //Bが入力され、かつスタックが空でないとき
            pop(&stk);  //スタックの最後尾を削除
        }
        ptr++;
    }

    //スタックを下から順に表示
    for (int i=0; i<stk.count; i++){
        printf("%c", stk.data[SIZE-i-1]);   //最後尾から出力していく
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1612
n, m = input().split(" ")
n = int(n)
m = int(m)
elms = list( map( int, input().split(" ")))

cnt = 0
total = 0
for elm in elms:
  total += elm
  
for elm in elms:
  if( elm*4*m >= total  ):
    cnt+= 1
    
if( cnt >= m ):
  print( "Yes" )
else:
  print( "No" )

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
	ll x=0,f=1; char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-')f=-f;
	for(;ch>='0'&&ch<='9';ch=getchar())
		x=x*10+ch-'0';
	return x*f;
}
#define _ read()
ll n,k,a[100005],res,ans,cnt[2];
int main() {
	n=_; k=_; for( ll i=1;i<=n;i++ ) a[i]=_;
	for( ll j=42;~j;j-- ) {
		cnt[1]=cnt[0]=0;
		for( ll i=1;i<=n;i++ ) cnt[(a[i]&(1ll<<j))?1:0]++;
		if(cnt[0]>cnt[1]&&res+(1ll<<j)<=k) res+=(1ll<<j);
	}
	for( ll i=1;i<=n;i++ ) ans+=(res^a[i]);
	cout<<ans;
}

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

#define lint long long
#define P pair<int, int>

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

    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    int cnt = 0;
    int cnt_z = 0;
    for(int i = 0; i < N; ++i){
        if(A[i] < 0){
            cnt++;
        }
        if(A[i] == 0){
            cnt_z++;
        }
    }
    lint sum = 0;
    for(int i = 0; i < N; ++i){
            sum += abs(A[i]);
        }

    if(cnt % 2 == 0 | cnt_z > 0){
  
        cout << sum << endl;
    } else {
        int m = 1E9;
        for(int i = 0;i < N; ++i){
                m = min(m, abs(A[i]));
        }
        cout << (sum - 2 * m) << endl;
    }

    
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  if (s[2] == s[3]) {
    if (s[4] == s[5]) {
      cout << "Yes" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

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

mod = 10 ** 9 + 7


def factorial(x):
    ret = 1
    for i in range(1, x + 1):
        ret *= i
        ret %= mod

    return ret


def solve(m, n):
    if m > n:
        m, n = n, m
    if n - m > 1:
        return 0
    fct = factorial(m)
    if n - m == 1:
        return fct ** 2 * n % mod
    else:  # n - m == 0
        return fct ** 2 * 2 % mod


ans = solve(m, n)
print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A=in(),B=in(),X=in();
	vector<int> V(A+1,0);
	REP(i,B){
		V[in()] = 1;
	}
	int costN = 0,cost0 = 0;
	for(int i=X;i<A;i++){
		if(V[i+1]) costN++;
	}
	for(int i=1;i<=X;i++){
		if(V[i-1]) cost0++;
	}
	out(min(costN,cost0));

	return 0;
}


Measured memory_bytes: 256
<?php
list($n, $m) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$di = new Di($n);
for($i = 0; $i < $m; $i++){
  list($from, $to, $d) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  $di->connect($from-1, $to-1, $d);
}
for($i = 1; $i < $n; $i++){
  $di->connect($i, $i - 1, 0);
}
$di->solve(0);
$distance = $di->distance[$n-1];
if($distance == $di->inf){
  echo -1;
}else{
  echo $distance;
}

/**
 * Dijkstra
 * Attention: 1-origin
 **/
class Di{
  public $pq;
  public $distance;
  public $G;
  public $from;
  public $inf = 10**18;
  function __construct($n) {
    $this->pq = new SplPriorityQueue();
    for($i = 0; $i < $n; $i++){
      $this->distance[$i] = $this->inf;
      $this->from[$i] = 0;
    }
  }
  function connect($from, $to, $cost){
    $this->G[$from][] = [$to, $cost];
  }
  function solve($from){
    $this->pq->insert($from, 0);
    $this->distance[$from] = 0;
    while($this->pq->count()){
      $f = $this->pq->extract();
      if(!isset($this->G[$f]))continue;
      foreach($this->G[$f] as list($t, $dist)){
        $new = $this->distance[$f] + $dist;
        if($this->distance[$t] > $new){
          $this->distance[$t] = $new;
          $this->from[$t] = $f;
          $this->pq->insert($t, -$new);
        }
      }
    }
  }
}

Measured memory_bytes: 142708
#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 <functional>
#include <stack>
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 vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;
//xor ^
int main(){
  string s;cin>>s;
  int ans=0;
  int length=s.length();
  for(int i=0;i<(length-1)/2;i++){
    if(s[i]!=s[length-1-i]){
      ans=1;
    }
  }
  for(int i=0;i<((length-1)/2)/2;i++){
    if(s[i]!=s[(length-1)/2-1-i]){
      ans=1;
    }
  }
  for(int i=0;i<(length-3)/2;i++){
    if(s[i+(length+3)/2-1]!=s[length-1-i]){
      ans=1;
    }
  }
  if(ans){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
typedef long long ll;
const int MYINF = 1e9+7;
typedef int bool;
const bool true = 1;
const bool false = 0;

#define MAX_N 128

int G[MAX_N][MAX_N];
int n;

int main(int argc, char **argv)
{
	int i, j, u, k, v;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		for (j = 0; j < k; j++) {
			scanf("%d", &v);
			G[u][v] = 1;
		}
	}

	for (i = 1; i <= n; i++) {
		const char *sp = "";
		for (j = 1; j <= n; j++) {
			printf("%s%d", sp, G[i][j]);
			sp = " ";
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,m,c,a,d = 0,ans = 0;
    cin >> n >> m >> c;
    int b[m];
    rep(i, m)cin >> b[i];
    rep(i, n){
        d = 0;
        rep(j, m){
            cin >> a;
            d += a * b[j];
        }
        if (d + c > 0) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string S="CODEFESTIVAL2016";
    string s;
    cin >> s;

    int ans =0 ;
    REP(i,s.length()){
        if(s[i]!=S[i]){
            ans ++;
        }
    }

    cout << ans << ENDL;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace	std;
int main(){
  string s;
  cin>>s;
  if(s[0]==s[1]&&s[1]==s[2]) cout<<"Yes"<<endl;
 else if(s[3]==s[2]&&s[1]==s[2]) cout<<"Yes"<<endl;
else   cout<<"No"<<endl;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
//#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-8
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 500005
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define hash Hash
using namespace std;
typedef long long LL;
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int a[100005];
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	LL big1=0,big2=0;
	for(int i=n-2;i>=0;i--){
		if(a[i]==a[i+1]){
			if(big1==0){
				big1=a[i];
			}
			else if(big2==0){
				big2=a[i];
			}
			i--;
		}
	}
	printf("%lld\n",(LL)big1*big2);
}
/*
14%20,15#17
20,14-18
1#5,11,4%10,14-18,20,21
11,21,20,14-18,4%10,1#5

*/


Measured memory_bytes: 640
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

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

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked

int inp() {
	int x = 0, f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

ll inp_ll() {
	ll x = 0; int f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

template<class T>
bool read(T &x)
{
	x = 0;
	char ch = getchar();
	if (ch == EOF) return 0;
	for(; !isdigit(ch); )
	{
		ch = getchar();
		if (ch == EOF) return 0;
	}
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return 1;
}

template<class T>
void write(T x)
{
	static char s[22];
	static char *it = s+20;
	static char *end = s+20;
	if (!x)
		*-- it = '0';
	while (x)
	{
		*-- it = x%10+'0';
		x /= 10;
	}
	for (; it < end; ++ it)
		putchar(*it);
}

template<class T>
void writeln(T x)
{
	write(x);
	putchar('\n');
}

const int MOD = 1000000007;
const int INF = 100000000;
const int MAXN = 200010;
const int MAXV = 500510;
const int K = 3;
const f80 eps = 1e-10;
const f64 alpha = 0.75;

int n;
ll a[MAXN];
ll s[MAXN];
ll b[MAXN];

int main()
{
	
	cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		a[i+n] = a[i];
		sum += a[i];
	}
	sum /= 2;
	for (int i = 1; i <= n+n; ++ i)
		s[i] = (i-2 >= 0 ? s[i-2] : 0)+a[i];
	
	for (int i = 1; i <= n; ++ i)
	{
		b[i] = sum-(s[i-2+n]-s[i-1]);
	}
	for (int i = 1; i <= n; ++ i)
		printf("%lld\n", b[i]*2);
	
	return 0;
}


Measured memory_bytes: 5248
#include<cstdio>
#include<iostream>
#include<deque>
using namespace std;
int main()
{
    string s;
    deque<int>ans;
    cin>>s;
    int len = s.size();
    for(int i = 0 ; i < len; i++){
        if(s[i] == '0'){
            ans.push_back(0);
        }
        else if(s[i] == '1'){
            ans.push_back(1);
        }
        else if(s[i] == 'B'){
            if(ans.size()!=0)ans.pop_back();
        }
    }
    while(!ans.empty()){
        printf("%d", ans.front());
        ans.pop_front();
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<P> bri(m);
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        bri[i]=P(b, a);
    }

    sort(bri.begin(), bri.end());

    int bmin=bri[0].first, cnt=1;
    for(int i=1; i<m; i++){
        if(bmin<=bri[i].second){
            bmin=bri[i].first;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1152
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int[] A = nextIntArray(sc, n);
		int q = sc.nextInt();
		int[] m = nextIntArray(sc, q);

		sc.close();

		Set<Long> s = new HashSet<>();

		for (int bit = 0; bit < (1 << n); bit++) {
			long sum = 0;
			for (int i = 0; i < n; i++) {
				if (((bit >> i) & 1) == 1) {
					sum += A[i];
				}
			}
			s.add(sum);
		}

		for (int i = 0; i < q; i++) {
			if (s.contains((long) m[i])) {
				out.println("yes");
			} else {
				out.println("no");
			}
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}



Measured memory_bytes: 54896
#include <stdio.h>
int main() {
  char a[100][100];
  int r[100] = {}, c[100] = {};
  int h, w, i, j;
  scanf("%d%d", &h, &w);
  for (i = 0; i < h; i++) {
    scanf("%s", a[i]);
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (a[i][j] == '#') {
        r[i] = c[j] = 1;
      }
    }
  }
  for (i = 0; i < h; i++) {
    if (!r[i]) continue;
    for (j = 0; j < w; j++) {
      if (!c[j]) continue;
      putchar(a[i][j]);
    }
    putchar('\n');
  }
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    fastio
    ll h,a;
    cin>>h>>a;
    cout<<ceil((double)h/a)<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  double t, x;
  scanf("%lf %lf", &t, &x);

  printf("%lf\n", t / x);
  return 0;
}


Measured memory_bytes: 128
def main():
    N = int(input())
    S = {int(i) for i in input().split()}
    q = int(input())
    T = (int(i) for i in input().split())
    ans = 0
    for t in T:
        if t in S:
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()


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

long long N;
long long ans=1;
map<long long,int> prime;
vector<long long> plist;

map<long long,int> prime_factor(long long N){
	map<long long,int> ret;
	for(long long i=2;i*i<=N;i++){
		while(N%i==0){
			ret[i]++;
			N/=i;
		}
	}
	if(N!=1)ret[N]=1;
	return ret;
}

void solve(int c,long long x){
	//cout << c << " " << x << endl;
	if(c==plist.size()){
		if(x==1){
			map<long long,int> prime1=prime_factor(N-1);
			long long add=1;
			for(auto p:prime1)add*=p.second+1;
			ans+=add-1;
			//cout << "+=" << add-1 << endl;
		}else{
			long long n=N;
			while(n%x==0)n/=x;
			if((n-1)%x==0){
				ans++;
				//cout << "++" << endl;
			}
		}
		return;
	}
	
	long long y=1;
	for(int i=0;i<=prime[plist[c]];i++){
		if(x*y<=N-(x*y))solve(c+1,x*y);
		else break;
		y*=plist[c];
	}
}

int main(){
	cin >> N;
	long long n=N;
	prime=prime_factor(N);
	for(auto p:prime)plist.push_back(p.first);
	solve(0,1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
typedef long long ll;
typedef long double LD;

#include <bits/stdc++.h>
using namespace std;
 



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sol = 0;
    for(int i=0; i<4; i++){
        char c = getchar();
        if(c == '+'){
        sol++;
        } else {
        sol--;
        }
    }
    cout << sol << "\n";
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

vector<int> prime = {2, 3, 5, 7, 11, 
	13, 17, 19, 23, 29, 
	31, 37, 41, 43, 47, 
	53, 59, 61, 67, 71, 
	73, 79, 83, 89, 97};
bool isprime(int n) {
	for (int i : prime) if (i == n) return true;
	return false;
}
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, ans = 0;
	cin >> n;
	vector<int> f(101);
	repp (i, 2, n + 1) {
		int tmp = n;
		while (tmp != 0) {
			f[i] += tmp / i;
			tmp /= i;
		}
	}
	// repp (i, 2, n + 1) eprintf("%d ", f[i]);

	// 75 = 75
	repp (i, 2, n + 1) if (f[i] >= 74 && isprime(i)) ans++;
	// 75 = 3 * 25
	int f3 = 0, f25 = 0;
	repp (i, 2, n + 1) if (f[i] >= 2 && isprime(i)) f3++;
	repp (i, 2, n + 1) if (f[i] >= 24 && isprime(i)) f25++;
	ans += f25 * (f25 - 1) + f25 * (f3 - f25);
	// 75 = 5 * 15
	int f5 = 0, f15 = 0;
	repp (i, 2, n + 1) if (f[i] >= 4 && isprime(i)) f5++;
	repp (i, 2, n + 1) if (f[i] >= 14 && isprime(i)) f15++;
	ans += f15 * (f15 - 1) + f15 * (f5 - f15);
	// 75 = 3 * 5 * 5
	ans += f5 * (f5 - 1) * (f5 - 2) / 2 + f5 * (f5 - 1) * (f3 - f5) / 2;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


string s, t;
int cnt;

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

	rep(i, 3){
		if (s[i] == t[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int sum = 0;
    for(int i=1;i<=N;i++){
      int n = i;
      int digSum = 0;
      while(n>0){
        digSum += n%10;
        n /= 10;
      }
      if(digSum>=A && digSum<=B){
        sum += i;
      }
    }
    System.out.println(sum);
  }
}

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

const int N = 1e6 + 100;

typedef long long LL;

LL f(string s) {
    LL ans = 0;
    int n = s.size();
    for(int i = 0; i < n; i++) {
        int l = i, r = i;
        for(int j = i; j < n; j++) {
            if(s[i] == s[j]) r = j;
            else break;
        }
        int cnt = r-l+1;
        ans += cnt/2;
        i = r;
    }
    return ans;
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    int K, n;
    cin >> s >> K;
    n = s.size();
    set<char> unq;
    for(char ch : s) unq.insert(ch);
    if(unq.size() == 1) {
        cout << (1ll*n*K)/2 << endl;
        return 0;
    }
    if(s[0] != s.back()) {
        LL ans = f(s);
        cout << ans * K << endl;
        return 0;
    }
    int pref_cnt = 0, suff_cnt = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == s[0]) pref_cnt++;
        else break;
    }
    for(int i = n-1; i >= 0; i--) {
        if(s[i] == s[n-1]) suff_cnt++;
        else break;
    }
    string t = s.substr(pref_cnt, n - pref_cnt - suff_cnt);
    LL ans = f(t) * K + 1ll * ((suff_cnt + pref_cnt)/2) * (K-1) + pref_cnt/2 + suff_cnt/2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
'use strict';

function Main(input) {
    const tmp = input.trim().split('\n')[0];

    const reg = /[A-Z]/;

    if (tmp.match(reg)) {
        console.log('A');
    } else {
        console.log('a');
    }

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29680
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
struct node{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
    while(x->left != NIL) x = x->left;
    
    return x;
}

Node treeSuccessor(Node x){
    if(x->right != NIL) return treeMinimum(x->right);
    
    Node y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void insertNode(int key){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = (node *)malloc(sizeof(struct node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    
    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
}

Node findNode(Node tree, int key){
    while(tree != NIL){
        if(tree-> key == key) return tree;
        else if(tree->key >= key) tree = tree->left;
        else tree = tree->right;
    }
    
    return tree;
}

void deleteNode(Node tree){
    Node x, y;
    
    if(tree->left == NIL || tree->right == NIL) y = tree;
    else y = treeSuccessor(tree);
    
    if(y->left != NIL) x = y->left;
    else x = y->right;
    
    if(x != NIL) x->parent = y->parent;
    
    if(y->parent == NIL) root = x;
    else{
        if(y == y->parent->left) y->parent->left = x;
        else y->parent->right = x;
    }
    
    if(y != tree) tree->key = y->key;
    
    free(y);
}

void inorederNode(Node tree){
    if(tree->left != NIL) inorederNode(tree->left);
    cout << " " << tree->key;
    if(tree->right != NIL) inorederNode(tree->right);
}

void preorederNode(Node tree){
    cout << " " << tree->key;
    if(tree->left != NIL) preorederNode(tree->left);
    if(tree->right != NIL) preorederNode(tree->right);
}

int main(void){
    int n, key;
    string command;
    Node t;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> command;
        
        if(command[0] == 'p'){
            inorederNode(root);
            cout << endl;
            preorederNode(root);
            cout << endl;
        }
        else if(command[0] == 'i'){
            cin >> key;
            insertNode(key);
        }
        else if(command[0] == 'f'){
            cin >> key;
            t = findNode(root, key);
            if(t != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else if(command[0] == 'd'){
            cin >> key;
            t = findNode(root, key);
            deleteNode(t);
        }
    }
}


Measured memory_bytes: 21952
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int n;
ll a[5000];
vector<int> G[5000];
bool used[5000];
vector<ll> x[5000];
int mi[5000];

void dfs(int id) {
	used[id] = true;
	x[id].push_back({ a[id] });
	if (a[id] > 0)mi[id] = 0;
	else mi[id] = 10000;
	rep(j, G[id].size()) {
		int to = G[id][j];
		if (used[to])continue;
		dfs(to);
		int len = x[to].size();
		int add = mi[to];
		vector<ll> nex; nex.resize(len + x[id].size(),INF);
		rep(k, len) {
			if (x[to][k] < 0) {
				add = min(add, k + 1);
				rep(l, x[id].size()) {
					nex[k+l + 1] = min(nex[k+l + 1], x[id][l]);
				}
			}
			rep(l, x[id].size()) {
				nex[k + l] = min(nex[k + l], x[to][k] + x[id][l]);
			}
		}
		if (mi[to] < 10000) {
			rep(l, x[id].size()) {
				nex[l + mi[to]+1] = min(nex[l + mi[to]+1], x[id][l]);
			}
		}
		x[id] = nex;
		mi[id] += add;
	}
}

int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n - 1) {
		int u, v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0);
	int ans = mi[0];
	rep(i, x[0].size()) {
		if (x[0][i] < 0) {
			ans = min(ans, i);
		}
	}
	cout << ans << endl;
	//stop
		return 0;
}


Measured memory_bytes: 116608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

vector <ll>a,ch;
int main() {
	ll n,m;
	cin>>n>>m;
	ll N=sqrt(n);
	for(ll i=2;i<=N;i++){
		if(n%i==0){
			a.push_back(i);
			while(n%i==0){
			n=n/i;
			}
			//cout << i<<endl;
		}
	}
	if(n!=1){
		a.push_back(n);
	}
	//cout << n<<endl;
	ll ans=1;
	for(ll i=0;i<a.size();i++){
		if(m%a[i]==0){
			ans++;
			m/=a[i];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n,m=map(int,input().split())
g=[[] for i in range(1+n)]
v=[0]*(1+n)
for i in range(m):
    a,b=map(int,input().split())
    g[a].append(b)
    g[b].append(a)
    if i==0:
        q=[a,b]
        v[a]=v[b]=1

p=[q[-1]]
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path

p=[q[0]]
path=[]
while p:
    cur=p.pop()
    path.append(cur)
    v[cur]=1
    flg=True
    for i in g[cur]:
        if v[i]==0:
            p.append(i)
            flg=False
    if flg:
        break
ans=path[::-1]+ans
print(len(ans))
print(*ans)

Measured memory_bytes: 69408
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double tax = 1.08;
    for(int i = 1; i <= 50000; i++){
      int result = (int) (i*tax);
      if(result == n){
        System.out.println(i);
        return;
      }
    }
    System.out.println(":(");
  }
}

Measured memory_bytes: 22612
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
MOD = 10**9 + 7

bl1 = A[:,None] > A[None,:]
bl2 = np.arange(N,dtype=np.int64)[:,None]
bl3 = np.arange(N,dtype=np.int64)[None,:]
mask = bl2[None] < bl3[None]
mask = bl1 & mask
ans1 = (mask*1).astype(np.int64).sum() % MOD
ans1 = ans1 * K % MOD

ans2 = (bl1 * 1).astype(np.int64).sum() % MOD
coe =int(K * (K - 1) // 2) % MOD
ans2 = ans2 * coe % MOD


print((ans1 + ans2) % MOD)

Measured memory_bytes: 82908
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() {
            var t = ReadLine();
            if (t.Trim().Length == 0) return new List<int>();
            return new List<int>(t.Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var nk = Sarray();
            var n = nk[0];
            var k = nk[1];
            var ans = "";
            long m,a;
            while(true)
            {
                m = n / k;
                a = n % k;
                if(m==0)
                {
                    ans += a;
                    break;
                }
                ans += a;
                n = m;
            }
            WriteLine(ans.Length);
        }
    }
}


Measured memory_bytes: 18816