akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7, INF = 0x3f3f3f3f;
int dp[1000010][2];

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s; cin >> s; s = '0' + s;
	vector<int> v;
	for(int i = 0; i < s.size(); ++ i){
		v.push_back(s[i] - '0');
	}
	int n = v.size();
	dp[0][0] = 0; dp[0][1] = INF;
	for(int i = 1; i <= n; ++ i){
		dp[i][0] = min(dp[i - 1][0], dp[i - 1][1] + 1) + v[i];
		dp[i][1] = min(dp[i - 1][1] - 1, dp[i - 1][0]) + 10 - v[i];
	}
//	for(int i = 1; i <= n; ++ i){
//		cout << dp[i][0] << ' ';
//	}
//	cout << endl;
//	for(int i = 1; i <= n; ++ i){
//		cout << dp[i][1] << ' ';
//	}
//	cout << endl;
	cout << min(dp[n][0], dp[n][1]) << '\n';
	return 0;
}

Measured memory_bytes: 15044
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b;
string s;
signed main()
{
	cin>>a>>b;
	if((a+b)%2==1){
		cout<<"IMPOSSIBLE"<<endl;
	}else{
		cout<<(a+b)/2;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;

int main()
{
	IOS
	ll k,i,x;
	cin>>k>>x;
	for(i=x-k+1;i<x+k;i++)
			cout<<i<<" ";
	return 0;

}             

Measured memory_bytes: 256
let n=read_int()open List;;let rec p=function|(_,_,[])->true|(x::a,[],z::c)when x<z->p(z::a,[],c)||p(x::a,[z],c)|(x::a,[],z::c)when x>=z->p(x::a,[z],c)|(x::a,y::b,z::c)when x>=z&&y<z->p(x::a,z::b,c)|(x::a,y::b,z::c)when x<z&&y>=z->p(z::a,y::b,c)|(x::a,y::b,z::c)when x<z&&y<z->p(z::a,y::b,c)||p(x::a,z::b,c)|_->false;;let rec q i=if i<n then let l=map int_of_string(Str.split(Str.regexp" ")(read_line()))in q(print_endline(if p([hd l],[],tl l)then"YES"else"NO");i+1);;q 0

Measured memory_bytes: 2132
w = []
k = []
for i in 0..9
  w[i] = gets.chomp.to_i
end
w.sort!
w_sum = w[9]+w[8]+w[7]
for j in 0..9
  k[j] = gets.chomp.to_i
end
k.sort!
k_sum = k[9]+k[8]+k[7]
s = [w_sum,k_sum]
puts s.join(' ')



Measured memory_bytes: 6864
n = int(input())
a = list(map(int,input().split()))

if max(a)-min(a) == 0:
    if a[0] == n-1 or 2*a[0] <= n:
        print("Yes")
    else:
        print("No")
elif max(a)-min(a) == 1:
    A = max(a)
    alone = 0
    not_alone = 0
    for i in a:
        if i == A:
            not_alone += 1
        else:
            alone += 1
    if alone < A and 2*(A-alone) <= not_alone:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 20716
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	int L;
	int N{ 0 };
	int n_edges{ 0 };
	int gaps;
	vector<tupiii> added;
public:
	D()
	{
		cin >> L;

		int pow{ 1 };
		while (pow <= L) pow *= 2, ++N;

		gaps = N - 1;
		n_edges = 2 * gaps;
	}

	void solve()
	{
		int defi{ L - (1 << gaps) };
		for (int bit{ 0 }; defi >= (1 << bit); bit++)
			if (defi & (1 << bit))
				++n_edges;

		cout << N << " " << n_edges << endl;

		REP1O(i, N)
		{
			cout << i << " " << i + 1 << " " << 0 << endl;
			cout << i << " " << i + 1 << " " << (1 << (i - 1)) << endl;
		}

		int now{ 1 << gaps };
		for (int bit{ 21 }; bit >= 0; bit--)
		{
			if (defi & (1 << bit))
			{
				cout << bit + 1 << " " << N << " " << now << endl;
				now += (1 << bit);
			}

		}
		
	}

};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		String[] a;
		long x,y;
		
		while(str!=null){
			a=str.split(" ",0);
			x=Integer.parseInt(a[0]);
			y=Integer.parseInt(a[1]);
			System.out.println(koyaku(x,y)+" "+kobai(x,y));
			str=br.readLine();
		}

	}
	
	public static long kobai(long x, long y){
		long l,s,num;
		if(x>=y){l=x;s=y;}
		else{l=y;s=x;}
		
		num=l;
		while(num%s!=0){
			num=num+l;
		}
		return num;
	}
	
	public static long koyaku(long x, long y){
		long l,s;
		if(x>=y){l=x;s=y;}
		else{l=y;s=x;}
		
		if(l%s==0) return s;
		return koyaku(s,l%s);
	}

}

