akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  int P[100000],Y[100000];
  vector<int> sortedY[100001];
  cin>>N>>M;
  for(int i=0;i<M;i++){
    cin>>P[i]>>Y[i];
    sortedY[P[i]].push_back(Y[i]);
  }
  for(int i=1;i<=N;i++){
    sort(sortedY[i].begin(),sortedY[i].end());
  }
  for(int i=0;i<M;i++){
    cout<<setfill('0')<<right<<setw(6)<<P[i];
    cout<<setfill('0')<<right<<setw(6)<< lower_bound(sortedY[P[i]].begin(),sortedY[P[i]].end(),Y[i])-sortedY[P[i]].begin()+1 <<endl;
  }
}

Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt();
		if(a+b+c==17) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 22100
first = gets.split.map(&:to_i)
sec = gets.split.map(&:to_i)
thi = gets.split.map(&:to_i)
d1 = [first[0], sec[0], thi[0]]
d2 = [first[1], sec[1], thi[1]]
d3 = [first[2], sec[2], thi[2]]
c1 = [first[0],sec[1],thi[2]]
c2 = [first[2],sec[1],thi[0]]
data = [first, sec, thi, d1, d2, d3, c1, c2]
n = gets.to_i
nums = []
n.times do
  nums.push(gets.to_i)
end

res = "No"
data.each do |row|
  flag = 0
  row.each do |n|
    if nums.include?(n)
      flag += 1
    end
  end
  if flag == 3
    res = "Yes"
  end
end
  puts res

