akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
const ll inf = 1e18 + 1;
const int mod = 1e9 + 7;
const int maxn = 5e6;
ll modpow(ll a,ll b,int mod = inf) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) {return __gcd(a,b);}
int n;long double h[3333], t[3333], dp[3333][3333];
signed main(){
	FLASH
	memset(dp, 0, sizeof(dp));
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> h[i], t[i] = 1 - h[i];
	dp[1][1] = h[1];
	dp[0][1] = t[1];
	for (int i = 2; i <= n; i++)
		dp[0][i] = t[i] * dp[0][i - 1];
	for (int j = 2; j <= n; j++)
		for (int i = 1; i <= j; i++)
			dp[i][j] = dp[i][j - 1] * t[j] + dp[i - 1][j - 1] * h[j];
	long double p = 0;
	for(int i = 1 + n/2; i <= n; i++)
		p += dp[i][n];
	cout << setprecision(10) << p << nl;

	return 0;
}


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

bool Iseven(int x){
  if(x%2==0)return true;
  else return false;
}

int main(){
  int Num[3];

  for(int i=0;i<3;i++){
    cin>>Num[i];
  }
  int EvenCnt=0;
  bool EvenInd[3]={false};

  int OpeCnt=0;

  for(int i=0;i<3;i++){
    if(Iseven(Num[i])==true){
      EvenCnt++;
      EvenInd[i]=true;
    }
  }


  if(EvenCnt==1){
    for(int i=0;i<3;i++){
      if(EvenInd[i]==false){
        Num[i]++;
      }
    }
    OpeCnt++;
  }else if(EvenCnt==2){
    for(int i=0;i<3;i++){
      if(EvenInd[i]==true){
        Num[i]++;
      }
    }
    OpeCnt++;
  }

  int Max=-1;
  for(int i=0;i<3;i++){
    if(Max<=Num[i]){
      Max=Num[i];
    }
  }
  int Sub=0;
  for(int i=0;i<3;i++){
    Sub+=Max-Num[i];
  }

  OpeCnt+=Sub/2;

  cout<<OpeCnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

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: 256
#include <iostream>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int c[200000];
void add(int a,int b){
    c[a]+=b;
    a=a/2;
    while(a!=0){
        c[a]=c[2*a]+c[2*a+1];
        a=a/2;
    }
    
}
int getSum(int d,int e){
    if(d==e){
        return c[d];
    }
    else if(d%2==1){
        return c[d]+getSum(d+1,e);
    }
    else if(e%2==0){
        return getSum(d,e-1)+c[e];
    }
    else{
        return getSum(d/2,e/2);
    }
}
int main(){
    int n,q,com,x,y;
    cin>>n>>q;
    f(i,0,n*2){
        c[i]=0;
    }
    f(i,0,q){
        cin>>com>>x>>y;
        if(com==0){
            add(x+n,y);
        }
        else{
            cout<<getSum(x+n,y+n)<<endl;
        }
    }
    return 0;
}





Measured memory_bytes: 3860
S = input()
dp = []
cnt = 1
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        dp.append(cnt)
        cnt = 1
dp.append(cnt)
ans = 0
if S[0] == '<':
    for i in range(0, len(dp)-1, 2):
        N = max(dp[i], dp[i+1])
        n = min(dp[i], dp[i+1])
        ans += sum(range(N+1)) + sum(range(n))
    if len(dp)%2 == 1:
        ans += sum(range(dp[-1]+1))
else:
    ans += sum(range(dp[0]+1))
    for i in range(1, len(dp)-1, 2):
        N = max(dp[i], dp[i+1])
        n = min(dp[i], dp[i+1])
        ans += sum(range(N+1)) + sum(range(n))
    if len(dp)%2 == 0:
        ans += sum(range(dp[-1]+1))
print(ans)


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main() {
  int X;
  cin >> X;
  for (int i = X; true; i++) {
    if (IsPrime(i)) {
      cout << i << endl;
      break;
    }
  }
}


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

signed main(){
	int n; std::cin >> n;
	int AC = 0, WA = 0, TLE = 0, RE = 0;
	for(int i = 0; i < n; i++){
		std::string s; std::cin >> s;
		if(s == "AC") AC++;
		if(s == "WA") WA++;
		if(s == "TLE") TLE++;
		if(s == "RE") RE++;
	}
	std::cout << "AC x" << " " << AC << std::endl;
	std::cout << "WA x" << " " << WA << std::endl;
	std::cout << "TLE x" << " " << TLE << std::endl;
	std::cout << "RE x" << " " << RE << std::endl;
}

Measured memory_bytes: 3556
//A Still TBD
#include<bits/stdc++.h>
using namespace std;

int main()
{
  string s;
  int m,d;
  cin>>s;
  m=10*(s.at(5)-'0')+(s.at(6)-'0');
  d=10*(s.at(8)-'0')+(s.at(9)-'0');
  if(m<5)
    cout<<"Heisei"<<endl;
  else
    cout<<"TBD"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define N 305
int n,m,p,dp[N][N],su[N][N],c[N][N];
int main()
{
	scanf("%d%d%d",&n,&m,&p);n++;m++;
	for(int i=1;i<=m;i++)dp[1][i]=1,su[1][i]=i;
	for(int i=0;i<=n;i++)c[i][i]=c[i][0]=1;
	for(int i=2;i<=n;i++)for(int j=1;j<i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%p;
	for(int i=2;i<=n;i++)
	{
		for(int k=1;k<=m;k++)
		for(int j=1;j<i;j++)
		dp[i][k]=(dp[i][k]+1ll*dp[i-j][k]*su[j][k-1]%p*c[i-2][j-1])%p;
		for(int k=1;k<=m;k++)su[i][k]=(su[i][k-1]+dp[i][k])%p;
	}
	printf("%d\n",dp[n][m]);
}

Measured memory_bytes: 1280
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int[] a = new int[M];
		int[] b = new int[M];
		ArrayList<int[]> key = new ArrayList<int[]>();
		for (int i=0;i<M;i++) {
			a[i] = Integer.parseInt(sc.next());
			b[i] = Integer.parseInt(sc.next());
			int s = 0;
			for (int j=0;j<b[i];j++) {
				int c = Integer.parseInt(sc.next());
				c--;
				s |= 1<<c;
			}
			int[] array = {s, a[i]};
			key.add(array);
		}

		int[] dp = new int[1<<N];
		for (int i=0;i<1<<N;i++) {
			dp[i] = 2_000_000_000;
		}
		dp[0] = 0;
		for (int s=0;s<1<<N;s++) {
			for (int i=0;i<M;i++) {
				int t = s | key.get(i)[0];
				int cost = dp[s] + key.get(i)[1];
				dp[t] = Math.min(dp[t], cost);
			}
		}
		System.out.println(dp[(1<<N)-1]==2_000_000_000 ? -1 : dp[(1<<N)-1]);
	}
}

Measured memory_bytes: 28452
// https://atcoder.jp/contests/abc141/tasks/abc141_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize, k: i32, q: usize,
        a: [usize1; q]
    };

    let mut points = vec![k; n];
    for ai in a {
        points[ai] += 1;
    }

    for i in 0..n {
        if points[i] > q as i32 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 6780
n = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
count = 0

A.insert(0,-1)
A.append(10e+10)
C.insert(0,-1)
C.append(10e+10)

for bi in B:
    left = 0
    right = n+1
    
    while right-left>1:
        middle = (left+right) //2
        if A[middle]>=bi:
            right = middle
        else:
            left = middle
    a_count = left

    left = 0
    right = n+1
    while right-left>1:
        middle = (left+right) //2
        if C[middle]>bi:
            right = middle
        else:
            left = middle
    c_count = n+1-right

    count += a_count*c_count

print(count)

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

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int n, int[] a, int[] b) {
    long ans = 0;
    long x = 0;
    for (int i = 0; i < n; i++) {
        ans += min(a[i], b[i]);
        int d = b[i] - a[i];
        if (d > 0) {
            ans += min(a[i+1], d);
            a[i+1] = max(0, a[i+1] - d);
        }
    }
    return ans;
}

