akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
	while( 1 ){
		double s = 0;
		double a;

		cin >> a;
		if( cin.eof() ) break;

		s += a;
		for(int i = 2; i <= 10; i++){
			if( i % 2 == 0 ){
				s += a * 2;
				a = a * 2;
			}else{
				s += a / 3;
				a = a / 3;
			}
		}
		printf("%10.8f\n", s);
	}
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
# include <queue>
using namespace std;
const int N=200006;
struct node
{
	int l,r;
}a[N];
priority_queue < int,vector <int>,greater <int> > b;
int n,m,s;
int comp (node p,node q)
{
	if (p.l<q.l)
	return 1;
else if (p.l==q.l)
    if (p.r>q.r)
    return 1;
else return 0;
else return 0;
}
void work (void)
{
	int i,j,t;
	i=1;
	t=0;
	while (a[i].l==0&&i<=n)
	i++;
	for (j=1;j<i;j++)
	b.push (a[1].r);
	for (j=1;j<=m;j++)
	{
		while (a[i].l<j&&i<=n)
		{
			b.push (a[i].r);
			i++;
		}
		if (i<=n)
		{
			i++;
			t++;
			if (t==n)
			break;
		}
   else if (b.top ()<=j)
        {
        	b.pop ();
        	t++;
			if (t==n)
			break;
		}
	}
	s=n-t;
	cout<<s;
}
int main (void)
{
	int i;
	cin>>n>>m;
	for (i=1;i<=n;i++)
	cin>>a[i].l>>a[i].r;
	sort (a+1,a+n+1,comp);
	work ();
	return 0;
}


Measured memory_bytes: 2936
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.ascii;


void main()
{
  int m, d1, d2;
  readf("%s %s\n", &m, &d1);
  readf("%s %s\n", &m, &d2);
  writeln(d2 < d1 ? 1 : 0);
}


Measured memory_bytes: 380
#include <iostream>

using namespace std;