Measured memory_bytes: 1788
/**
 *    author:  tourist
 *    created: 25.11.2017 14:40:16       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 1234567;

char foo[N];
int s[N];
int l[N], r[N];
vector<int> g[N];
int decc[N];

int main() {
  scanf("%s", foo);
  int n = (int) strlen(foo);
  for (int i = 0; i < n; i++) {
    s[i] = foo[i] - 'a';
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &l[i], &r[i]);
    l[i]--; r[i]--;
    int op_l = n - 1 - l[i];
    if (l[i] <= op_l && op_l <= r[i]) {
      l[i] = op_l + 1;
    }
    int op_r = n - 1 - r[i];
    if (r[i] >= op_r && op_r >= l[i]) {
      r[i] = op_r - 1;
    }
    if (l[i] > n - 1 - l[i]) {
      swap(l[i], r[i]);
      l[i] = n - 1 - l[i];
      r[i] = n - 1 - r[i];
    }
    if (l[i] <= r[i]) {
      g[l[i]].push_back(r[i]);
    }
  }
  int delta = 0;
  for (int i = 0; i < n - 1 - i; i++) {
    sort(g[i].begin(), g[i].end());
    int to = (g[i].empty() ? -1 : g[i][0]);
    for (int j = 1; j < (int) g[i].size(); j++) {
      if (g[i][j - 1] < g[i][j]) {
        g[g[i][j - 1] + 1].push_back(g[i][j]);
      }
    }
    delta -= decc[i];
    int cur = (s[i] + delta) % 26;
    if (cur != s[n - 1 - i]) {
      if (to == -1) {
        puts("NO");
        return 0;
      }
      int diff = (s[n - 1 - i] - cur + 26) % 26;
      delta += diff;
      decc[to + 1] += diff;
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 42880
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(int i = 0; i <N; i++)
using namespace std;


const int MOD = pow(10,9)+7;
const int MAX = 2047483647;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}

ll gcb(ll a, ll b){/// ユークリッドの互除法: O(log)
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}


int main() {
    
    int n = in();
    
    vector<int> inputOdd(100001,0);
    vector<int> inputEven(100001,0);

    int temp;
    for(auto i = 0; i<n/2; i++){
        temp = in();
        inputOdd[temp]++;
        
        temp = in();
        inputEven[temp]++;
    }
    
    
    auto oddmax = max_element(inputOdd.begin(),inputOdd.end());
    auto evenmax = max_element(inputEven.begin(),inputEven.end());
    
    if (oddmax-inputOdd.begin() != evenmax - inputEven.begin() ){ ///最大個数の要素が同一でなければ、それに各々寄せる
        
        cout << n - *oddmax - *evenmax << endl;
        return 0;
    }
    
    
    if (*oddmax == n/2 && *evenmax == n/2 && inputOdd[0] == inputEven[0]){
        cout << n/2 << endl;
        return 0;
    }
    
    int omax = *oddmax;
    int emax = *evenmax;
    
    nth_element(inputOdd.begin(),inputOdd.begin()+1,inputOdd.end(),greater<int>());
    nth_element(inputEven.begin(),inputEven.begin()+1,inputEven.end(),greater<int>()); //second largestを比較して、大きい方に寄せる
    
    
    int cand;

    cand =  n - emax - inputOdd[1];
        
    if (cand > n - omax - inputEven[1]){
        cand =n -omax - inputEven[1];
    }

    
    cout << cand << endl;
    

    return 0;
}




Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int C[500], S[500],F[500], cnt[500];
int N;

int main(){
    cin >> N;
    
    for(int i=1;i<N;i++){
      cin >> C[i] >> S[i] >> F[i];
    }


    for(int i=1;i<N;i++){
      int res = S[i] + C[i];
      for(int j=i+1;j<N;j++){
        int time = (res+F[j]-1)/F[j];
        res = C[j] + max(S[j], time*F[j]);
      }
      cout << res <<endl;
    }
    cout << 0 <<endl;

  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n, t;
    cin >> n >> t;
    ll a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    ll lowest = a[0];
    ll dif;
    map<ll, ll> ma;
    ll maxd = 0;
    for (i = 1; i < n; i++) {
        chmin(lowest,a[i]);
        chmax(maxd,a[i]-lowest);
        ma[a[i]-lowest]++;
    }
    cout << ma[maxd] << endl;
}

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}





int main(){
    string s;
     cin >> s;
     bool ctr =0;
    for (int i = 0; i <s.size() ; ++i) {
        if(i%2){
            if(s[i]=='R')ctr=1;
        }else{
            if(s[i]=='L')ctr=1;
        }
    }
    if(ctr==1)cout<<"No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#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> 

using namespace std;

#define _int64 long long

int gcd(int x,int y)
{
  if (y==0) return x;
  else return gcd(y,x%y);
}

int main()
{
  int i,j,n,k,x,y,ma;
  scanf("%d%d",&n,&k);
  y=0;
  ma=0;
  for (i=0;i<n;i++)
  {
    scanf("%d",&x);
    y=gcd(y,x);
    if (x>ma) ma=x;
  }
  if ((k%y==0)&&(k<=ma)) printf("POSSIBLE\n");
  else printf("IMPOSSIBLE\n");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  int c[102];
  int main()
  {  string s,a,b;
       int n;
       cin>>n;
       cin>>s>>a>>b;
       for(int i=0;i<n;i++)
       {
           if(s[i]==a[i]&&s[i]==b[i])
             c[i]=0;
           else if(s[i]==a[i]||a[i]==b[i]||s[i]==b[i])
            c[i]=1;
           else c[i]=2;
       }
       int sum=0;
       for(int i=0;i<n;i++)
        sum+=c[i];
        cout<<sum<<endl;
      return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(n+1,0);
  rep(i,n){
    cin>>a[i];
  }
  
  int ans=inf;

  rep(i,n){
    vector<int> b,c;
    rep(j,n+1){
      if(a[j]<a[i]){
        sort(all(b));
        rep(l,b.size()-k+1){
          c.PB(b[l]);
        }
        b.clear();
      }else{
        b.PB(a[j]);
      }
    }
    if(c.size()<q) continue;
    sort(all(c));
    ans=min(ans,c[q-1]-c[0]);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int sum=0;
    char c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)){
        sum=sum*10+(c^48);
        c=getchar();
    }
    return sum;
}
int const maxn=200005;
int const maxm=400005;
int n,q,cnt,ans,H[maxn],f[maxn],father[maxn];
struct Edge{
    int from,to,length;
}E[maxm];
inline void add(int a,int b,int c){
    E[++cnt]=(Edge){a,b,c};
    H[a]=cnt;
}
int find(int x){
    if(father[x]!=x) father[x]=find(father[x]);
    return father[x];
}
inline bool cmp(Edge x,Edge y){
    return x.length<y.length;
}
inline void kruskal(){
    sort(E+1,E+cnt+1,cmp);
    for(int i=1;i<=n;i++)
      father[i]=i;
    for(int i=1;i<=cnt;i++){
        int r1=find(E[i].from),r2=find(E[i].to);
        if(r1!=r2) father[r1]=r2,ans+=E[i].length;
    }
}
signed main(){
    n=read(),q=read();
    for(int i=1;i<=n;i++)
      f[i]=1e16;
    for(int i=1;i<=q;i++){
        int x=read()+1,y=read()+1,z=read();
        add(x,y,z);
        f[x]=min(f[x],z+1),f[y]=min(f[y],z+2);
    }
    //这个做法要记住的，它很巧妙地通过了断环为链，并且扫两遍，求出了环的前缀
    for(int i=1;i<=2*n-1;i++){
        int pre=(i%n==1)?n:((i-1)%n);
        f[(i-1)%n+1]=min(f[(i-1)%n+1],f[pre]+2);
    }
    for(int i=1;i<=n;i++)
      add(i,i%n+1,f[i]);
    kruskal();
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 17408
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
using namespace std;
#define rep(p,q) for(int i = p;i < q; i++)

int main(void) {
	int people = 0, domestic_limit = 0, foreign_limit = 0,domestic_rank = 0,foreign_rank = 0;
	string rank;
	cin >> people >> domestic_limit >> foreign_limit >> rank;
	rep(0, people) {
		if (rank[i] == 'a' && domestic_rank + foreign_rank < domestic_limit + foreign_limit) {
			domestic_rank++;
			cout << "Yes" << endl;
		}
		else if (rank[i] == 'b' && domestic_rank + foreign_rank < domestic_limit + foreign_limit && foreign_limit > foreign_rank) {
			foreign_rank++;
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 896
n = int(input())
p = list(map(float, input().split()))
dp = [[0 for _ in range(n+1)] for _ in range(n)]
#dp[i][j]: iまで投げてj枚表の確率
dp[0][0] = 1 - p[0]
dp[0][1] = p[0]

for i in range(1, n):
	for j in range(i+2):
		if j == 0:
			dp[i][j] = dp[i-1][j] * (1 - p[i])
		else:
			dp[i][j] = dp[i-1][j] * (1 - p[i]) + dp[i-1][j-1] * p[i]

#print(dp)
ans = 0
for i in range(n//2 + 1, n+1):
	ans += dp[-1][i]
print(ans)

Measured memory_bytes: 261640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

int main(){
  int a,b;cin >> a >> b;
  if((b>0&&a<0)||b==0||a==0){
    cout << "Zero" << endl;
    return 0;
  }if(b>0){
    cout << "Positive" << endl;
    return 0;
  }
  if((a-b)%2==0)cout << "Negative" << endl;
  else cout << "Positive" << endl;
}

Measured memory_bytes: 256
import java.io.*;
 
class Main{
    public static void main (String[ ] args) throws Exception{
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        String str = br.readLine();

        String[] strarr = str.split(" ");

        int x = Integer.parseInt(strarr[0]);
        int y = Integer.parseInt(strarr[1]);
        
        if(x < y)
        {
            System.out.println("a < b");
        }
        else if(x > y)
        {
            System.out.println("a > b");
        }
        else
        {
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
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(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> T keta(T num){ T k=0; while(num>0){ num/=10; k++; } return k; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    vector<pair<ll, int>> ab;
    ll a[100010], b[100010];

    cin >> n;
    rep(i, n){
        cin >> a[i] >> b[i];
        ab.push_back(make_pair(a[i]+b[i], i));
    }

    sort(all(ab), greater<pair<ll, int>>());

    ll res = 0;
    rep(i, ab.size()){
        if(i%2 == 0) res += a[ab[i].second];
        else res -= b[ab[i].second];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(void){
	int data[2];
	int i, j;
	
	while(1){
		scanf("%d %d", &data[0], &data[1]);
		if(data[0] == 0 && data[1] == 0){
			return 0;
		}
		
		for(i=0 ; i < data[0] ; i++){
			for(j=0 ; j < data[1] ; j++){
				if(i % 2 == 0){
					if(j % 2 == 0){
						printf("#");
					}
					else{
						printf(".");
					}
				}
				else{
					if(j % 2 == 0){
						printf(".");
					}
					else{
						printf("#");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int input() {
	int r;
	cin >> r;
	//scanf("%lld", &r);
	return r;
}
int n, a[5678], dp[5678][5], dpm[5678][5];
signed main() {
	cin >> n;
	for1(i, n) {
		cin >> a[i];
		if (i == 1) {
			dp[i][0] = 0;
			dp[i][1] = 1;
			dp[i][2] = 2;
			dp[i][3] = 3;
		}
		else {
			dp[i][0] = dpm[i - 1][a[i - 1]];
			dp[i][1] = dpm[i - 1][max(a[i - 1] - 1, 0)] + 2;
			dp[i][2] = dpm[i - 1][max(a[i - 1] - 2, 0)] + 4;
			dp[i][3] = dpm[i - 1][max(a[i - 1] - 3, 0)] + 6;
		}
		dpm[i][3] = dp[i][3];
		dpm[i][2] = min(dpm[i][3], dp[i][2]);
		dpm[i][1] = min(dpm[i][2], dp[i][1]);
		dpm[i][0] = min(dpm[i][1], dp[i][0]);
	}
	dp[n + 1][0] = dpm[n][a[n]];
	dp[n + 1][1] = dpm[n][max(a[n] - 1, 0)] + 1;
	dp[n + 1][2] = dpm[n][max(a[n] - 2, 0)] + 2;
	dp[n + 1][3] = dpm[n][max(a[n] - 3, 0)] + 3;
	cout << min({ dp[n + 1][0], dp[n + 1][1], dp[n + 1][2], dp[n + 1][3] }) << endl;
}


Measured memory_bytes: 3356
#include <iostream>
#include <vector>
using namespace std;
vector<int> setElem(vector<int> v, int index, int val) {
    v[index] = val;
    return v;
}
int countEven(const vector<int>& v, int index = 0) {
    if (index == v.size()) {
        for (int i : v) if (i % 2 == 0) return 1;
        return 0;
    }
    else {
        int val = v[index];
        return countEven(setElem(v, index, val - 1), index + 1) +
                countEven(setElem(v, index, val + 1), index + 1) +
                countEven(v, index + 1);
    }
}
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int& i : A) cin >> i;
    cout << countEven(A) << endl;
}

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

using namespace std;

void solve()
{
    double a, b, c;
    cin >> a >> b >> c;
    c = c / 360 * 2 * M_PI;
    cout << fixed << setprecision(30) << a * b * sin(c) / 2 << endl;
    double d = sqrt(a * a + b * b - 2 * a * b * cos(c));
    cout << a + b + d << endl;
    cout << b * sin(c) << endl;
}

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



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

pts = 0

for i in range(N):
    if i >= 1 and A[i] == A[i - 1] + 1:
        pts += B[A[i] - 1] + C[A[i - 1] - 1]
    else:
        pts += B[A[i] - 1]

print(pts)

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

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

ll chmax(ll a,ll b){
    if(a > b) return a;
    else return b;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a (n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    vector<ll> front (n);
    vector<ll> back (n);
    for(int i=0; i<n-1; i++){
        front.at(i+1) = gcd(front.at(i),a.at(i));
    }
    for(int i=n-1; i>=1; i--){
        back.at(i-1) = gcd(back.at(i),a.at(i));
    }
    ll ans = -1;
    for(int i=0; i<n; i++){
        ans = chmax(ans,gcd(front.at(i),back.at(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
n = list(map(int, list(input())))
v1 = n[0] * 100 + n[1] * 10 + n[2] * 1
v2 = n[0] * 100 + n[0] * 10 + n[0] * 1
if v1 > v2:
    n[0] += 1
s = str(n[0])
print(''.join([s, s, s]))


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

int main() {
  int n;
  cin >> n;
  int pt = 0, px = 0, py = 0;
  bool feasible = true;
  for (int ni = 0; ni < n; ni++) {
    int t, x, y;
    cin >> t >> x >> y;
    int tdiff = t - pt;
    int diff = abs(x - px) + abs(y - py);
    if (tdiff < diff || tdiff % 2 != diff % 2) {
      feasible = false;
    }
    pt = t;
    px = x;
    py = y;
  }
  if (feasible) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,i;
	cin>>n;
	vector<ll> a(n);
	unordered_map<ll,ll> mp,ans,done,used;
	for(i=0;i<n;i++) cin>>a[i], mp[a[i]]++;
	ll tot=0, tmp,r;
	for(i=0;i<n;i++)
	{
	    if(mp[a[i]] > 1 && !used[a[i]]) {tot+=(mp[a[i]]*(mp[a[i]]-1));used[a[i]]=1;}
	}
	for(i=0;i<n;i++)
	{
	    if(!done[a[i]])
	    {
	        tmp = tot;
	        tmp-= (mp[a[i]]*(mp[a[i]]-1));
	        r = mp[a[i]] - 1;
	        if(r>1) tmp+=(r*(r-1));
	        ans[a[i]] = tmp/2;
	        done[a[i]]=1;
	    }
	    cout<<ans[a[i]]<<"\n";
	}
}

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

int N,M;

vector<vector<int>> to;
vector<bool> visited;

vector<int> res;

void dfs(int v){
 if( visited[v]){ return ;}
 
 visited[v] = true;
 
  for(auto ne : to[v]){
   dfs(ne);
  }
   
   res.push_back(v);
   
}
   


int main(){
 cin >> N >> M;
 vector<int> numbering(N,0);
 to.resize(N); visited = vector<bool>(N,false);
 for(int i = 0; i < N-1+M; i++){
 int a,b; cin >> a >> b; a--; b--;
 to[b].push_back(a); //子から親に辺をはる
 }
 
 for(int i = 0; i < N; i++){ 
 dfs(i);
 } //トポロジカルソート
 
 for(int i = 0; i < N; i++){
  numbering[res[i]] = i+1;
  }
  
 
  for(int i = 0; i < N; i++){ 
  //全ての親の中で数字が最も大きいものを採用
   int cnt = -1;
   int ans = 0;
   for(auto ne : to[i]){
     
     if( numbering[ne] > cnt ){ cnt = numbering[ne]; ans = ne+1; }
     
   }
   
   
   cout << ans << endl;
   
  }
   
   return 0;
}
   

Measured memory_bytes: 10232
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main() {
	char W[11];
	char T[1000];
	int cnt = 0;
	scanf("%s", W);
	while (1) {
		scanf("%s", T);
		if (!strcmp(T, "END_OF_TEXT"))break;
		for (unsigned int i = 0; i < strlen(T); i++) {
			if (65 <= T[i] && 90 >= T[i]) {
				T[i] += 32;
			}
		}
		if (!strcmp(W,T)) cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 2732
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N; cin >> N;
	int D = 0;
	vector<int>vec(N);
	for (int X = 0; X < N; X++) {
		cin >> vec[X];
		for (int Y = 0; Y < 30; Y++) {
			if (vec[X] % 2 == 0) {
				vec[X] /= 2;
				D++;
			}
		}
	}
	cout << D << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

template <int mod>
struct ModInt{
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p){
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while (e > 0){
            if (e % 2 == 0){
                p = (p * p) % mod;
                e /= 2;
            }
            else{
                a = (a * p) % mod;
                e--;
            }
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p){
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a){
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using modint = ModInt<mod>;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int d;
    cin>>s>>d;
    int n=s.size();
    modint dp[n+5][2][105];
    //dp[i][j][k]:i桁目までみたとき、それが値以下(j=1で未満が確定)で、かつmodがいくつか
    for(int i=0;i<=n;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<105;k++)dp[i][j][k]=0;
        }
    }
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            for(int m=0;m<d;m++){
                int lim=j?9:s[i]-'0';
                for(int k=0;k<=lim;k++){
                    dp[i+1][j||k<lim][(m+k)%d]+=dp[i][j][m];
                }
            }
        }
    }
    modint res=dp[n][0][0]+dp[n][1][0]-1;
    cout<<res<<endl;
}

Measured memory_bytes: 16640
x,y=map(int,input().split())
ans=10**9+100
for i in range(1<<2):
    if (i>>0)&1:
        x1=x*-1
    else:
        x1=x
    if (i>>1)&1:
        y1=y*-1
    else:
        y1=y
    if x1<=y1:
        ans=min(ans,y1-x1+((i>>0)&1)+((i>>1)&1))

print(ans)

Measured memory_bytes: 61488
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,s=0,p,temp;
cin>>N;
    temp=N;
while(N!=0)
{
p=N%10;

s=s+p;
        N=N/10;}
    
if(temp%s==0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N, K;
vector<int> v;
vector<int> dp;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	cin >> N >> K;
	v.resize(N);
	dp.resize(N);
	fill(all(dp), 0);
	
	for(int i = 0; i < N; i++) {
		cin >> v[i];
	}
	
	for(int i = 1; i < N; i++) {
		dp[i] = INF;
		for(int j = 1; j <= K; j++) {
			if(i - j >= 0) dp[i] = min(dp[i], abs(v[i] - v[i-j]) + dp[i-j]);
		}
	}
	
	cout << dp[N-1] << endl;

    return 0;
}


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

int main() {
    int x, a, b; cin >> x >> a >> b;
    if (b - a <= 0) {
        cout << "delicious" << endl;
    } else if (b - a <= x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}

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

int main(void){
	char S[10];
	int max=0,maxi=-1,maxj=-1;
	scanf("%s",S);
	for(int i=0;i<strlen(S);i++){
		for(int j=i;j<strlen(S);j++){
			int count=0;
			for(int k=i;k<=j;k++){
				if(S[k]=='A'||S[k]=='C'||S[k]=='G'||S[k]=='T') count++;
			}
			if(count==j-i+1){
				if(max<count){
					max=j-i+1;
				}
			}
		}
	}
	printf("%d",max);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int count=0;
		int max =0;
	    long t1 = sc.nextLong();
	    for(int i=0;i<N-1;i++) {
	    	long t2=sc.nextLong();
	    	if(t1>=t2) count++;
	    	if(count>max )max =count;
	    	if(t1 <t2 )count=0;
	    	t1 =t2;
	    	
	    }
	    
	 
		
	   System.out.println(max);
	}
	
}



Measured memory_bytes: 48040
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int mod1 = 1000000007;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  int n;
  long long int a[200000];
  long long int b[200000] = {0};
  long long int sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = n - 2; i >= 0; i--)
  {
    b[i] = (b[i + 1] + a[i + 1]) % mod1;
  }
  for (int i = 0; i < n - 1; i++)
  {
    sum += (a[i] * b[i]) % mod1;
    sum %= mod1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 6696
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;

  vector<int>p(n);
  REP(i, n) cin >> p[i]; 
  
  int ans = 0;
  REP(i, n-1){
    if(p[i] != i+1) ans++;
  }

  if(ans > 2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int m = 0, f = 0, r = 0,sum;
	scanf("%d %d %d", &m, &f, &r);
	while (m + f + r != -3)
	{
		sum = m + f;
		if (sum >= 80){ printf("A\n"); }
		else if (m == -1 || f == -1){ printf("F\n"); }
		else if (65 <= sum){ printf("B\n"); }
		else if (50 <= sum){ printf("C\n"); }
		else if (30 <= sum)
		{
			if (r >= 50){
				printf("C\n");
			}
			else{
				printf("D\n");
			}
		}
		else if (sum < 30){ printf("F\n"); }
		scanf("%d %d %d", &m, &f, &r);
	}
	return 0;
}


Measured memory_bytes: 2056
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T, X;
    cin >> T >> X;
    cout << (double)T /(double) X << endl;

    return 0;
}


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

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

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

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int k;
  cin >> k;

  int ans = 0;
  vector<vector<vector<int>>> v(k, vector<vector<int>>(k, vector<int>(k, 1)));
  for(int i=0; i<k; i++) {
    for(int j=0; j<k; j++) {
      for(int l=0; l<k; l++) {
        if(i==0 || j==0 || l==0) {
          ans++;
        }
        else if(i==j && i==l) {
          ans += i + 1;
          v[i][j][l] = i + 1;
        }
        else if(i < l) {
          ans += v[i][j][l - i - 1];
          v[i][j][l] = v[i][j][l - i - 1];
        }
        else if(j < l) {
          ans += v[i][j][l - j - 1];
          v[i][j][l] = v[i][j][l - j - 1];
        }
        else if(i > l) {
          ans += v[i - l - 1][j][l];
          v[i][j][l] = v[i - l - 1][j][l];
        }
        else if(j > l) {
          ans += v[i][j - l - 1][l];
          v[i][j][l] = v[i][j - l - 1][l];
        }
        else {
          cout << "error" << endl;
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 36124
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

int n, i, j, k;
vector<int> h(N);
int dp[N];

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                cin>>n>>k;
                for(i = 1; i<=n; i++) {
                        cin>>h[i]; dp[i] = INT_MAX;
                }
                dp[0] = dp[1] = 0;
                for(i = 2; i<=n; i++){
                        for(j = 1; j<=k; j++){
                                if(i > j) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
                        }
                }
                cout<<dp[n];
        }
        return 0;
}

Measured memory_bytes: 4048
import java.io.*
import java.util.*

fun solve(N: Long, D: Long){
    val r = 2*D + 1L
    val ans = (N/r) + if(N % r == 0L) 0L else 1L
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val D = sc.next().toLong()
    solve(N, D)
}



Measured memory_bytes: 29476
#include <iostream>
#include <deque>

int main(){
	//Switching queue
	std::deque<int> que;
	int tmp;
	
	while(std::cin >> tmp){
		if(tmp == 0){
			std::cout << que.back() << std::endl;
			que.pop_back();
		}
		else que.push_back(tmp);
	}
		return 0;
	}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long[]A = new long[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
		}
		long[]D1 = new long[61];
		long[]D2 = new long[61];
		long mod = 1000000007;
		for(var i=0;i<N;i++){
			long a = 1;
			for(var j=0;j<=60;j++){
				if(A[i]/a%2==1){
					D1[j]++;
				} else {
					D2[j]++;
				}
				a *= 2;
			}
		}
		long a1 = 1;
		long ans = 0;
		for(var i=0;i<=60;i++){
			long b1 = D1[i]*D2[i]%mod;
			b1 = a1 % mod * b1 % mod;
			ans = (ans + b1) % mod;
			a1 *= 2;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 51656
N, K, S = map(int, input().split())
ans = []
for _ in range(K):
    ans.append(S)

if S != 10**9:
    for _ in range(N-K):
        ans.append(S+1)
else:
    for _ in range(N-K):
        ans.append(S-1)

print(*ans)

Measured memory_bytes: 9692
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b,c,d; cin >> a >> b >> c >> d;
  COUT(min(a,b) + min(c,d));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N, K;
    cin >> N >> K;
    
    vec<int> h(N);
    rep(i, N) cin >> h[i];

    vec<int> dp(N+K+10,1e9+7);
    dp[1] = 0;
    for(int i=1;i<=N-1;++i)for(int k=1;k<=K&&i+k<=N;++k){
        dp[i+k] = min(dp[i+k],dp[i]+abs(h[i-1]-h[i+k-1]));
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 3980
N = int(input())
A = [int(x) for x in input().split()]

X = 1
for i in range(N):
    flg = 0
    if X == -1:
        if A[i] == 0:
            X=0
            break
    else:
        X = X*A[i]
    if X > 10**18:
        X = -1

print(X)


Measured memory_bytes: 21480
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  string S,T;
  int ans=0;
  cin >> S >> T;
  rep(i,3){
    if(S[i]==T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
void main()
{
    long k = rdElem;

    if (k <= 10)
    {
        k.writeln;
        return;
    }

    string d = "0123456789";
    string[] list;
    foreach (x; d[1..$]) list ~= x.to!string;
    long idx;
    while (list.length < k)
    {
        string s = list[idx];
        long l = max(0, s[$-1]-'0'-1), r = min(9, s[$-1]-'0'+1);
        foreach (i; l .. r+1)
        {
            list ~= s ~ i.to!string;
        }
        ++idx;
    }

    list[k-1].writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 7292
a,b,c,d,e=gets.split.map!{|i| i.to_i}
ans=0
if b>d
  ans=(c-a-1)*60+60+d-b-e
else
  ans=(c-a)*60+d-b-e
end
if ans>=0
  puts ans
else
  puts 0
end

Measured memory_bytes: 14244
#include <iostream> // cout, endl, cin
#include <vector>   // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main(void)
{
  for(int i = 0;i < 10000;i++)
  {
    int x, y;
    cin >> x >> y;
    if(x == y&&y == 0)
    break;
    if(x > y ? cout << y << " " << x:cout << x << " " << y)
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
import sys
input = sys.stdin.readline
n,k,q = map(int,input().split())
score = [k-q]*n
for i in range(q):
  a = input().strip()
  score[int(a)-1] += 1
for j in score:
  if j > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 6580
import sys
from collections import Counter
input = sys.stdin.buffer.readline
N = int(input())
D = list(map(int, input().split()))
D = Counter(D)
M = int(input())
T = list(map(int, input().split()))
T = Counter(T)

# print('D, T', D, T)
for key, value in zip(T.keys(), T.values()):
    if D.get(key, 0) < value:
        print('NO')
        exit()
print('YES')


Measured memory_bytes: 55800
S, T = [s for s in input()], [s for s in input()]
s_str = ''.join(sorted(S))
t_str = ''.join(sorted(T, reverse=True))
if s_str == t_str:
  print('No')
  exit()
else:
  print('Yes' if sorted([s_str,t_str]).index(s_str)==0 else 'No')


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b) {
			if (b < c){
				System.out.printf("%d %d %d\n",a,b,c);
			} else {
				if (a < c){	
					System.out.printf("%d %d %d\n",a,c,b);
				} else {
					System.out.printf("%d %d %d\n",c,a,b);
				}
			}
		} else if (a < c) {
			System.out.printf("%d %d %d\n",b,a,c);
		} else if (b < c){
			System.out.printf("%d %d %d\n",b,c,a);
		} else {
			System.out.printf("%d %d %d\n",c,b,a);
		}
	} 
}


Measured memory_bytes: 26208
// problem: "https://atcoder.jp/contests/abc123/tasks/abc123_d"

#include<iostream>
#include<queue>
#include<set>
#include<algorithm>
#define ll long long int
#define defv vector<ll>
using namespace std;

struct Node
{
    ll s,x,y,z;

    Node(ll s,ll x,ll y,ll z): s(s),x(x),y(y),z(z) {}
};

struct compareF
{
    bool operator()(Node const& p1,Node const& p2)
    {
        return p1.s<p2.s;
    }
};

struct index
{
    ll x,y,z;

    index(ll x,ll y,ll z): x(x),y(y),z(z) {}
};

/*
bool operator<(const index& t1, const index& t2)
{
    if(t1.x<t2.x && t1.y<t2.y && t1.z<t2.z)
        return true;

    return false;
}
*/