void main() {
    int n; scan(n);
    auto a = readints;
    auto b = readints;
    writeln(calc(n, a, b));
}


Measured memory_bytes: 9672
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*(n-k)
for i in range(k,n):
    ans[i-k]=(a[i]>a[i-k])
for i in range(0,n-k):
    print("Yes" if ans[i] else "No")

Measured memory_bytes: 94252
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int n;
char s[1<<19];
string t;
int dp[1<<19];
set<int> z;

int f(int k){
	if(dp[k]>=0)return dp[k];
	assert(k<SZ(t));
	int r=0;
	if(z.count(k))r=f(k+1);
	else {
		auto it=z.upper_bound(k);
		if(it==z.end())r=0;
		else {
			int j=*it;
			r=j-k+f(j+2);
			auto it2=z.upper_bound(j);
			if(it2==z.end())r=max(r,SZ(t)-1-j);
			else {
				int jj=*it2;
				r=max(r,jj-2-j+f(jj-1));
				r=max(r,jj-1-j+f(jj+1));
			}
		}
		r=max(r,f(k+1));
	}
	//printf("%d %d\n",k,r);
	return dp[k]=r;
}

int doit(){
	memset(dp,-1,4*(SZ(t)+5));dp[SZ(t)]=0;
	//puts(t.c_str());
	z.clear();
	fore(i,0,SZ(t))if(t[i]=='0')z.insert(i);
	int r=f(0);//printf("%d\n\n",r);
	return r;
}