const unsigned long long limit{ 1000000007 };

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

	string s1, s2;
	cin >> s1;
	cin >> s2;

	bool flag;
	int i;
	unsigned long long result;
	if(s1[0] == s2[0]) {
		result = 3;
		i = 1;
		flag = false;
	}
	else {
		result = 6;
		i = 2;
		flag = true;
	}

	for(; i < n; ++i) {
		if(s1[i] != s2[i] && flag == true) {
			result = (3 * result) % limit;
			++i;
		}
		else if(s1[i] == s2[i] && flag == true) {
			flag = false;
			continue;
		}
		else if(s1[i] == s2[i] && flag == false){
			result = (2 * result) % limit;
		}
		else if(s1[i] != s2[i] && flag == false){
			result = (2 * result) % limit;
			flag = true;
			++i;
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    string N;
    cin >> N;
    if (N == "ABC")
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
n,m=map(int,input().split())
ans=[0]*n
l=[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    l.append(b)

import collections
c = collections.Counter(l)

for k, v in c.items():
    ans[k-1]+=v

for i in ans:
    print(i)


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

int main() {
    int h = 1, w = 1;
    while (h != 0 && w != 0) {
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i + j) % 2 == 0) cout << '#';
                else cout << '.';
            }
            cout << '\n';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 2996
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static int x;
    static int y;
    static int z;


    public static void main(String[] args) {
        read();
        solve();
    }

    public static void read() {
        x = sc.nextInt();
        y = sc.nextInt();
        z = sc.nextInt();
    }

    public static void solve() {
        int sum = 0;
        int count = -1;
        sum += z;
        while (sum <= x) {
            count++;
            sum += y;
            sum += z;
        }
        System.out.println(count);
    }
}


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

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

Measured memory_bytes: 3604
def main():
    result=[]
    n,k=list(map(float, input().split()))
    for i in range(1,int(n)+1):
        value=float(i)
        count=1
        while value<k:
            value=value*2
            count/=2
        result.append(count)
    print(sum(result)/n)
main()

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll k;
const int maxn=2e5;
int n,a[maxn],b[maxn],rt[maxn],cnt,p;
int pos,len;
int main()
{
   cin>>n>>k;
   for(int i=1;i<=n;i++) cin>>a[i];
   rt[0]=1,p=1,b[1]=0;
   while(1)
   {
   	  if(b[a[p]]!=0)
   	  {
   	  	pos=b[a[p]];
   	  	len=cnt-pos+1;
   	  	break;
		 }
	   rt[++cnt]=a[p]; //记录路径 
	   b[a[p]]=cnt;   //记录出现顺序 
	   p=a[p];
   }
   if(k<pos)cout<<rt[k];
   else
     {
     	int s=(k-pos)%len;
     	cout<<rt[s+pos];
	 }
return 0;
}


Measured memory_bytes: 5820
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#include<algorithm>
#define EPS 1e-10
using namespace std;

struct P {
  double x,y;
  P(){}
  P(double x,double y):x(x),y(y){

  }

  P operator - (P p){
    return P(x-p.x,y-p.y);
  }

  double det(P p){
    return x*p.y-y*p.x;
  }

};
  
 
  
  
bool comp(const P& p, const P& q){
  if(p.x!=q.x)return p.x<q.x;
  return p.y < q.y;
}

vector<P> totu(P* ps,int n){
  sort(ps,ps+n,comp);
  int k=0;
  vector<P> qs(n*2);
  for(int i=0;i<n;i++){
    while(k>1 && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
    qs[k++] = ps[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)k--;
    qs[k++] = ps[i];
  }
  qs.resize(k-1);
  return qs;
}



int main(){
  int n;

  while(
	cin >> n 
	&& 
	n 
	)
    {
      P ps[n+1];
      for(int i=0;i<n;i++){
	scanf("%lf,%lf",&ps[i].x,&ps[i].y);
      }
      cout << n-totu(ps,n).size() << endl;
      
    }
  
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

stack<int> st;
int main(){
    string s;
    while(cin>>s){
        if(s=="+"){
            int x=st.top();st.pop();
            int y=st.top();st.pop();
            st.push(x+y);
        }
        else if(s=="-"){
            int x=st.top();st.pop();
            int y=st.top();st.pop();
            st.push(y-x);
        }
        else if(s=="*"){
            int x=st.top();st.pop();
            int y=st.top();st.pop();
            st.push(x*y);
        }
        else st.push(stoi(s));
    }
    cout<<st.top()<<endl;
    return 0;
}


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



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout << "Yes\n";
    }
    else cout << "No\n";
}


Measured memory_bytes: 256
var a,b,c:int64;
begin
  readln(a,b,c);
  if b>=a then
    writeln('1')
  else
    if c>=b then
      writeln('-1')
    else
      if ((a-b)mod(b-c)>=1) then
        writeln(((a-b)div(b-c)+1)*2+1)
      else
        writeln((a-b)div(b-c)*2+1)
end.

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

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> A(h, vector<int>(w)), B(h, vector<int>(w));
    for (int i = 0; i < h; i++)
        copy_n(istream_iterator<int>(cin), w, A[i].begin());

    for (int i = 0; i < h; i++)
        copy_n(istream_iterator<int>(cin), w, B[i].begin());

    const int sup = 1e5;
    vector<vector<bitset<sup>>> M(h + 1, vector<bitset<sup>>(w + 1));

    M[0][0][sup / 2] = true;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            int c = abs(A[i][j] - B[i][j]);
            M[i + 1][j] |= M[i][j] << c;
            M[i + 1][j] |= M[i][j] >> c;
            M[i][j + 1] |= M[i][j] << c;
            M[i][j + 1] |= M[i][j] >> c;
        }
    }

    int ans = 1e9;
    for (int k = 0; k < sup; k++){
        if (M[h - 1][w][k])
            ans = min(ans, abs(k - sup / 2));
    }

    cout << ans << endl;
}

Measured memory_bytes: 82720
#include<iostream>

using namespace std;

typedef long long ll;

int cnt[110];

int main(){
  int a,b,c; cin >> a >> b >> c; 
  cnt[a]++; cnt[b]++; cnt[c]++;
  int m = 0;
  for(int i = 1; i<= 100; i++){
    if(cnt[i]){ m++;}
  }

  cout << m << endl; return 0;
}

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

using namespace std;

typedef long long ll;

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 round_up(int x, int base) {
    return (x + base - 1) / base;
}

int round_down(int x, int base) {
    return x / base;
}