auto Sfind(auto it1,auto it2,index p)
{
    for(auto it=it1;it!=it2;it++)
    {
        if((*it).x==p.x && (*it).y==p.y && (*it).z==p.z)
            return it;
    }

    return it2;
}

void printKLargest(defv &A,ll X,defv &B,ll Y,defv &C,ll Z,ll K)
{
    priority_queue<Node,vector<Node>,compareF>Q;        // define compareF
    vector<index>S;

    ll M = A[0]+B[0]+C[0];
    Q.push(Node(M,0,0,0));
    S.push_back(index(0,0,0));

    // // test
    // Q.push(Node(1,2,3,4));
    // Q.push(Node(4,2,5,3));
    // Q.push(Node(2,5,3,2));
    // Q.push(Node(1,4,2,5));

    // while(!Q.empty())
    // {
    //     cout<<Q.top().s<<'\n';
    //     Q.pop();
    // }
    ll k = 0;

    while(k<K && !Q.empty())
    {
        cout<<Q.top().s<<'\n';
        k++;

        Node p(Q.top());
        Q.pop();

        if(p.x+1<X)
        {
            M = A[p.x+1]+B[p.y]+C[p.z];

            if(Sfind(S.begin(),S.end(),index(p.x+1,p.y,p.z)) == S.end())       // define
            {
                Q.push(Node(M,p.x+1,p.y,p.z));
                S.push_back(index(p.x+1,p.y,p.z));
            }
        }

        if(p.y+1<Y)
        {
            M = A[p.x]+B[p.y+1]+C[p.z];

            if(Sfind(S.begin(),S.end(),index(p.x,p.y+1,p.z)) == S.end())
            {
                Q.push(Node(M,p.x,p.y+1,p.z));
                S.push_back(index(p.x,p.y+1,p.z));
            }
        }

        if(p.z+1<Z)
        {
            M = A[p.x]+B[p.y]+C[p.z+1];

            if(Sfind(S.begin(),S.end(),index(p.x,p.y,p.z+1)) == S.end())
            {
                Q.push(Node(M,p.x,p.y,p.z+1));
                S.push_back(index(p.x,p.y,p.z+1));
            }
        }
    }
}