int main(){
	scanf("%d%s",&n,s);n=strlen(s);
	int r=0,k=0;
	while(s[k]=='0')k++;
	while(k<n){
		if(s[k]=='0'&&(s[k+1]=='0'||k+1==n)){
			r+=doit();t.clear();
			while(s[k]=='0')k++;
		}
		else t.pb(s[k++]);
	}
	r+=doit();t.clear();
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 34564
# E - Multiplication 4
import heapq
N, K = map(int, input().split())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7

# N = K の時
if N == K:
    ans = 1
    for a in A:
        ans = (ans * a) % MOD

else:
    pos = []
    neg = []
    for a in A:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)

    # 必ずマイナスになる時＝全てがマイナスの値であり、
    # かつKが奇数の時
    if len(neg) == N and K&1 == 1:
        neg.sort(reverse=True)
        ans = 1
        for i in range(K):
            ans = (ans * neg[i]) % MOD

    # それ以外のプラスになるケース
    # プラスの要素とマイナスの要素を絶対値の大きい順にソートし、
    # Kが奇数であれば、プラスのリストから1つ選び、
    # 残りの偶数個のKに対して、２つずつを選んだ時の
    # 大きい方から取得していく
    else:
        pos.sort(reverse=True)
        pos2 = []
        ans = 1
        ini = 0
        rem = K
        if K&1 == 1:
            ans = (ans * pos[0]) % MOD
            ini = 1
            rem -= 1
        for i in range(0, (len(pos)-ini)//2):
            heapq.heappush(pos2, (pos[i*2+ini] * pos[i*2+ini+1])*-1)
        neg.sort()
        neg2 = []
        for i in range(0, len(neg)//2):
            heapq.heappush(neg2, (neg[i*2] * neg[i*2+1]) * -1)
        while rem > 0:
            if (pos2 != [] and neg2 == []) or (pos2 != [] and neg2 != [] and pos2[0] <= neg2[0]):
                tmp = heapq.heappop(pos2) * -1
            else:
                tmp = heapq.heappop(neg2) * -1
            ans = (ans * tmp) % MOD
            rem -= 2

print(ans)

Measured memory_bytes: 33196
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;
using i64 = int64_t;

void solve() {
	int x;
	cin >> x;
	if (x == 2) {
		cout << x << endl;
		return;
	}
	for (int i = x; ; ++i) {
		bool is_prime = true;
		for (int j = 2; j <= (i + 1) / 2; ++j) {
			if (i % j == 0) {
				is_prime = false;
				break;
			}
		}
		if (is_prime) {
			cout << i << endl;
			return;
		}
	}
}

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


Measured memory_bytes: 256
n = int(input())
x = input()

x_cnt = x.count('1')
yp = 0
ym = 0
for i in range(n):
    yp *= 2
    yp += int(x[i])
    yp %= x_cnt + 1

    if x_cnt != 1:
        ym *= 2
        ym += int(x[i])
        ym %= x_cnt - 1


def count(z):
    cnt = 0
    while z:
        z = z % bin(z).count('1')
        cnt += 1
    return cnt


# print(x, x_cnt, yp, ym)

ans = [0] * n
bp = bm = 1
for i in reversed(range(n)):
    if x[i] == '0':
        z = (yp + bp) % (x_cnt + 1)
        ans[i] = 1 + count(z)
    else:
        if x_cnt == 1:
            ans[i] = 0
        else:
            z = (ym - bm + x_cnt - 1) % (x_cnt - 1)
            ans[i] = 1 + count(z)
    # print(i, z, ans[i])
    bp *= 2
    bp %= x_cnt + 1
    if x_cnt != 1:
        bm *= 2
        bm %= x_cnt - 1

print(*ans, sep='\n')


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

int main(){
  int  n; cin >> n;
  int ans = 0, finalans = 0;
  int H, nextH; cin >> nextH;
  for(int i=1; i<n; i++){
    H = nextH;
    cin >> nextH;
    if(H >= nextH) ans++;
    else {
      finalans = max(ans, finalans);
      ans = 0;
    }
  }
  finalans = max(ans, finalans);

  cout << finalans << endl;
}

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

int n, num[100005], a[100005];
string ta;
int main()
{
    int i, j, k, t1, t2;
    cin >> n;
    cin >> ta;
    for (i = 0; i < n; i++) {
		if (ta[i] == 'o') a[i] = 0;
		else a[i] = 1;
    }
    a[n] = a[0];
    for (i = 0; i< 2; i++) {
        for (j= 0; j< 2; j++) {
            num[0] = i;
            num[1] = j;
            for (k = 1; k < n + 1; k++) {
				num[k+1]=((num[k - 1] ^ num[k]) ^ a[k]);
            }
            if (num[n] == num[0] && num[n+1] == num[1]) {
                for (k = 0; k < n; k++) {
                    if (num[k] == 0) printf("S");
                    else printf("W");
                }
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int n;
	int lowest = INF;
	int ans = -INF;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		int x;
		cin >> x;
		if (i>=1)
			ans = max(ans, x - lowest);

		lowest = min(lowest, x);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3088
using System;

namespace _0216
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = 4280;
            int y = 0;
            while (true)
            {
                int a = int.Parse(Console.ReadLine());
                if (a == -1) { break; }
                if (a <= 10) { y = 1150; }
                else if (a <= 20)
                {
                    y = 1150 + (a - 10) * 125;
                }
                else if (a <= 30)
                {
                    y = 1250 + 1150 + (a - 20) * 140;
                }
                else// if (a <= 40)
                {
                    y = 1400 + 1150 + 1250 + (a - 30) * 160;
                }


                Console.WriteLine(k-y);
            }
        }
    }
}

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

char x[2010][2010];
int n, m, q;

void in(){
	read(n, m, q);
	for(int i=1; i<=n; ++i) scanf("%s", x[i]+1);
}

int vt[2010][2010];

int el[2010][2010];
int em[2010][2010];

void bt(){
	for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j){
		if(x[i][j]=='1' && x[i+1][j] == '1'){
			em[i][j] += 1;
		}
		if(x[i][j]=='1' && x[i][j+1] == '1'){
			el[i][j] += 1;
		}
	}
	for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j){
		vt[i][j] = vt[i][j-1] + vt[i-1][j] - vt[i-1][j-1] + (x[i][j] == '1');
		em[i][j] += em[i-1][j] + em[i][j-1] - em[i-1][j-1];
		el[i][j] += el[i-1][j] + el[i][j-1] - el[i-1][j-1];
	}
}

int rect(int arr[][2010], int d, int u, int l, int r){
	auto f = [&](int i, int j){
		if(i<0 || j<0) return 0;
		return arr[i][j];
	};
	if(d>u || l>r) return 0;
	return f(u, r) - f(d-1, r) - f(u, l-1) + f(d-1, l-1);
}

int main()
{
	in();
	bt();
	for(;q--;){
		int d, u, l, r;
		read(d, l, u, r);
		int dv = rect(vt, d, u, l, r);
		int de = rect(em, d, u-1, l, r) + rect(el, d, u, l, r-1);
		printf("%d\n", dv - de);
	}
    return 0;
}


Measured memory_bytes: 53120
x1, y1, x2, y2 = gets.split.map(&:to_i)

x = (y1 - y2).abs
y = (x1 - x2).abs

if x1 <= x2
  x *= -1 if y1 <= y2
  x3, y3 = [x2 + x, y2 + y]
  x4, y4 = [x1 + x, y1 + y]
else
  if y1 >= y2
    y *= -1
  else
    x *= -1
    y *= -1
  end
  x3, y3 = [x2 + x, y2 + y]
  x4, y4 = [x1 + x, y1 + y]
end

puts [x3, y3, x4, y4].join(' ')

Measured memory_bytes: 1788
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
 
struct sword{
	int a;
	int b;
}kat[200005];
 
int cmp1(sword x,sword y){
	if (x.a>y.a) return 1;
	else if (x.a==y.a&&x.b>y.b) return 1;
	return 0;
}
 
int cmp2(sword x,sword y){
	if (x.b>y.b) return 1;
	else if (x.b==y.b&&x.a>y.a) return 1;
	return 0;
}
 
int main(){
	int n,h;
	cin>>n>>h;
	for (int i=1;i<=n;i++){
		cin>>kat[i].a>>kat[i].b;
	}
	
	int ans=0;
 
	sort(kat+1,kat+1+n,cmp1);
	sort(kat+2,kat+1+n,cmp2);
	if (kat[1].b>kat[1].a) {
		ans++;
		h-=kat[1].b;
	}
	for (int i=2;i<=n&&kat[i].b>=kat[1].a;i++){
		if (h<=0) break;
		h-=kat[i].b;
		ans++;
	}
	if (h>0){
		ans+=h/kat[1].a;
		h%=kat[1].a;
		if (h>0) ans++;
	}
	
	cout<<ans;
	
	
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            var ans = "";
            for (int i = 0; i < S.Length; i++)
            {
                var a = S[i] - 3;
                if (a == 62)
                {
                    Write("X");
                }
                else if (a == 63)
                {
                    Write("Y");
                }
                else if (a == 64)
                {
                    Write("Z");
                }
                else
                {

                    char c = (char)a;
                    Write(c);
                }
            }
            WriteLine();
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15852
N = int(input())
d_li = list(map(int, input().split(" ")))

d_li.sort()

hn = N//2 - 1
hp = N//2 

dis = d_li[hp] - d_li[hn]

if dis == 0:
    print(0)
elif dis > 0:
    print(dis )


Measured memory_bytes: 14396
using System;
using System.Collections;
using System.Collections.Generic;
namespace Collections
{
	class program
	{
		static void Main(string[] args)
		{
			// 入力
			string[] input = Console.ReadLine().Split(' '); // N, a
			long A = long.Parse(input[0]);
			long B = long.Parse(input[1]);
			long C = long.Parse(input[2]);
			long D = long.Parse(input[3]);

			long multC = B/C - (A-1)/C; //A->Bに含まれるCの倍数は
			long multD = B/D - (A-1)/D; //A->Bに含まれるDの倍数

			// C,Dの最小公倍数を求める
			long gcd = getGCD(C,D);
			long lcm = C*D/gcd;
			long multCD = B/lcm - (A-1)/lcm;

			long num = (B-A+1) - multC - multD + multCD;
			Console.WriteLine(num + "");
    }
		static long getGCD(long a, long b)
		{
			if(a%b == 0)
				return b;

			return getGCD(b, a%b);
		}
	}
}


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

void sw_str(char* str){
	char tmp = {0};
	int len = strlen(str), i, j;
	
	for(i=0, j=len-1; i<len/2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}	
}

int main(){
	char*	table[4] = { "maerd", "remaerd", "esare", "resare" };
	char	buff[8] = {0};
    char    s[100000+1] = {0};
	int		idx=0;
	int		flag;

    scanf("%s", s);
	sw_str(s);

	while( idx < strlen(s) ){
		flag = 0;

		for(int i=0; i<4; i++){
			memset( buff, 0x00, sizeof(buff) );
			strncpy( buff, &s[idx], strlen(table[i]) );
			if( strcmp(buff, table[i])==0 ){
				flag=1;
				idx += strlen(table[i]);
				break;
			}
		}
		if( flag == 0 ){ printf("NO\n"); return 0; }
	}
	printf("YES\n");

    return 0;
}

Measured memory_bytes: 1760
function splitMap(input: string) {
  return input.split(' ').map(s => parseInt(s, 10))
}

function main(input: string) {
  const lines = input.split('\n')
  const [_, ...shops] = lines.map(l => splitMap(l))
  const [count, want] = _
  //sort
  const s = shops.sort((a, b) => a[0] - b[0])
  
  let total = 0
  let got = 0
  for (let i = 0; i < count; i++) {
    const [price, limit] = s[i]
    
    if (got + limit > want) {
      // rest
      total += price * (want - got)
      break
    } else {
      // all
      got += limit
      total += price * limit
    }
  }
  
  console.log(total)
}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim())

Measured memory_bytes: 52964
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
    int key;
    struct Node *right;
    struct Node *left;
    struct Node *parent;
};
void insert(int);
int  find(struct Node *,int);
void inorder(struct Node *);
void preorder(struct Node *);