int main(void) {
    int A, B;
    cin >> A >> B;

    int low_a = round_up(100 * A, 8);
    int high_a = round_up(100 * (A + 1), 8) - 1;

    int low_b = round_up(100 * B, 10);
    int high_b = round_up(100 * (B + 1), 10) - 1;

    if (high_a < low_b || high_b < low_a) {
        cout << -1 << endl;
    } else {
        cout << max(low_a, low_b) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

//const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }

const int h = 19, w = 15;

int main()
{
	cin.sync_with_stdio(false);
	vs fld(h);
	REP(i, h) cin >> fld[i];
	vector<vi> id(h, vi(w, -1));
	vector<pii> place;
	int cnt = 0;
	pii init;
	REP(i, h)REP(j, w)
	{
		if (fld[i][j] == '.') continue;
		if (fld[i][j] == 'O')
		{
			init = pii(i, j);
			fld[i][j] = '.';
		}
		else
		{
			id[i][j] = cnt;
			place.push_back(pii(i, j));
			cnt++;
		}
	}
	map<pair<int, pii>, int> mp;
	queue<pair<int, pii>> que;
	que.emplace(0, init);
	while (!que.empty())
	{
		auto tmp = que.front(); que.pop();
		int bit = tmp.first, tx = tmp.second.first, ty = tmp.second.second;
		//cout << bitset<20>(bit) << " " << tx << " " << ty << endl;
		if (tx >= h - 1)
		{
			cout << mp[tmp] << endl;
			return 0;
		}
		REP(i, 8)
		{
			int nx = tx + dx[i], ny = ty + dy[i];
			if (!valid(nx, ny, h, w) || fld[nx][ny] == '.' || (bit >> id[nx][ny]) & 1) continue;
			vi remove;
			while (valid(nx, ny, h, w) && fld[nx][ny] != '.' && ((bit >> id[nx][ny]) & 1) == 0)
			{
				remove.push_back(id[nx][ny]);
				nx += dx[i], ny += dy[i];
			}
			if (!valid(nx,ny,h,w) && nx != h) continue;
			int nbit = bit;
			for (auto j : remove) nbit |= 1 << j;
			pair<int, pii> nex(nbit, pii(nx, ny));
			if (mp.count(nex)) continue;
			mp[nex] = mp[tmp] + 1;
			que.push(nex);
		}
	}
	cout << -1 << endl;
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define MAXL 1000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

ll n;
vector<P> x;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}


int main() {
    cin >> n;
    ll tmp_f, tmp_s, tmp;
    rep(i, n) {
        cin >> tmp_f >> tmp_s;
        tmp = tmp_f-tmp_s;
        if (tmp<0) tmp = 0;
        x.push_back(make_pair(tmp, tmp_f+tmp_s));
    }

    sort(x.begin(), x.end(), pairCompare);

    
    ll ans = 0, t = -1;
    for(int i=0; i<n; ++i) {
        if (t <= x[i].first) {
            ++ans;
            t = x[i].second;
        }
    }

    cout << ans << endl;
}



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

int main(){
    int n;
    cin>>n;
    ll ans = 1;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n){
        cin>>a[i];
        b[a[i]]++;
    }
    if(a[0]){
        cout << 0 << endl;
        return 0;
    }
    for(int i=1; i<n;i++){
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }else{
            ans = (ans * b[a[i]-1])%998244353;
        }
    }
    
    cout << ans << endl;
    return 0;
}



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

int main()
{
  int a, b;
  char op;

  cin >> a >> op >> b;

  int ans;
  while( op != '?' ) {
    switch( op ) {
    case '+': ans = a + b; break;
    case '-': ans = a - b; break;
    case '/': ans = a / b; break;
    case '*': ans = a * b; break;

    default:
      break;
    }
    cout << ans << endl;
    cin >> a >> op >> b;
  }

  return 0;
}