int main()
{
    ll X,Y,Z,K;
    cin>>X>>Y>>Z>>K;

    ll i;
    vector<ll>A(X);
    for(i=0;i!=X;i++)
        cin>>A[i];

    vector<ll>B(Y);
    for(i=0;i!=Y;i++)
        cin>>B[i];

    vector<ll>C(Z);
    for(i=0;i!=Z;i++)
        cin>>C[i];

    sort(A.begin(),A.end(),greater<ll>());
    sort(B.begin(),B.end(),greater<ll>());
    sort(C.begin(),C.end(),greater<ll>());

    printKLargest(A,X,B,Y,C,Z,K);     // define

    //printKLargest();

    return 0;
}


Measured memory_bytes: 896
solver::(String,String,String)->String
solver (a,b,c) = if (last a == head b)&&(last b == head c) then "YES" else "NO"

main::IO()
main =do
  abcc<-getLine
  let a:b:c:[]=words abcc
  putStr (solver (a,b,c))
  putStr "\n"


Measured memory_bytes: 380
N = int(input())
Ls = [int(i) for i in input().split()]


count = 0
for i in range(N):
    for j in range(i,N):
        for k in range(j,N):
            a = Ls[i] 
            b = Ls[j]
            c = Ls[k]
            if a!=b and a!=c and b!=c:
                if a+b > c and a+c > b and b+c > a:
                    count += 1