struct Node *root,*NIL;
int y_or_n[500000];
int t=0,g=0;

int main(){
    int n,i,j,x;
    char St[10];

    scanf("%d",&n);
    for(j=0;j<n;j++){
        scanf("%s%d",St,&x);//プリントしたいときはxに任意の数を入力
        if(strcmp(St,"print")==0){
            if(t==0) g=1;
            else{
                for(i=0;i<t;i++){
                if(y_or_n[i]==1) printf("yes\n");
                else printf("no\n");
            }
            }
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
            t=0;
        }
        else if(strcmp(St,"insert")==0) {
            insert(x);
        }
        else{
            find(root,x);
        }   
    }
    if(g==1){
         for(i=0;i<t;i++){
            if(y_or_n[i]==1) printf("yes\n");
            else printf("no\n");
            }
    }
    return 0;
}

void insert(int k){
    struct Node *x=root;
    struct Node *y=NIL;
    struct Node *z;

    z=(struct Node *)malloc(sizeof(struct Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }
    else{
        if(z->key < y->key){
            y->left=z;
        }
        else{
            y->right=z;
        }
    }
}
  int find(struct Node *u,int k){
    while(u!=NIL){
        if(k==u->key){
            y_or_n[t]=1;
            t++;
            return 0;
        }
        else if(k<=u->key){
            u=u->left;
        }
        else{
            u=u->right;
        }
    }
    t++;
    y_or_n[t]=2;
    return 0;
}

void inorder(struct Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(struct Node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}


Measured memory_bytes: 20876
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)


int main(){
  queue<char> que;
  string s;
  cin>>s;
  ll cc=0;

  for(int i=0;i<s.size();i++){
      que.push(s[i]-'0');
  }
  while(!(que.empty())){
      cc += que.front();
      que.pop();
  }

  if(cc%9==0){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }



}











Measured memory_bytes: 3832
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
int dp[30000][256] = {};
void solve() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		REP(i, n + 1) {
			REP(q, 256) {
				dp[i][q] = 1e18;
			}
		}
		vector<int> inputs;
		REP(i, m) {
			int a;
			cin >> a;
			inputs.push_back(a);
		}
		dp[0][128] = 0;
		REP(i, n) {
			int a;
			cin >> a;
			REP(q, 256) {
				REP(t, inputs.size()) {
					int next = q + inputs[t];
					next = min(next, 255LL);
					next = max(next, 0LL);
					dp[i + 1][next] = min(dp[i + 1][next], dp[i][q] + (long long)pow(next - a, 2));
				}
			}
		}
		int ans = 1e18;
		REP(i, 256) {
			ans = min(ans, dp[n][i]);
		}
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 43136
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long int
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

void solve(){
    double n,d;
    cin>>n>>d;
    vector<pair<double,double>> a(n);
    loop(i,0,n) cin>>a[i].ff>>a[i].ss;
    int cnt = 0;
    loop(i,0,n){
        double dist = ((a[i].ff)*a[i].ff+a[i].ss*a[i].ss);
        dist = sqrt(dist);
        if(dist<=d) cnt++;
    }
    cout<<cnt<<endl;

}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


Measured memory_bytes: 6476
x, n = gets.split(" ").map(&:to_i)
if n == 0
  puts x
  exit
end
m = 0
pa = gets.split(" ").map(&:to_i).sort
t = []
-1.upto(101){ |i|
  t[i+1] = i
}
for i in 0..n-1
  t.delete(pa[i])
end
m = 0
for i in 0..t.length
  if t[i] > x
    m = i
    break
  end
end
puts (x - t[m-1]).abs <= (t[m] - x).abs ? t[m-1] : t[m]

Measured memory_bytes: 14292
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

char toUpper(const char str)
{
  return str - ('a' - 'A');
}

string s1, s2, s3;
int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s1 >> s2 >> s3;

  cout << toUpper(s1[0]) << toUpper(s2[0]) << toUpper(s3[0]) << endl;

  return 0;
}