Measured memory_bytes: 24116
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.HashSet;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        long a = fs.nextLong();
        long v = fs.nextLong();
        long b = fs.nextLong();
        long w = fs.nextLong();
        long t = fs.nextLong();
      	if(Math.abs(a-b) <= (v-w)*t){
        	System.out.println("YES"); 

        }else{
        	System.out.println("NO"); 
        }
        
  }
  public static int calcMin(int[] array) {

    int intMin = array[0];

    for (int i = 1; i < array.length; i++ ) {
        if(intMin > array[i]) {
            intMin = array[i];
        }
    }
    return intMin;
}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte(){
        if(ptr < buflen){
            return true;
        }else{
            ptr = 0;
            try{
                buflen = in.read(buffer);
            }catch(IOException e){
                e.printStackTrace();
            }
            if(buflen <=0){
                return false;
            }
        }
        return true;
    }

    private int readByte(){
        if(hasNextByte())return buffer[ptr++];
        else return -1;
    }

    private static boolean isPrintableChar(int c){
        return 33<=c && c<=126;
    }
    public boolean hasNext(){
        while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;
        return hasNextByte();
    }

    public String next(){
        if(!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong(){
        if(!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if(b == '-'){
            minus = true;
            b = readByte();
        }
        if(b < '0' || '9' < b){
            throw new NumberFormatException();
        }
        while(true){
            if('0' <= b && b<='9'){
                n*=10;
                n+=b-'0';
            }else if(b==-1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt(){
        long nl = nextLong();
        if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDoutble(){return Double.parseDouble(next());}
}


Measured memory_bytes: 32480
#include <array>
#include <iostream>
#include <vector>

int main()
{
    int N, T, A;
    std::cin >> N;
    std::cin >> T >> A;
    int height;
    std::cin >> height;
    int ans = 0;
    double min = std::abs(T - 0.006 * height - A);
    double tmp;
    for (int i = 1; i < N; i++) {
        std::cin >> height;
        tmp = std::abs(T - 0.006 * height - A);
        if (tmp < min) {
            ans = i;
            min = tmp;
        }
    }
    std::cout << ans + 1 << std::endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = 0;
    if(A+B <= C+C){
        ll cnt = min(X,Y);
        ans += (A+B) * cnt;
    } else {
        ll cnt = min(X,Y);
        ans += (C+C) * cnt;
    }
    ll bcnt = abs(X-Y);
    if(X > Y){
        ans += min(bcnt*A,bcnt*C*2);
    } else if(X < Y){
        ans += min(bcnt*B,bcnt*C*2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int ans[200000];
vector <int> v[200000];
map <int, int> mp[200000];

int count(int x, int y, int m) {
    int ans = 1, i;
    
    if (mp[x].count(m)) return mp[x][m];
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i] >= m) break;
        if (v[x][i] == y) continue;
        
        ans += count(v[x][i], x, m);
    }
    
    return mp[x][m] = ans;
}

void dfs(int x, int y, int m) {
    int i;
    
    if (x > 0) {
        if (x > y && x > m) {
            ans[x] = ans[y] + count(x, y, max(y, m));
        } else if (m > x && m > y) {
            ans[x] = ans[y];
        } else if (x > m) {
            ans[x] = ans[y] + count(x, y, y);
        } else {
            ans[x] = ans[y] + count(x, y, y) - count(x, y, m);
        }
    }
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i] == y) continue;
        
        dfs(v[x][i], x, max(y, m));
    }
}

int main() {
    int n, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n - 1; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    for (i = 0; i < n; i++) sort(v[i].begin(), v[i].end());
    
    dfs(0, -1, -1);
    
    for (i = 1; i < n; i++) {
        if (i > 1) putchar(' ');
        printf("%d", ans[i]);
    }
    puts("");
    
    return 0;
}


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

using namespace std;

int main(){

	int W;
	int n;


	int cs=0;
	while(cin>>W&&W!=0){
		int v[1001];
		int w[1001];
		
		int dp[1001][1001];
		cin>>n;
		for(int i = 0; i < n; i++){
			char cm;
			cin>>v[i]>>cm>>w[i];
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j <= 1000; j++){
				if(i==0){
					if(j==w[0]){
						dp[i][j]=v[i];
					}
					else{
						dp[i][j]=0;
					}
				}
				else{
					if(j-w[i]>=0){
						dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
					}
					else{
						dp[i][j]=dp[i-1][j];
					}
				}
			}
		}
		int idx=0;
		int maxNum=-1;
		for(int i = 0; i <= W; i++){
			if(maxNum<dp[n-1][i]){
				maxNum=dp[n-1][i];
				idx=i;
			}
		}
		cout<< "Case " << cs+1 << ':' << endl;
		cout<<maxNum<<endl;
		cout<<idx<<endl;

		cs++;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>;
using namespace std;
int main() {
	int a=0, c=0,k=0;
	string s;
	cin >> s;
	if (s[0] == 'A') { a = 1; }
		for (int i = 2; i < s.length()-1; i++) {
			if (s[i] == 'C') {
				c++;
			}
		}
		for (int j = 0; j < s.length() ; j++) {
			if (isupper(s[j])) {
				k++;
			}
		}
	
	if (a==1 && c == 1 && k==2 ) { cout << "AC"; }
	else { cout << "WA"; }
	return 0; }

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

int main() {
  int n,a,b;cin>>n>>a>>b;
  if((b-a)%2==0)cout<<"Alice"<<endl;
  else cout<<"Borys"<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

int func(int a, int b, int c)
{
	return ((a * c) + b) % 26;
}

int main(void)
{
	int n;
	string a;
	getline(cin, a);
	
	n = atoi(a.c_str());
	for (int i = 0; i < n; i++){
		// cout << "*" << endl;
		string str;
		getline(cin, str);
		
		for (int a = 0; a < 100; a++){
			for (int b = 0; b < 100; b++){
				string tmp = str;
				for (int j = 0; j < str.size(); j++){
						if (tmp[j] == '.') continue;
						if (tmp[j] == ' ') continue;
						if (isdigit(tmp[j])) continue;
						tmp[j] = func(a, b, str[j] - 'a') + 'a';
				}
				
				if (tmp.find("that") != string::npos || tmp.find("this") != string::npos){
					cout << tmp << endl;
					goto a;
				}
			}
		}
		a:;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////


ll res(ll x, ll p){
    int cn =0;
    ll res=0;
    for(ll i=p;i<=x;i*=p){
        ll ko= x/i;
        res -= cn * ko;
        cn++;
        res+=cn*ko;
    }
    return res;
}
int main(){
    ll x;
    cin>>x;
    if(x%2==1)cout<<0<<endl;
    else 
    cout<<(min(res(x,2),res(x/2,5)))<<endl;

}

Measured memory_bytes: 256
n = gets.to_i
nums = gets.strip.split.map(&:to_i)
num = nums.sort.reverse #大きい順
i = 0
sum = 0
tum = 0
while i < n do
  if i%2==0
    sum += num[i]
  else
    tum += num[i]
  end
  i += 1
end
puts sum-tum

Measured memory_bytes: 14192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m,k;
int a[2][100010];
bool visit[100010];
int res=0;
int main()
{
	cin >>n>>m>>k;
	for (int i=0;i<n;i++) cin >>a[0][i];
	sort(a[0],a[0]+n);
	for (int i=0;i<n;i++) a[1][i]=a[0][i]+k;
	for (int i=0;i<n;i++)
	{
		if (visit[i]) continue;
		for (int j=i;j<n;j++)
		{
			if (j-i+1>m) break;
			if (a[0][j]>a[1][i]) break;
			visit[j]=1;
		}
		/*cout <<i<<" ##\n";
		for (int j=0;j<n;j++) cout <<visit[j]<<" ";
		cout <<"\n";*/
		res++;
	}
	cout <<res;
	return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    if((B-A+1) <= 2*K){
        for(int i=A;i <= B;i++) cout << i << endl;
        return 0;
    }
    else{
        REP(i,K) cout << A+i << endl;
        REP(i,K) cout << B-K+i+1 << endl;
    }
    return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int s;
    cin>>s;
    int a=sqrt(s);
    int d=a;
    while(a+1>hell-7) a--;
    while(d+1<=hell-7 and (d+1)*a<=s) d++;
    while(d>hell-7) d--;
    int b=(s-a*d);
    int c=-1;
    assert(a+1<=hell-7);
    assert(c+1<=hell-7);
    assert(b<=hell-7);
    assert(d<=hell-7);
    assert(abs(d*a-b*c)==s);
    cout<<1<<" "<<0<<" "<<a+1<<" "<<b<<" "<<c+1<<" "<<d<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int num, count = 0;
	while (1){
		scanf("%d", &num);
		if (num == 0) break;
		while (num != 1){
			if (num%2 == 0){
				num = num/2;
				count++;
			}else{
				num = num * 3 + 1;
				count++;
			}
		}
		printf("%d\n", count);
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

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

  if(S[0] == 'R'){
    if(S[1] == 'R'){
      if(S[2] == 'R'){
	cout << 3 << endl;
      }
      else
	cout << 2 << endl;
    }
    else
      cout << 1 << endl;
  }
  else
    if(S[1] == 'R'){
      if(S[2] == 'R')
	cout << 2 <<endl;
      else
	cout << 1 << endl;
    }
    else
      if(S[2] == 'R')
	cout << 1 <<endl;
      else
	cout << 0 <<endl;
	
  return 0;
}


Measured memory_bytes: 3624
class Point
  attr_reader :x, :y

  def initialize(x, y)
    @x=x
    @y=y
  end
end

# 1次関数(2点標準形)
def linear(p1, p2)
  lambda { |p| (p2.y-p1.y)*(p.x-p1.x)-(p2.x-p1.x)*(p.y-p1.y) }
end

# 分類判定(凸四角形)
def convex?(poly)

  a=linear(poly[0], poly[2]).call(poly[1])
  b=linear(poly[0], poly[2]).call(poly[3])
  c=linear(poly[1], poly[3]).call(poly[0])
  d=linear(poly[1], poly[3]).call(poly[2])

  return (a*b<0&&c*d<0)

end


while (line=gets)!=nil

  ps = line.split(/,/).map(&:to_f)
  p1=Point.new(ps[0], ps[1])
  p2=Point.new(ps[2], ps[3])
  p3=Point.new(ps[4], ps[5])
  p4=Point.new(ps[6], ps[7])

  if convex?([p1, p2, p3, p4])
    puts :YES
  else
    puts :NO
  end

end

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

int main(void) {
    int i, j, m, n, cnt=0;
    cin >> n;
    int A[n];

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

    for (i = 0; i < n; i++) {
        m = i;
        for (j = i + 1; j < n; j++) {
            if (A[j] < A[m]) {
                m = j;
            }
        }
        if (i != m) {
        swap(A[i], A[m]);
        cnt++;
        }
    }

    for (i = 0; i < n; i++) {
        cout << A[i];
        if (i == n - 1) cout << endl;
        else cout << ' ';
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int n,ans=0;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0;i<n;i++) cin >> v[i];
  for(int i=0;i<n;i++) cin >> c[i];
  for(int i=0;i<n;i++) {
    ans+=max(0,v[i]-c[i]);
  };
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		int person, hotWaterTime;
		string[] vals = Console.ReadLine().Split(' ');
		person = int.Parse(vals[0]);
		hotWaterTime = int.Parse(vals[1]);

		int sumTime = 0;
		
		string[] strElaspedTimes = Console.ReadLine().Split(' ');
		int[] elaspedTimes = new int[strElaspedTimes.Length];
		for(int i = 0 ; i < strElaspedTimes.Length ; i++){
			elaspedTimes[i] = int.Parse(strElaspedTimes[i]);
		}
		
		sumTime += hotWaterTime;
		
		for(int idx = 1; idx < elaspedTimes.Length; idx++){
			int diffTime = elaspedTimes[idx] - elaspedTimes[idx - 1];
			
			if(hotWaterTime > diffTime){
				sumTime += diffTime;
			}else{
				sumTime += hotWaterTime;
			}
		}
		
		Console.WriteLine(sumTime.ToString());
	}
}

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

struct Tree {
  int key;
  Tree *left, *right, *parent;
};

Tree* find(Tree* trees, int key) {
  if (trees == nullptr) return nullptr;
  if (trees->key == key) return trees;
  else if (key < trees->key) return find(trees->left, key);
  else return find(trees->right, key);
}

void del(Tree* trees, int key) {
  Tree* tree = find(trees, key);
  if (tree == nullptr) return;

  Tree* parent_tree = tree->parent;
  Tree* new_child_tree = nullptr;
  if (tree->right != nullptr && tree->left != nullptr) {
    new_child_tree = tree->right;
    while (new_child_tree->left != nullptr) {
      new_child_tree = new_child_tree->left;
    }
    tree->key = new_child_tree->key;
    tree = new_child_tree;
    parent_tree = tree->parent;
    new_child_tree = nullptr;
  }

  if (tree->left != nullptr && tree->right == nullptr) {
    new_child_tree = tree->left;
  } else if (tree->right != nullptr && tree->left == nullptr) {
    new_child_tree = tree->right;
  }

  if (parent_tree->left == tree) {
    parent_tree->left = new_child_tree;
  } else {
    parent_tree->right = new_child_tree;
  }
  if (new_child_tree != nullptr) {
    new_child_tree->parent = parent_tree;
  }
  delete tree;
}

void insert(Tree* trees, Tree* new_tree) {
  Tree *cur_tree = trees;
  Tree *pre_tree;
  bool is_left_selected;
  while (cur_tree != nullptr) {
    pre_tree = cur_tree;
      if (new_tree->key < cur_tree->key) {
        cur_tree = pre_tree->left;
        is_left_selected = true;
      } else {
        cur_tree = pre_tree->right;
        is_left_selected = false;
      }
  }
  new_tree->parent = pre_tree;
  if (is_left_selected) {
    pre_tree->left = new_tree;
  } else {
    pre_tree->right = new_tree;
  }
}

void inorder(Tree *tree) {
  if (tree->left != nullptr) {
    inorder(tree->left);
  }
  cout << " " << tree->key;
  if (tree->right != nullptr) {
    inorder(tree->right);
  }
}

void preorder(Tree *tree) {
  cout << " " << tree->key;
  if (tree->left != nullptr) {
    preorder(tree->left);
  }
  if (tree->right != nullptr) {
    preorder(tree->right);
  }
}

void print(Tree* trees) {
  inorder(trees);
  cout << endl;
  preorder(trees);
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  Tree* trees = nullptr;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s.find("insert") != string::npos) {
      Tree* new_tree = new Tree;
      cin >> new_tree->key;
      new_tree->parent = nullptr;
      new_tree->left = nullptr;
      new_tree->right = nullptr;
      if (trees == nullptr) {
        trees = new_tree;
      } else {
        insert(trees, new_tree);
      }
    } else if (s.find("find") != string::npos) {
      int key;
      cin >> key;
      if (find(trees, key) != nullptr) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else if (s.find("delete") != string::npos) {
      int key;
      cin >> key;
      del(trees, key);
    } else {
      print(trees);
    }
  }
  return 0;
}



Measured memory_bytes: 21916
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,k; cin>>n>>k;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    if(n==k){
        cout<<1<<endl;
        return 0;
    }
    int che;
    rep(i,n) if(p[i]==1) che=i;
    int ch=n-1-che;
    int ans=(ch+che+k-2)/(k-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>


struct Node 
{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) 
{
    Node *cur = nil->next;
    while ( cur != nil && cur->key != key ) {
        cur = cur->next;
    }
    return cur;
}

void init() 
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() 
{
    Node *cur = nil->next;
    int isf = 0;
    while ( 1 ) {
        if ( cur == nil ) break;
        if ( isf++ > 0 ) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
    
}


void deleteNode(Node *t) 
{
    if ( t == nil ) return; //t?????????????????????????????????
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() 
{
    deleteNode(nil->next);
}

void deleteLast() 
{
    deleteNode(nil->prev);
}

void deleteKey(int key)
{
    deleteNode(listSearch(key));
}

void insertKey(int key) 
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    //???????????´??????????´??????????
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
    
}


int main() 
{
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();

    for (i = 0; i < n; i++) {
        scanf("%s%d", com, &key);
        if(com[0] == 'i') {
            insertKey(key);
            np++;
            size++;
            
        } else if (com[0] == 'd') {
            if (com[6] == 'F') {
                deleteFirst();
            } else if(com[6] == 'L') {
                deleteLast();
            } else {
                deleteKey(key);
            }
            size--;
            
        }
    }

    printList();
    return 0;
}

Measured memory_bytes: 32216
s = input()
mae = s[0] + s[1]
usiro = s[2] + s[3]

monthexe = ["01","02","03","04","05","06","07","08","09","10","11","12"]

maeOK = mae in monthexe
usiroOK = usiro in monthexe

if maeOK:
  if usiroOK:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if usiroOK:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int ans = 0;

            for(int i = 0; i < N; i++)
            {
                if(i == 0)
                {
                    ans += B[i];
                }
                else if (i == N - 1)
                {
                    ans += B[i - 1];
                }
                else
                {
                    ans += Math.Min(B[i-1], B[i]);
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28260
#include<bits/stdc++.h>
//typedef long long ll;
//#define ull       unsigned long long
#define int       long long
#define F           first
#define S           second
#define endl        "\n"//<<flush
#define eps         1e-6
#define lowbit(x)   (x&(-x))
#define PI          acos(-1.0)
#define inf         0x3f3f3f3f
#define MAXN        0x7fffffff
#define INF         0x3f3f3f3f3f3f3f3f
#define pa          pair<int,int>
#define ferma(a,b)  pow(a,b-2)
#define pb          push_back
#define all(x)      x.begin(),x.end()
#define memset(a,b) memset(a,b,sizeof(a));
#define IOS         ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
void file()
{
#ifdef ONLINE_JUDGE
#else
    freopen("cin.txt","r",stdin);
    //  freopen("cout.txt","w",stdout);
#endif
}
signed main()
{
    IOS;
    //file();
    string str;
    cin>>str;
    deque<char>de;
    for(auto it:str)
        de.push_back(it);
    int flag=0;
    int q;
    cin>>q;
    while(q--)
    {
        int t,f;
        char c;
        cin>>t;
        if(t==1)
            flag++;
        else
        {
            cin>>f>>c;
            if(f==1)
            {
                if(flag%2==0)
                    de.push_front(c);
                else
                    de.push_back(c);
            }
            else
            {
                if(flag%2)
                    de.push_front(c);
                else
                    de.push_back(c);
            }
        }
    }
    string ans;
    while(!de.empty())
        ans+=de.front(),de.pop_front();
    if(flag%2)
        reverse(all(ans));
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 1368
n = int(input())
a = list(map(int,input().split()))

ans = [sum(a[0:2*n:2])-sum(a[1:2*n:2])]
ans2 = ''

for i in range(n-1):
    ans.append(2*a[i]-ans[i])

for i in range(n):
    ans2 += str(ans[i])
    if i != n-1:
        ans2 += ' '

print(ans2)


Measured memory_bytes: 14156
#include<bits/stdc++.h>
using namespace std;
#define M 100005
int a[M],ans[M];
int main(){
	int n,v;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);v=a[1];
	for(int i=2;i<=n;++i)v=a[i]-v;
	ans[1]=v;
	for(int i=1;i<n;++i)ans[i+1]=a[i]*2-ans[i];
	for(int i=1;i<=n;++i)printf("%d ",ans[i]);
}

Measured memory_bytes: 2048
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
maximum = max(l)
a = 10 ** 10
r = (maximum - 1) / 2

for x in l:
    if abs(x-r) <= a:
        a = abs(x-r)
        tmp = x
print(maximum,tmp)


Measured memory_bytes: 14428
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

const int MOD = 1000000007;

ll to[10][10];
ll cost[10];
vector <bool> visited(10 , false);

int dfs(int m, ll c, int s, vector<bool> visited)
{

    if(m == 1)
    {
        cost[s] = min(cost[s], c);
        return 0;
    }

    if(visited[m])return 0;
    visited[m] = true;
    REP(i,10)
    {
        if(i == m)continue;
        dfs(i, c + to[m][i], s, visited);
    }
}

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    //方針:各数値の -> 1までの最短経路探索
    ll h,w;
    cin >> h >> w;
    ll c;
    //iから1にいくまでのコスト
    REP(i,10)
    {
        REP(j,10)
        {
            cin >> c;
            to[i][j] = c;
        }
    }

    REP(i,10)
    {
        cost[i] = INF;
    }

    REP(i,10)
    {
        //時間がかかりすぎるのでテコ入れ
        //0->1の最短を最初に求めるので、 i 未満なら、最短を知っている(cost[i])
        dfs(i, 0, i, visited);
    }

#if DEBUG
    REP(i,10)
    {
        cout << cost[i] << endl;
    }
#endif

    ll res;

    REP(i,h)
    {
        REP(j,w)
        {
            ll a;
            cin >> a;
            res += cost[a];
        }
    }
    cout << res << endl;

    return 0;     
}



Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const x = parseInt(input[0]);

  console.log(x >= 30 ? "Yes" : "No");

}
// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29532
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
char s[MAXN];
int num[MAXN];
void Solve() {
    read(N);
    scanf("%s",s);
    for(int i = 0 ; i <= 1 ; ++i) {
        for(int j = 0 ; j <= 1 ; ++j) {
            num[0] = i;num[1] = j;
            for(int k = 2 ; k < N ; ++k) {
                num[k] = (s[k - 1] == 'x') ^ num[k - 2] ^ num[k - 1];
            }
            int t0 = num[N - 1] ^ num[1] ^ num[0] ^ (s[0] == 'x');
            int tN = num[0] ^ num[N - 2] ^ num[N - 1] ^ (s[N - 1] == 'x');
            if(t0 == 0 && tN == 0) {
                for(int i = 0 ; i < N ; ++i) {
                    if(num[i] == 0) putchar('S');
                    else putchar('W');
                }
                enter;
                return;
            }
        }
    }
    puts("-1");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	int m = n % 10;

	if (m == 3) cout << "bon" << endl;
	else if (m == 0 || m == 1 || m == 6 || m == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
}


Measured memory_bytes: 3636
import bisect

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

ans = 0

for e in b:
    i = bisect.bisect_left(a, e)
    j = bisect.bisect_right(c, e)
    if i > 0 and j != len(c):
            ans += i * (N - j)
            
print(ans)

Measured memory_bytes: 23360
n = int(input())
s = [input() for  _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
for i in s:
  if ans < s.count(i) - t.count(i):
    ans = s.count(i) - t.count(i)
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

struct TTransition {
  vector<int> perm;
  vector<ll> cost;

  TTransition(int d = -1) {
    perm.resize(10);
    cost.resize(10);
    for (int i = 0; i < 10; ++i) {
      if (d == -1) {
        perm[i] = i;
        cost[i] = 0;
        continue;
      }

      int x = i + d;
      int c = 1;
      if (x >= 10) {
        x = x / 10 + x % 10;
        c++;
      }
      perm[i] = x;
      cost[i] = c;
    }
  }


  TTransition operator *(const TTransition& tr) const {
    TTransition result;
    for (int d = 0; d < 10; ++d) {
      result.perm[d] = tr.perm[perm[d]];
      result.cost[d] = cost[d] + tr.cost[perm[d]];
    }
    return result;
  }
};

TTransition Pow(TTransition x, ll n) {
  TTransition result;
  while (n > 0) {
    if (n % 2 == 1) {
      result = result * x;
      n--;
    } else {
      x = x * x;
      n /= 2;
    }
  }
  return result;
}

pair<int, ll> Solve(int d0, int d, ll n) {
  TTransition tr(d);
  tr = Pow(tr, n);
  return make_pair(tr.perm[d0], tr.cost[d0]);
}

int main()
{
  int n;
  cin >> n;
  int curDigit = 0;
  ll curResult = 0;
  for (int i = 0; i < n; ++i) {
    int d;
    ll c;
    cin >> d >> c;
    pair<int, ll> p = Solve(curDigit, d, c);
    curDigit = p.first;
    curResult += p.second;
  }
  curResult--;
  cout << curResult << endl;

  return 0;
}


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

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

  int k;
  string s;

  cin >> k >> s;

  cout << s.substr(0, k) << (s.length() > k ? "...\n" : "\n");

  return (0);
}


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

using namespace std;

constexpr int INF = numeric_limits<int>::max() / 2;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s = "$" + s;
    vector<int> sum(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        sum[i] = sum[i - 1] + (s[i] == '#');
    }
    int ret = INF;
    for (int i = 0; i <= n; i++)
    {
        int tmp = i - sum[i];
        tmp += sum[n] - sum[i];
        ret = min(ret, tmp);
    }
    cout << ret << endl;
}


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

int main(){
  int n;
  cin>> n;
  vector<int>d(n);
  rep(i, n) cin>> d[i];
  int sum=0;
  rep(j, n) rep(i, j){
    sum +=d[i]*d[j];
  }
  cout<< sum<< endl;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

#ifdef LOCAL
#define i64 "%lld"
#else
#define i64 "%I64d"
#endif

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

vector<int> prefix_function (string s) {
	int n = (int) s.length();
	vector<int> pi (n);
	for (int i=1; i<n; ++i) {
		int j = pi[i-1];
		while (j > 0 && s[i] != s[j]) j = pi[j-1];
		if (s[i] == s[j])  ++j;
		pi[i] = j;
	}
	return pi;
}

bool good(vi &pi, int l) {
    int d = l - pi[l-1];
    return d == l || l%d != 0;
}

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

    string s; cin >> s;
    int n = si(s);
    auto pi = prefix_function(s);

    string t = s;
    reverse(all(t));
    auto pi2 = prefix_function(t);

    int d = si(s) - pi.back();
    if (d == n || n%d != 0) cout << "1\n1\n";
    else if (d == 1) cout << n << endl << 1 << endl;
    else {
        cout << 2 << endl;
        int ways = 0;
        forsn(x,1,n) {
            int y = n-x;
            ways += good(pi,x) && good(pi2,y);
        }
        cout << ways << endl;
    }

    return 0;
}


Measured memory_bytes: 5684
#include<stdio.h>
int r[100],u[100],b[100],c[100],y[100],k,l,n,f,z;
void quicksort(int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=b[a[(s+t)/2]];
    while(1){
      while(b[a[i]]<p)i++;
      while(p<b[a[j]])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int main(){
  f=0;
  scanf("%d",&n);
  for(k=0;k<n;k++){y[k]=k;scanf("%d%d",&r[k],&u[k]);}
  for(k=0;k<n;k++)scanf("%d%d",&b[k],&c[k]);
  quicksort(y,0,n-1);
  for(k=0;k<n;k++){z=-1;for(l=0;l<n;l++)if(r[l]<b[y[k]]&&u[l]<c[y[k]]&&(z==-1||u[z]<u[l]))z=l;if(z!=-1){u[z]=1000;f++;}}
  printf("%d",f);
}


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

int main() {
    string s, t;
    cin >> s >> t;
    string ans = "Yes";
    for (int i = 0; i < s.size(); ++i) {
        if (s.at(i) != t.at(i)) {
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String T = sc.next();
      int N = S.length();
      int R = 0;
      for(int i = 0;i<N;i++){
        String a = S.substring(i,i+1);
        String b = T.substring(i,i+1);
        if(a.equals(b)){
          R += 1;
        }else{
          continue;
        }
      }
      System.out.println(R);
    }
}

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

#define int long long
#define pb emplace_back
#define f(i,n) for(int i=0 ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;
	int n;
	cin >> n;
	
	int a[n];
	f(i,n)  cin >> a[i];
	sort(a,a+n);
	int x1 = a[n/2-1];
	int x2 = a[n/2];
	cout << x2 - x1 ;
}







Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    c=0;
    cin>>a>>b;
    if(a==1 and b==1){
        cout<<1000000;
        return 0;

    }
    if(a==1){
        c+=300000;
    }
    if(b==1){
        c+=300000;
    }
    if(a==2){
        c+=200000;
    }
    if(b==2){
        c+=200000;
    }
    if(a==3){
        c+=100000;
    }
    if(b==3){
        c+=100000;
    }
    cout<<c;
    return 0;
}


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

int main() {
    string s;
    while(cin >> s, s[0] != '#') {
        int y, m, d; cin >> y >> m >> d;
        if(y <= 30 || (y == 31 && m < 5)) {
            cout << "HEISEI" << " " << y << ' ' << m << ' ' << d << endl;
        } else {
            cout << "? " << y - 30 << ' ' << m << ' ' << d << endl;
        }
    }
}



Measured memory_bytes: 3220
module.exports=function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){n(1)(n(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r){e.exports=function(e){for(var r=Number(e[0]),n=e[1].split(" ").map(function(e){return Number(e)}),t=new Array(r+1).fill(0),o=r;o>=1;o--){for(var u=o,i=0;u<=r;)i+=t[u],u+=o;i%2!=n[o-1]&&(t[o]=1)}for(var f=0,l=[],c=1;c<=r;c++)1==t[c]&&(f++,l.push(c));console.log(f),l.length>0&&console.log(l.join(" "))}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 24712
N, K = map(int, input().split())

p = list(map(int, input().split()))
c = list(map(int, input().split()))

for i in range(len(p)):
    p[i] -= 1

ans = float("-inf")

for i in range(N):
    #iはスタートポジション
    pos = i
    #移動先のマスにかかれたポイント
    point = []
    total = 0
    while True:
        pos = p[pos]
        point.append(c[pos])
        # totalは周期の和がマイナスかプラスかで後々場合分けするために使う。(周期が負だったら一巡目で終わらせたい。周期が正だったらできる限り後の方で終わらせたい)
        total += c[pos]
        #スタートポジションに戻ってきた==サイクルを検知した
        if pos == i: break
    l = len(point)

    t = 0
    #total<0のときはif total>0以外の処理でまきとれる
    for i in range(l):
        t += point[i]
        #Kがi+1より小さい時のハンドリング
        if i+1 > K: break
        now = t
        if total > 0:
            #K-i-1の-1はポイントの一個目を獲得する時に1個動くので-1。二こ目のポイントを取る時はi=1で、K-2になり計算が合う。それをlでわり周期が何個回れるかを計算する
            #nowはtotalのセットが何個かあって、その先にpoint[i]がくっつくイメージ。[a,b,c] + [a,b,c] + [a,b,c] + ([a] or [a+b] + [a+b+c]) 
            #最初now += total * (K-i-1)//lとしていてWAしていたので書き方注意。これだとtotalと(K-i-1)をかけたものをlでわる、となってしまう。
            cnt = (K-i-1) // l
            now += total * cnt 
        ans = max(ans, now)
print(ans)

Measured memory_bytes: 81084
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/math/common_factor_rt.hpp>
class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    std::uint64_t a, b;
    in >> a, b;
    out << boost::math::lcm(a, b);

    return 0;
}


Measured memory_bytes: 256