print(count)

Measured memory_bytes: 9196
import sys,collections,math,itertools,bisect;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,Q = Is()
As,Bs = [],[]
for i in range(A):
    As.append(I())
for i in range(B):
    Bs.append(I())
for i in range(Q):
    x = I()
    a = bisect.bisect_left(As,x)
    b = bisect.bisect_left(Bs,x)
    ans = 10**11
    As.append(10**11) if a == A else 0
    Bs.append(10**11) if b == B else 0
    AR = As[a] - x
    AL = x - As[a-1] if 0 < a  else 10**11
    BR = Bs[b] - x 
    BL = x - Bs[b-1] if 0 < b  else 10**11
    print(min(max(AL,BL),max(AR,BR),AL+BR+min(AL,BR),BL+AR+min(BL,AR)))


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

//class node {
//public:
//	string name;
//	int time;
//};

int main() {
	queue<pair<string, int>> qu;
	int numNode;
	int qwon;

	cin >> numNode >> qwon;
	for (int i = 0; i < numNode; i++) {
		string name;
		int time;
		cin >> name >> time;
		qu.push(make_pair(name, time));
	}

	int elaps = 0;
	while (!qu.empty()) {
		pair<string, int> q = qu.front();
		qu.pop();
		int t = q.second < qwon ? q.second : qwon;
		q.second -= t;
		elaps += t;

		if (q.second > 0) {
			qu.push(q);
		}
		else {
			cout << q.first << " " << elaps << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6236