Measured memory_bytes: 256
L=input()
mod=10**9+7



N=[int(i) for i in L]
keta=len(N)
dp=[[0 for i in range(2)] for j in range(keta+1)]
dp[0][0] = 1
#dp[0][0][1] =0
#dp[0][1][0] =0
#dp[0][1][1] =0

for i in range(keta):
    for smaller in [0,1]:
        if 1:
            for x in range(2 if smaller else (N[i]+1)):
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))]+= dp[i][smaller]*(2 if x==1 else 1)
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))] %=mod
print((dp[keta][0]+ dp[keta][1])%mod)


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

int N, M;
int sum = 0;
//vector<int> A(100);

int main(){
    cin >> N >> M;
    
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum += A[i];
    }

    //cout << sum << endl;

    sort(A.begin(), A.end());
    //cout << A << endl;
    /*for(int i=0; i<N; i++){
        cout << A[i];
    }
    cout << endl;*/

    reverse(A.begin(), A.end());

    /*for(int i=0; i<N; i++){
        cout << A[i];
    }
    cout << endl;*/
    
    if(sum%(4*M) == 0){
        if(sum/(4*M) > A[M-1]) cout << "No" << endl;
        else cout << "Yes" << endl;
    }else{
        if(sum/(4*M)+1 > A[M-1]) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    
}