Measured memory_bytes: 3076
using System;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split();
        var a = int.Parse(ab[0]);
        var b = int.Parse(ab[1]);

        if (a == 1) a += 13;
        if (b == 1) b += 13;

        if (a < b) Console.WriteLine("Bob");
        else if (b < a) Console.WriteLine("Alice");
        else Console.WriteLine("Draw");
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int candy[3];
	REP(i, 3){
		cin >> candy[i];
	}
	sort(candy, candy + 3);
	if(candy[0] + candy[1] == candy[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N, D, X;
    scanf("%d%d%d", &N, &D, &X);
    int A[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
        X += (D-1) / A[i] + 1;
    }
    printf("%d\n", X);
    return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::pair<ll, ll> PLL;
typedef std::vector<int> VI;

ll mul(ll a, ll b){
	if(((long double)a)*b > 1e18) return 1000000000ll*1000000000ll;
	return a*b;
}

const ll INF = 100000000ll*1000000000ll;
void solve(){
	ll n;
	std::cin >> n;

	ll a, b, c, d;
	std::cin >> a >> b >> c >> d;

	std::map<ll, ll> mam;
	mam[n] = 0;
	
	ll best = 1000000000ll*1000000000ll;
	FOR(_, 70){
		
		auto old = mam;
		mam.clear();
		for(auto pr : old){
			for(int i = -5; i <= 5; ++i){
				if(mam.count(pr.X+i) == 0) mam[pr.X+i] = INF;
				if(pr.X+i >= 0) mam[pr.X+i] = std::min(mam[pr.X+i],
												pr.Y + 1ll*std::abs(i)*d);
			}
		}

		for(auto pr : mam){
			best = std::min(best, pr.Y + mul(pr.X, d));
		}

		std::map<ll, ll> next;

		auto check = [&](ll a, ll cost){
			if(next.count(a) == 0) next[a] = cost;
			next[a] = std::min(next[a], cost);
		};

		for(auto pr : mam){
			if(pr.X%2 == 0)check(pr.X/2, pr.Y + a);
			if(pr.X%3 == 0)check(pr.X/3, pr.Y + b);
			if(pr.X%5 == 0)check(pr.X/5, pr.Y + c);
		}
		
		mam = next;
	}

	std::cout << best << "\n";
}

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

	int t;
	std::cin >> t;
	while(t--) solve();

	return 0;
}

Measured memory_bytes: 4404
#include <iostream>
using namespace std;
const int64_t INF = 1145141919;
int main(){
    int64_t minx;
    int64_t res = -1 * INF;
    int n; cin >> n;
    for(int i=0; i<n; ++i){
        int64_t x; cin >> x;
        if(!i){
            minx = x;    
            continue;
        }
        res = max(res, x-minx);
        minx = min(minx, x);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const int N = 1e6 + 5;
const long long INF = 1e18;
const int mod = 1000000007;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

long long t;
int arr[N];
int ans = 0;

int main()
{
	cin >> t;
	while(t % 2 == 0)
	{
		arr[2]++;
		t /= 2;
	}
	while(t % 3 == 0)
	{
		arr[3]++;
		t /= 3;
	}
	for(int i = 5; i <= sqrt(t); i = i + 6)
	{
		while(t % i == 0)
		{
			arr[i]++;
			t /= i;
		}
		while(t % (i + 2) == 0)
		{
			arr[i + 2]++;
			t /= (i + 2);
		}
	}
	for(int i = 1; i <= 1e6; i++)
	{
		for(int j = 1; j <= 100; j++)
		{
			if(j > arr[i])
			{
				break;
			}
			ans++;
			arr[i] -= j;
		}
	}
	if(t != 1)
	{
		cout << ans + 1;
	}
	else
	{
		cout << ans;
	}
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	vector<int> v(5);
	int k; 
	REP(i, 5) cin >> v[i]; 
	cin >> k;

	for(int i = 0; i < 5; ++i){
			for(int j = i+1; j < 5; ++j){
					if(v[j] - v[i] > k ){
							cout << ":(" << endl;
							return 0;
					}
			} 
	}
	cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a, b, c, m;
    scanf("%d %d %d %d",&a,&b,&c,&m);
    int sum=0;
    sum=max(a, max(b, c));
    if(sum==a)
    {
        while(m--)
            a*=2;
        printf("%d",a+b+c);
    }
    else if(sum==b)
    {
        while(m--)
            b*=2;
        printf("%d",a+b+c);
    }
    else
    {
        while(m--)
            c*=2;
        printf("%d",a+b+c);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int , int>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define fl(i , n) for(int i = 0;i<n;i++)


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

    int cnt = 0;
    for(int i = 0 ; i <3;i++)
    {
        if(s[i] == t[i])cnt++;
    }

    cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		long ans=0;
		for(int i = 0;s[0]*i<=s[3];i++) {
			for(int j = 0;j*s[1]<=(s[3]-s[0]*i);j++) {
				//((s[3]-s[0]*i)-j*s[1])
				if(((s[3]-s[0]*i)-j*s[1])%s[2]==0){
					//Console.WriteLine("{0} {1} {2}",i,j,((s[3]-s[0]*i)-j*s[1])/s[2]);
					ans++;
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 11220
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format;

void main(string[] args)
{
    auto s = readln.strip();
    long cnt = 0;
    foreach (i; 0 .. s.length / 2)
    {
        if (s[i] != s[s.length - i - 1])
        {
            cnt++;
        }
    }
    writeln(cnt);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MAXN=10000;
using namespace std;

int x[MAXN], y[MAXN];

void mainp()
{
	int n;
	cin>>n;
	long long all=1ll;
	long long odd=1ll;
	for(int i=0; i<n; i++) cin>>x[i];
	for(int i=0; i<n; i++)
	{
		all*=3ll;
		if(x[i]%2==0) odd*=2ll;
	}
	
	cout<<(all-odd)<<endl;
}
int main()
{
	mainp();
	return 0;
}


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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

int const N=1e6+100;
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
int const BN = 31;

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

void dfs(int r, vint gr[], vlong &xsum, vlong &ans, ll psum, vint &vst){
	psum+=xsum[r];
	ans[r]=psum;
	vst[r]=0;
	for(auto x : gr[r]){
		if(vst[x]==1){
			dfs(x,gr,xsum,ans,psum,vst);
		}
	}
}

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

	int n;
	cin>>n;
	unordered_map<string,ll> cnt;
	for(int i=0; i<n; i++){
		string str;
		cin>>str;
		sort(all(str));
		cnt[str]++;
	}

	ll ans=0;
	for(auto x : cnt){
		ans+=x.scd*(x.scd-1)/2;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 10660
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <cmath>
#include <cstdlib>
#include <locale>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define pb push_back 
#define ALL(I) (I).begin(), (I).end()
#define MAX 100005
#define F first
#define S second
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
LL dis[MAX];
int group[MAX];
int siz[MAX];
vector<int>member[MAX];
int find_set(int v){
    return v == group[v] ? v : group[v] = find_set(group[v]);
}
int Union(int v1, int v2, int d){
    int l1 = find_set(v1);
    int l2 = find_set(v2);
    if(l1 == l2){
        if(dis[v2] == dis[v1] + d) return 1;
        else return 0;
    }
    int t = 0;
    if(member[l1].size() > member[l2].size()){
        swap(l1, l2); t = 1;
    }
    int v = dis[v2] - d - dis[v1];
    if(t) v = -v;
    rep(i, member[l1].size()){
        dis[ member[l1][i] ] += v; 
        member[l2].pb(member[l1][i]);
    }
    group[l1] = l2;
    return 1;
}
int main(void){
    int n, m; scanf("%d %d", &n, &m);
    rep1(i, 1, n+1){
        dis[i] = 0; group[i] = i; member[i].pb(i);
    }
    bool flag = 0;
    rep(i, m){
        int v1, v2, d; scanf("%d %d %d", &v1, &v2, &d);
        if(flag) continue;
        int r = Union(v1, v2, d);
        if(!r) flag = 1;
    }
    if(flag) puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 10620
package main
import (
	"fmt"
)

func main(){
	var n, x int
	fmt.Scan(&n, &x)
	ms := make([]int, n)
	min :=  999999999999999
	sum := 0
	for i:=0; i<n; i++{
		var mi int
		fmt.Scan(&mi)
		ms[i] = mi
		sum+=mi
		if mi<min{
			min = mi
		}
	}
	fmt.Println(n+(x-sum)/min)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int h,w;cin>>h>>w;
	char g[h+2][w+2];
	rep(i,h+2) rep(j,w+2) g[i][j]='1';
	for(int i=1;i<h+1;i++) for(int j=1;j<w+1;j++) cin>>g[i][j];
	for(int i=1;i<h+1;i++){
		for(int j=1;j<w+1;j++){
			if(g[i][j]=='.'){
				int cnt=0;
				for(int k=-1;k<2;k++){
					for(int l=-1;l<2;l++){
						if(g[i+k][j+l]=='#') cnt++;
					}
				}
				g[i][j]=cnt+'0';
			}
		}
	}
	for(int i=1;i<h+1;i++){
		for(int j=1;j<w+1;j++){
			cout<<g[i][j];
		}
		cout<<"\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;
  
#define MP make_pair
#define PB push_back
#define MAX_N 2001000
#define SIZE 2000
#define X first
#define Y second
  
const int STX = 1000, STY = 1000;

typedef pair<int, int> Pii;
typedef pair<int, Pii> P;
  
int id[SIZE][SIZE];
bool is_prime[MAX_N+1];
vector<Pii> coord;

void Sieve() {
  fill(is_prime, is_prime+MAX_N+1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2; i*i<=MAX_N; i++)
    if(is_prime[i])
      for(int j=i*i; j<=MAX_N; j+=i)
	is_prime[j] = false;
}

void MakeMap() {
  int x = STX, y = STY;
  int cnt = 0;
  
  coord.PB(MP(0, 0)); // no use
  cnt ++;
  coord.PB(MP(x, y)); // cnt = 1
  
  fill(id[0], id[0]+SIZE*SIZE+1, -1);
  
  const int dx[] = {0,-1,0,1};
  const int dy[] = {-1,0,1,0};
  
  int a = 0; x = STX+1; y = STY+1;
  while(cnt <= MAX_N) {
    a += 2;
    for(int turn=0; turn<4; turn++) {
      for(int i=0; i<a; i++) {
	x += dx[turn], y += dy[turn];
	coord.PB(MP(x, y));
	id[y][x] = ++ cnt;
      }
    }
    x++, y++;
  }
}

int dp[MAX_N+1];

int main() {
  
  Sieve();
  MakeMap();
  
  int m, n;

  while(cin >> m >> n && (m|n)) {
    
    fill(dp, dp+MAX_N+1, -1);
    dp[n] = is_prime[n];
    Pii ans(dp[n], n);
    
    queue<P> que;
    que.push(P(dp[n], coord[n]));
    while(!que.empty()) {
      P now = que.front(); que.pop();
      int tmpid = id[now.second.Y][now.second.X];
      if(now.first < dp[tmpid]) continue;
      
      int noid = id[now.second.Y][now.second.X];
      
      for(int i=-1; i<=1; i++) {
	Pii nex = MP(now.second.X+i, now.second.Y+1);
	if(nex.X < 0 || SIZE <= nex.X || nex.Y < 0 || SIZE <= nex.Y) continue;
	int neid = id[nex.Y][nex.X];
	if(neid <= m) {
	  if(dp[neid] < dp[noid] + is_prime[neid]) {
	    dp[neid] = dp[noid] + is_prime[neid];
	    if(is_prime[neid]) ans = max(ans, MP(dp[neid], neid));
	    que.push(P(dp[neid], nex));
	  }
	}
      }

    }
    
    if(ans.first == 0) cout << "0 0" << endl;
    else cout << ans.first << ' ' << ans.second << endl;
  }
  return 0;
}

Measured memory_bytes: 42352
use std::io;


fn main() {
    let c1 = read_one::<String>().chars().collect::<Vec<char>>();
    let c2 = read_one::<String>().chars().collect::<Vec<char>>();
    let c3 = read_one::<String>().chars().collect::<Vec<char>>();

    println!("{}{}{}", c1[0], c2[1], c3[2]);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=1e5+5;
ll c[N];
void solve()
{
	ll n;
	cin>>n;
	ll a[n+1],b[n+1],c[n];
	ll i,j;
	ll ans=0;
	rep(i,0,n){
		cin>>a[i];
	}
	rep(i,1,n+1){
		cin>>b[i];
	}
	rep(i,1,n)
	cin>>c[i];
	rep(i,0,n){
		if(i==0){
			ans+=b[a[i]];
		}else if(a[i]==1){
			ans+=b[1];
		}else{
			ans+=b[a[i]];
			if(a[i-1]==a[i]-1){
				ans+=c[a[i]-1];
			}
		}
	}
	cout<<ans;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
/*氏名：保坂優介, 学籍番号：200441141
  概要：*/

#include<stdio.h>

int main(void)
{
    int i, j, k, r, c;
    long num[102][102] = { 0 };

    scanf("%d %d", &r, &c);

    for (i = 0; i < r; i++)
    {
        for (j = 0; j < c; j++)
        {
            scanf("%d", &k);

            num[i][j] = k;
        }
    }

    for (i = 0; i < r; i++)
    {
        for (j = 0; j < c; j++)
        {
            num[i][c] = num[i][c] + num[i][j];
        }
    }

    for (i = 0; i < c; i++)
    {
        for (j = 0; j < r; j++)
        {
            num[r][i] = num[r][i] + num[j][i];
        }
    }

    for (i = 0; i < r; i++)
    {
        num[r][c] = num[r][c] + num[i][c];
    }

    for (i = 0; i <= r; i++)
    {
        for (j = 0; j <= c; j++)
        {
            printf("%d",num[i][j]);

            if (j < c)
            {
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}


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

int main(void)
{
    int x, y;
    int xg, yg;
    cin >> x >> y;
    if(x==2)
        xg=3;
    else if(x==4 or x==6 or x==9 or x==11)
        xg=2;
    else
        xg=1;
    if(y==2)
        yg=3;
    else if(y==4 or y==6 or y==9 or y==11)
        yg=2;
    else
        yg=1;

    if(xg==yg)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n;
    cin >> n;
    int dd = 2;
    int ans = 0;
    for (int i = 2; i * i <= n; ++i)
    {
        if (n % i)
            continue;
        int ct = 0;
        while (n % i == 0)
        {
            n = n / i;
            ct++;
        }
        int pre = 1;
        while (pre <= ct)
        {
            ans++;
            ct -= pre;
            pre++;
        }
    }
    if (n > 1)
        ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	ll A,B,C;
	cin>>A>>B>>C;
	cout<<B + min(A+B+1, C)<<endl;
	return 0;
}

Measured memory_bytes: 256
List=list(input())
A="".join(List[:2])
B="".join(List[2:])
a=int(A)
b=int(B)
if 1<=a<=12 and 1<=b<=12:
    print("AMBIGUOUS")
elif 1<=a<=12 and (b==0 or b>12):
    print("MMYY")
elif (a==0 or a>12) and 1<=b<=12:
    print("YYMM")
else:
    print("NA")
    


Measured memory_bytes: 3060
/*Bismillahir Rahmanir Rahim
->>Code by Ashraful Islam Paran
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define f(a,b,x) for(int a=b;a<x;a++)
#define pb push_back
#define endl "\n"
#define MX 200000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define vi vector<int>

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

    string s;
    cin >> s;
    f(i,0,s.size())
    {
        if(s[i] == '?')
        {
            s[i] = 'D';
        }
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int n,m;
int f[200005],v[200005]={0};
pair<int,int> ind[200003]=make_pair(0,0);
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) f[i]=0;
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		f[y]=x;
		ind[y].first++;
		ind[y].second=y;
	}
	sort(ind+1,ind+n+1);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		v[x]+=y;
	}
	for(int i=2;i<=n;i++){
		v[ind[i].second]+=v[f[ind[i].second]];
	}
	for(int i=1;i<=n;i++) printf("%d ",v[i]);
}


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

void main()
{
	int[4] type;
	foreach (line; stdin.byLine) {
		auto st = line.split(",");
		if (st[1] == "A") type[0]++;
		else if (st[1] == "B") type[1]++;
		else if (st[1] == "O") type[3]++;
		else type[2]++;
	}
	foreach (t; type) {
		t.writeln;
	}
}

Measured memory_bytes: 1064
#include <iostream>
using namespace std;
int main() {
  long long ans = 0;
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  ans = a * c;
  ans = max(ans, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  cout << ans;
  return 0;
}

Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc119/tasks/abc119_d
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define INFL (1e18)
#define PI (acos(-1))

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);
    REP(i, a) cin >> s[i];
    REP(i, b) cin >> t[i];
    REP(i, q) cin >> x[i];
    sort(ALL(s));
    sort(ALL(t));
    for (auto i : x) {
        // 指定キー以上のイテレータを返す
        auto is1 = lower_bound(ALL(s), i);
        auto it1 = lower_bound(ALL(t), i);
        // 1つ前のイテレータを保存
        auto is2 = is1;
        auto it2 = it1;

        bool fminus = true, fplus = true;
        if (is1 != s.begin()) {
            is2 = prev(is1);
        }
        if (it1 != t.begin()) {
            it2 = prev(it1);
        }

        if (is1 == s.begin() || it1 == t.begin()) {
            fminus = false;
        }
        if (is1 == s.end() || it1 == t.end()) {
            fplus = false;
        }
        ll ans = INFL;
        // 開始位置からマイナス方向のみ
        if (fminus) {
            ans = max(abs(*is2 - i), abs(*it2 - i));
        }
        // 開始位置からプラス方向のみ
        if (fplus) {
            ans = min(ans, max(abs(*is1 - i), abs(*it1 - i)));
        }
        // 両方向
        ll nears, neart, sum;
        if (abs(*is1 - i) < abs(*is2 - i)) {
            nears = *is1;
        } else {
            nears = *is2;
        }
        if (abs(*it1 - i) < abs(*it2 - i)) {
            neart = *it1;
        } else {
            neart = *it2;
        }
        sum = abs(nears - i) + abs(neart - i) +
              min(abs(nears - i), abs(neart - i));
        ans = min(ans, sum);

        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void Sort(int A[],int n){
  int i,j,k;
  for(i=1;i<n;i++){
    k =A[i];
    j = i-1;
    while(j >= 0 && A[j] > k){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = k;
    trace(A,n);
  }
}

int main(){
  int n, i, j;
  int A[N+1];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  Sort(A,n);

  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
#include <stdlib.h>
#include <string.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
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int A, B, M;
  scanf("%d %d %d", &A, &B, &M);

  int a[MAX], b[MAX];
  rep(i, 0, A) scanf("%d", &a[i]);
  rep(i, 0, B) scanf("%d", &b[i]);
  int x[MAX], y[MAX], c[MAX];
  rep(i, 0, M) scanf("%d %d %d", &x[i], &y[i], &c[i]);

  int ma = INF, mb = INF;
  rep(i, 0, A) ma = min(a[i], ma);
  rep(i, 0, B) mb = min(b[i], mb);

  int ans = ma + mb;
  rep(i, 0, M) {
    ans = min(ans, a[x[i]-1] + b[y[i]-1] - c[i]);
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>

#define N (100)
#define N_RESULT (100)

int main(){
        int     shoot, set;
        int     hit, total;
        char    str[N];
        int     result[N_RESULT];
        int     i, j;

        for( i=0; i<N_RESULT; i++ ){
                // Scan number of shuut
                fgets( str, N-1, stdin );
                sscanf( str, "%d", &shoot );
                if( shoot == 0 ) break;
                else if( ( shoot % 4 ) != 0 ){
                        fprintf( stderr, "Invalid number\n" );
                        return 1;
                }
                set = shoot / 4;
                // Scan numberof hit
                total = 0;
                for( j=0; j<set; j++ ){
                        fgets( str, N-1, stdin );
                        sscanf( str, "%d", &hit );
                        total += hit;
                }
                result[i] = total;
        }

        // Show results
        for( j=0; j<i; j++ ){
                printf( "%d\n", result[j] );
        }

        return 0;
}



Measured memory_bytes: 2028
#include<stdio.h>                                                 
#include<string.h>                                                
int main(void){                                                   
   char s[3];                                                     
   scanf("%s",s);                                                 
                                                                  
   if(!strcmp(s,"ABC")){                                          
      printf("ARC");                                              
   }else{                                                         
      printf("ABC");                                              
   }                                                              
   return 0;                                                      
} 

Measured memory_bytes: 1728
s=input()
l=len(s)
j=0
k=0

if s[0]=="A":
    for i in range(2,l-1):
        if s[i]=="C":
            j=i
            k+=1

if k==1:
    if s[1:j].islower() and s[j+1:l].islower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
/**
 * Explanation : Answer is the gcd of the entire array
 * 
*/
// https://atcoder.jp/contests/abc118/tasks/abc118_c
// NOT SOLVED
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ll n;
    cin >> n;
    int answer = 0, this_health;
    for (ll i = 0; i < n; i++)
    {
        cin >> this_health;
        answer = (i == 0) ? this_health : gcd(answer, this_health);
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<functional>
#include<algorithm>
#include<math.h>
#include<unordered_map>
#include<string.h>
#include<limits.h>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<unordered_set>
#include<deque>
#define int long long
#define P pair<int,int>
using namespace std;

P a[200000];
signed main() {
	int b; scanf("%lld", &b);
	for (int c = 0; c < b; c++) {
		scanf("%lld%lld", &a[c].first, &a[c].second);
	}
	int ans = LLONG_MAX / 3;
	if (1) {
		int n, m, x, y; n = x = 0; m = y = LLONG_MAX/3;
		for (int i = 0; i < b; i++) {
			if (a[i].first > a[i].second) {
				swap(a[i].first, a[i].second);
			}
			n = max(n, a[i].first);
			m = min(m, a[i].first);
			x = max(x, a[i].second);
			y = min(y, a[i].second);
		}
		ans = (x - y)*(n - m);
	}
	map<int, int>M, X;
	for (int i = 0; i < b; i++) {
		M[a[i].first]++;
		X[a[i].second]++;
	}
	sort(a, a + b);
	for (int i = 0; i < b; i++) {
		M[a[i].first]--;
		if (M[a[i].first] == 0) {
			M.erase(a[i].first);
		}
		X[a[i].second]--;
		if (X[a[i].second] == 0) {
			X.erase(a[i].second);
		}
		M[a[i].second]++;
		X[a[i].first]++;
		P S = *M.rbegin(),T=*M.begin();
		P p = *X.rbegin(), q = *X.begin();
		ans = min(ans, (p.first-q.first)*(S.first-T.first));
	}
	cout << ans << endl;
}

Measured memory_bytes: 30464
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,temp;
  int temp1,temp2,q;
  int rev=0;
  cin >> s >> q;
  while(q--){
    cin >> temp1;
    if(temp1==1){
      if(s.size()!=1)rev++;
    }
    else{
      cin >> temp2 >> temp;
      if((rev+temp2)%2==1) s.insert(0,temp);
      else s.push_back(temp[0]);
    }
  }
  if(rev%2==0) cout << s << endl;
  else{
    reverse(s.begin(),s.end());
    cout << s  << endl;
  }
  return 0;
}

Measured memory_bytes: 912
#include <stdio.h>

int main(){
   int h, w;
   int i, j;
   while(1){
       scanf("%d %d ", &h, &w);
       if(h==0&&w==0)break;
       for(i=0;i<h;i++){
           for(j=0;j<w;j++){
               if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){
                   printf("#");
               }else{
                   printf(".");
               }
           }
           printf("\n");
       }
       printf("\n");
   }

   return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define fi first
#define se second
#define reset(n,k) memset((n),k,sizeof(n))
#define all(n) n.begin(),n.end()
#define pb push_back
using namespace std;
using ll=long long;
using pii=pair<int,int>;
int ope,q,ta;
deque<char> dq;
string s;
char c;
bool rev= 0;

int main(){
	IOS;
	
	cin>>s;
	for(auto i:s) dq.pb(i);
	
	cin>>q;
	while(q--){
		cin>>ope;
		if(ope == 1) rev^=1;
		else{
			cin>>ta>>c;
			if(rev){
				if(ta == 1){
					dq.pb(c);
				}
				else{
					dq.push_front(c);
				}
			}
			else{
				if(ta==1){
					dq.push_front(c);
				}
				else{
					dq.pb(c);
				}
			}
		}
	}
	if(rev) reverse(all(dq));
	for(auto i:dq)cout<<i;
	cout<<'\n';

}


Measured memory_bytes: 976
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
string s, t;
void solve() {  
    cin >> s >> t;
    for (char a = 'a'; a <= 'z'; ++a) {
        if (s + a == t) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}       
    

Measured memory_bytes: 3676
#pragma GCC optimize("Ofast")  
#include<bits/stdc++.h>
using namespace std;

#define ll 				long long
#define eb 				emplace_back
const long long 		MOD = 1e9 + 7;
#define rep(i,n) 		for (int (i) = 0; (i) < (n); (i)++) 
#define REP(i,k,n)  	for (int (i) = (k); (i) <= (n); (i)++) 
#define REPR(i,k,n) 	for (int (i) = (k); (i) >= (n); (i)--)
#define watch(x) 		cout << (#x) << " = " << (x) << endl
#define t(x)			int x; cin >> x; while(x--)

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	/*---- continue Coding ;----*/

	int n;
    cin >> n;
    int a[n], b[n];
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    int count = 0;
    rep(i, n){
        if(a[i] == b[i]){
            count++;
        }else{
            if(count >= 3)
                break;
            else
                count = 0;
        }
        
    }
    count >= 3 ? cout << "Yes\n" : cout << "No\n";
	
	/*---- break ;----*/

	cerr<<"Execution time: "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}


Measured memory_bytes: 3776