Measured memory_bytes: 256
//apigs property
//Happiness can be found, even in the darkest of times, if one only remembers to turn on the light
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define md (s + e) / 2
#define mid (l + r) / 2
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define C continue
#define R return
#define lx node * 2
#define rx node * 2 + 1
using namespace std;
typedef long long ll;
ll q, d, dp[100][100005], a[555555] , b[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll i , ll sum){
	if(i == n && sum == 0)R 1;
	else if(i >= n || sum < 0)R 0;
	ll &r = dp[i][sum];
	if(r != -1)R r;
	r = mem(i + 1 , sum) % mod + mem(i, sum - 1) % mod - mem(i + 1 , sum - a[i] - 1) % mod;
	r %= mod;
	if(r < 0)r += mod;
	R r;
}
void solve(){
	msdp(dp);
	cin >> n >> k;
	for(ll i = 0 ; i < n ; i++){
		cin >> a[i];
	}
	cout << mem(0 , k);
}
int main(){
    fast ;
	//cin >> q;
    q = 1;
    while(q--){
    	solve();
	}
}




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

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException err){
			err.printStackTrace();
		}
	}

	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> nums = new ArrayList<Integer>();
		List<int[]> sequence = new ArrayList<int[]>();
		String line;

		while((line = in.readLine()) != null){
			int size = Integer.parseInt(line);

			if(size == 0){
				break;
			}

			line = in.readLine();
			String[] dst = line.split(" ");
			int[] data = new int[dst.length];
			for(int i=0; i<data.length; i++){
				data[i] = Integer.parseInt(dst[i]);
			}

			int count = 0;
			while(true){
				int[] old = new int[data.length];
				for(int i=0; i<data.length; i++){
					old[i] = data[i];
				}
				Process(data);
				if(isSame(data, old)){
					break;
				}
				count++;
			}

			nums.add(count);
			sequence.add(data);
		}

		for(int i=0; i<nums.size(); i++){
			System.out.println(nums.get(i));
			int[] dst = sequence.get(i);
			for(int j=0; j<dst.length; j++){
				System.out.print(dst[j]);

				if(j == dst.length-1){
					System.out.println();
				}else{
					System.out.print(" ");
				}
			}
		}
	}

	public void Process(int[] data){
		int[] result = new int[data.length];

		for(int i=0; i<data.length; i++){
			int n = data[i];
			int count = 0;

			for(int j=0; j<data.length; j++){
				if(n == data[j]){
					count++;
				}
			}
			result[i] = count;
		}

		for(int i=0; i<data.length; i++){
			data[i] = result[i];
		}
	}

	public boolean isSame(int[] a, int[] b){
		for(int i=0; i<a.length; i++){
			if(a[i] != b[i]){
				return false;
			}
		}

		return true;
	}
}

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

char seather(char c, int n) {
  if (c == ' ') return ' ';
  if (c == '.') return '.';

  int nn = c + n;
  if (nn > 122) return char(nn - 122 + 97 - 1);
  return char(nn);
}

string decrypt(string str) {
  for (int i = 0; i < 26; i++) {
    string can = "";
    for (int j = 0; j < str.length(); j++) {
      can += seather(str[j], i);
    }
    if(can.find("the") != string::npos || can.find("this") != string::npos || can.find("that") != string::npos) {
      return can;
    }
  }

  return "could not decrypt" + str;
}

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

  string input;
  while(getline(cin, input)) {
    if (input == "") continue;
    cout << decrypt(input) << "\n";
  }

  return 0;
}



Measured memory_bytes: 3104
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b;cin>>a>>b;
  int d=b-a;
  int h=(d+1)*d/2;
  cout<<h-b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
        cin >> h[i];
    bool ans = true;
    for(int i = 0; i < n - 1; i++){
        if(h[i] == h[i + 1])
            continue;
        else if(h[i] < h[i + 1])
            h[i + 1]--;
        else ans = false;
    }
    if(ans)
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll i,ans=0;
    string a,b;
    cin>>a>>b;
    for(i=0;i<3;i++) ans+=(a[i]==b[i]);
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!



Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int s[n];
    int ans = -100000000;
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=0;i<n;i++){
      int a = s[i];
      if(a>ans) ans = a;
      for(int j=i+1;j<n;j++){
	a += s[j];
	if(a>ans) ans = a;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

li n;
li a[100100];
map<li, li> cnt;

inline li solve() {
    if (cnt[0] == 1) {
        repp(i, 1, n) {
            if (a[i] != i) {
                return 0;
            }
        }
        return 3;
    }
    if (cnt[0] > 3) {
        return 0;
    }

    li scaling = 6;

    repp(i, 1, n) {
        if (cnt[i] > cnt[i - 1]) {
            return 0;
        }
    }


    map<li, li> tcnt;
    li res = scaling;
    rin{
        tcnt[a[i]]++;
        if (a[i] == 0) {
            continue;
        }
        //p3(i, a[i], tcnt[a[i] - 1]);
        if (tcnt[a[i] - 1] == 0) {
            return 0;
        }
        res = (res*tcnt[a[i] - 1]) % MOD;
        tcnt[a[i] - 1]--;
    }
    return res;
}

int main() {
    cin >> n;
    rin{
        cin >> a[i];
        cnt[a[i]]++;
    }
    cout << solve() << endl;

    return 0;
}

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

int n;
int x[100010];
int r[100010];

double min_distance(double X){
    double miny = 1e9;
    for(int i=0; i<n; i++){
        double d = 1. * abs(x[i] - X);
        double y = sqrt(1. * r[i] * r[i] - d * d);
        miny = min(miny, y);
    }

    return miny;
}

double thrnary_search(int L, int R){
    double left = 1. * L;
    double right = 1. * R;

    for(int i=0; i<100; i++){
        if(min_distance((left * 2 + right) / 3) > min_distance((left + right * 2) / 3)){
            right = (left + right * 2) / 3;
        }
        else{
            left = (left * 2 + right) / 3;
        }
    }

    return (left + right) / 2;
}

int main(){
    cin>>n;
    for(int i=0; i<n; i++) cin>>x[i]>>r[i];

    int left = -1e9;
    int right = 1e9;
    for(int i=0; i<n; i++){
        left = max(left, x[i] - r[i]);
        right = min(right, x[i] + r[i]);
    }

    double ansx = thrnary_search(left, right);
    double ansy = min_distance(ansx);
    cout << fixed << setprecision(10) << ansy << endl;
}


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

typedef long long ll;

ll a, b;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b;
	if(a + b == 15)
		cout << '+';
	else if(a * b == 15)
		cout << '*';
	else
		cout << 'x';
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int d[n];
    rep(i,n){
        int x;
        cin >> x;
        d[i] = x;
    }
    int ans = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<=n-1;j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans <<endl;
    
    return 0;
    
}
















































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    vi cnt(26, 1e9);
    rep(i, n) {
        map<char, int> tmap;
        string s;
        cin >> s;
        rep(j, s.size()) {
            tmap[s[j]]++;
        }
        rep(j, 26) {
            cnt[j] = min(cnt[j], tmap[j+'a']);
        }
    }

    string res = "";
    rep(i, 26) {
        rep(j, cnt[i]) res += i+'a';
    }

    sort(ALL(res));

    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int xa = Math.abs(x-a);
		int xb = Math.abs(x-b);
		if (xa<xb) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}		
}

Measured memory_bytes: 23892