akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip> 
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(j, a, b) for (int j = a; j >= b; j--)
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e9 + 7;
void add(int& a, int b){
    a=(long long)a+b;
    if(a>=MOD)a-=MOD;
}
int abs_diff(int a, int b){
    return abs(a-b);
}
void get_max(int& a, int b){
    a = max(a, b);
}
void get_min(int& a, int b){
    a = min(a, b);
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector <int> v(n+2), dp(n+2, MAX);
    rep(i,0,n)cin>> v[i];
    dp[0]= 0;
    rep(i,1,n){
        rep(j,1,3){
            if(i-j<0)break;
            get_min(dp[i], dp[i-j]+ abs_diff(v[i],v[i-j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define swap(a, b) {int tmp;tmp = a;a=b;b=tmp;}

int main(){
	int a,b,c;
	scanf("%d %d %d",&a, &b, &c);
	if(b > c)swap(b,c);
	if(a > b)swap(a,b);
	if(b > c)swap(b,c);
	printf("%d %d %d\n",a, b, c);
	return 0;
}

Measured memory_bytes: 596
n = int(input())
t_p = 0
h_p = 0
for i in range(n):
    taro, hana = [i for i in input().split()]
    if taro > hana:
        t_p += 3
    elif taro == hana:
        t_p += 1
        h_p += 1
    else:
        h_p += 3
print(f'{t_p} {h_p}')


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    bool flag = false;
    REP(i, N)
    {
        ll minSum = -D * i + C * (N - 1 - i);
        ll maxSum = -C * i + D * (N - 1 - i);
        if (minSum <= B - A && maxSum >= B - A)
        {
            flag = true;
            break;
        }
    }
    string ans = flag ? "YES" : "NO";

    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int a=0,b=0;
  string s=" ";
  cin>>a>>b;
  cin>>s;
  for(int i=0; i<a+b+1; i++)
  {
    if(i==a)
    {
      if(s[a]!='-')
      {
        cout<<"No"<<endl;
        return 0;
      }
    }
    else
    {
      if(s[i]<'0' || s[i]>'9')
      {
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      r: usize,
    }
    if r >= 2800 {
        println!("{}", "AGC");
    } else if r >= 1200 {
        println!("{}", "ARC");
    } else {
        println!("{}", "ABC");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll  long long int
long long int power(long long int a,long long int b )
{
    long long int res=1;
    a=a%mod;
    while(b>0)
    {
        if(b&1)
        res=(res*a)%mod;
        b=b>>1;
        a=(a*a)%mod;
    }
    return res;
}
int main()
{
   ll k,n;
   cin>>k>>n;
   ll a[n];
   for(ll i=0;i<n;i++)
    cin>>a[i];
   ll ans=10000000;

   for(ll i=1;i<n;i++)
   {
       ans=min(ans,k-a[i]+a[i-1]);
   }
   ans=min(ans,a[n-1]-a[0]);
   cout<<ans;
}


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

using namespace std;

const int MAX = 100010;

vector<int> tree(MAX, 0);

int getSum(int i)
{
	int SUM = 0;
	
	for(; i > 0; i -= i&-i)
		SUM += tree[i];
	
	return SUM;
}

void add(int i, int x, int n)
{
	for(; i <= n; i += i&-i)
		tree[i] += x;
}

int main() 
{
    int n, q, x, y, z;
    scanf("%d %d", &n, &q);
    
    for(int i = 0; i < q; i++)
    {
        scanf("%d %d %d", &x, &y, &z);
        
        if(x == 0)
            add(y, z, n);
        else if(x == 1)
            printf("%d\n", getSum(z) - getSum(y-1));
    }
    
    return 0;
}


Measured memory_bytes: 3420
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

#define UF uftree
#define MAX_UF 101000

int n, k;

class uftree 
{
    public:
        int size;
        vector<int> par, rank;
        uftree(int n) : size(n), par(n), rank(n) {
            for (int i = 0; i < size; i++) {
                par[i] =  i;
                rank[i] = 0;
            }
        }
        int find(int x) {
            if (par[x] == x) {
                return x;
            } else {
                return par[x] = find(par[x]);
            }
        }
        void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) {
                return ;
            }

            if (rank[x] < rank[y]) {
                par[x] = y;
            } else {
                par[y] = x;
                if (rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
        }
        bool same(int x, int y) {
            return find(x) == find(y);
        }
};

int main()
{
    cin >> n >> k;
    n++;
    vector<vector<bool> > rub(n, vector<bool>(n, false));
    vector<bool> use(n, false);
    UF tree(n);
    int ans = 0;

    for (int i = 0; i < k; i++) {
        int m;
        cin >> m;
        int tmp;
        cin >> tmp;
        for (int j = 1; j < m; j++) {
            int t;
            cin >> t;
            tree.unite(tmp, t);
        }
    }

    int r;
    cin >> r;

    for (int i = 0; i < r; i++) {
        int a, b;
        cin >> a >> b;
        if (tree.same(a, b)) {
            if (!use[a]) {
                ans++;
                use[a] = true;
            }
            if (!use[b]) {
                ans++;
                use[b] = true;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int S = stdIn.nextInt();
		int a[] = new int[4];
		for(int i = 3; i >= 0; i--) {
			a[i] = S%10;
			S = S/10;
		}
		
		if(a[0] == 0 && a[1] >=1) {
			if(a[2] == 0 && a[3] >= 1) {
				System.out.println("AMBIGUOUS");
			}
			else if(a[2] == 1) {
				if(a[3] <= 2) {
					System.out.println("AMBIGUOUS");
				}
				else {
					System.out.println("MMYY");
				}
			}
			else {
				System.out.println("MMYY");
			}
		}
		else if (a[0] == 1) {
			if(a[1] <= 2) {
				if(a[2] == 0 && a[3] >= 1) {
					System.out.println("AMBIGUOUS");
				}
				else if(a[2] == 1) {
					if(a[3] <= 2) {
						System.out.println("AMBIGUOUS");
					}
					else {
						System.out.println("MMYY");
					}
				}
				else {
					System.out.println("MMYY");
				}
			}
			else {
				if(a[2] == 0 && a[3] >= 1) {
					System.out.println("YYMM");
				}
				else if (a[2] == 1) {
					if(a[3] <= 2) {
						System.out.println("YYMM");
					}
					else {
						System.out.println("NA");
					}
				}
				else {
					System.out.println("NA");
				}
			}
		}
		else {
			if(a[2] == 0 && a[3] >= 1) {
				System.out.println("YYMM");
			}
			else if(a[2] == 1) {
				if(a[3] <= 2) {
					System.out.println("YYMM");
				}
				else {
					System.out.println("NA");
				}
			}
			else {
				System.out.println("NA");
			}
		}

	}

}

Measured memory_bytes: 21844
n,k=map(int,input().split())
s=list(input())
if s[k-1]=='A':
    s[k-1]='a'
elif s[k-1]=='B':
    s[k-1]='b'
else:
    s[k-1]='c'
ans=''
for i in range(n):
    ans+=s[i]
print(ans)

Measured memory_bytes: 3060
N = int(input())
S = input()
A = S.split(' ')

count = 0
for i in A:
  i = int(i)
  if i%2==0:
    if not (i%3==0 or i%5==0):
      count += 1
if count ==0:
  print('APPROVED')
else:
  print('DENIED')

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

int main(){
    vector<vector<int>> a(3, vector<int>(3));
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
    }
    int N; cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }
    vector<vector<int>> ans(3, vector<int>(3));
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if(a[i][j] == b[k]) ans[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < 3; i++)
    {
        if(ans[i][0] == 1 && ans[i][1] == 1 && ans[i][2] == 1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 3; i++)
    {
        if (ans[0][i] == 1 && ans[1][i] == 1 && ans[2][i] == 1)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (ans[0][0] == 1 && ans[1][1] == 1 && ans[2][2] == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (ans[0][2] == 1 && ans[1][1] == 1 && ans[2][0] == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
  while y!=0:
    x, y = y, x%y
  return x
def lcd(x, y):
    return x*y//gcd(x,y)
def C():
    a,b,c,d = list(map(int, input().split()))
    c_divide = b//c - (a-1)//c
    d_divide = b//d - (a-1)//d
    cd_lcd = lcd(c,d)
    lcd_divide = b//cd_lcd - (a-1)//cd_lcd
    print(b-a+1 - c_divide - d_divide + lcd_divide)
C()


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			total = 500*i + 100*j + 50*k
			if total == x:
				count += 1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;



int main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	double ans = (double)W * H;
	ans = ans / 2;
	cout << fixed;
	cout << setprecision(6) << ans << " ";
	if (W % 2 == 0 && H % 2 == 0) {
		if (x == W / 2 && y == H / 2) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int X;
    cin >> X;
    if (X == 7 || X == 5 || X == 3) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

//挿入ソート
void insertionSort(int A[], const int N)
{
    int i, j;

    for( i = 0; i < N; ++i ){
        int tmp = A[i];
        for( j = i-1; -1 < j && tmp < A[j]; --j ){
            A[j+1] = A[j];
        }
        A[j+1] = tmp;

        //出力
        for( j = 0; j < N; ++j ){
            printf("%d", A[j]);
            if( j != N-1 ) printf(" ");
        }
        printf("\n");
    }
}

int main()
{
    int i;

    //入力
    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define re return
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi; 
int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i = 0;i<n;i++)cin >> s[i];
	for(int i = 0;i<n;i++)
	{
		reverse(s[i].begin(),s[i].end());
	}
	sort(s.begin(),s.end());
	ll ans = 0;
	//for(auto i = s.begin();i!=s.end();i++)cout<<(*i)<<endl;cout<<endl;

	for(int i = 0;i<n;i++)
	{
		//if(s[i].size()==1)continue;
		ll now = 0;
		auto left = lower_bound(s.begin(),s.end(),s[i].substr(0,s[i].size()-1));

		//cout<<*left<<endl;

		for(auto j = left;j!=s.end();j++)
		{
			if(s[i]==(*j))continue;
			if(s[i].substr(0,s[i].size()-1)!=(*j).substr(0,s[i].size()-1))break;

			char x = s[i].back();
			for(int k = s[i].size()-1;k<(*j).size();k++)
			{
				if((*j)[k]==x)
				{
					ans++;
					break;
				}
			}
		}
		
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9464
n,a,b,c,d=gets.split
n=n.to_i
a=a.to_i
b=b.to_i
c=c.to_i
d=d.to_i

i=0
n.times{
   max=a+d*i-c*(n-i-1)
   min=a+c*i-d*(n-i-1)
   
   
   
   if b>=min && b<=max
      puts "YES"
      exit
  end
  
  
   i+=1 
}

puts "NO"

Measured memory_bytes: 1788
#include<iostream>

using namespace std;

typedef unsigned long long ull;
#define B1 100000007
#define B2 1000000007

bool rolling_hash(string const& S, int t_start, int m){
  int s_start = t_start + m;

  // B^mを用意する
  ull pow_B_m_1 = 1, pow_B_m_2 = 1;
  for(int k = 0; k < m; k++){
    pow_B_m_1 *= B1, pow_B_m_2 *= B2;
  }

  // sとtの先頭m文字のハッシュ値sh,thを計算
  ull sh1 = 0, sh2 = 0, th1 = 0, th2 = 0;
  for(int k = 0; k < m; k++){
    th1 = th1 * B1 + S[t_start + k], th2 = th2 * B2 + S[t_start + k];
    sh1 = sh1 * B1 + S[s_start + k], sh2 = sh2 * B2 + S[s_start + k];
  }

  // sをずらしてハッシュ値を更新
  for(int k = 0; s_start + k < S.length(); k++){
    if(sh1 == th1 && sh2 == th2) return true;
    if(k + s_start < S.length()){
      sh1 = sh1 * B1 + S[s_start + m + k] - S[s_start + k] * pow_B_m_1;
      sh2 = sh2 * B2 + S[s_start + m + k] - S[s_start + k] * pow_B_m_2;
    }
  }
  return false;
}

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

  // 一致する最大文字数を２分探索
  int ng = n+1, ok = 0, mid;
  while(ng - ok > 1){
    mid = (ng + ok) / 2;
    bool mached = false;
    // Sのi文字目をtの先頭として,t = S[i:i+mid], s = S[i+mid:]
    for(int i = 0; i < n; i++){
      if(i + mid*2 > n) break;
      if(rolling_hash(S, i, mid)){
        mached = true;
        break;
      }
    }
    if(mached) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n, m, i;
  int s, c;
  int x[4] = {-1,-1,-1,-1};

  cin >> n >> m;

  for(i=0;i<m;i++){
    cin >> s >> c;
    if(x[s]==-1){
      x[s] = c;
    }
    else if(x[s]!=c){
      cout << -1 << endl;
      return 0;
    }
  }

  if(x[1]==0){
    if(n==1)cout << 0 << endl;
    else cout << -1 << endl;
    return 0;
  }
  else if(x[1]!=-1){
    cout << x[1];
  }
  else{
    if(n==1){
      cout << 0 << endl;
      return 0;
    }
    cout << 1;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll inf = 1e18+5;
ll h;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> h;
	if (h < 2){
		if (h == 1)cout << 1;
		else cout << 0;
		return 0;
	}
	ll cur = 2;
	ll power = 1;
	while (cur < h){
		cur *= 2;
		power++;
	}
	if (cur != h){
		cur /= 2;
		power--;
	}
	ll levels = power+1;
	ll ans = 0;
	ll starting = 1;
	for (ll i = 0; i< levels; i++){
		ans += starting;
		starting *= 2;
	}
	//~ cout << cur << ' ' << power;
	cout << ans;
}


Measured memory_bytes: 256
(function() {
    'use strict';

    var fs = require('fs');
    var contents = fs.readFileSync('/dev/stdin', 'utf-8');

    var search = function(contents) {
        var S = [];
        var n = 0;
        var q = 0;
        var C = 0;
        var t = 0;

        var lines = contents.trim().split("\n");
        n = parseInt(lines[0]);
        S.length = n;
        var a = lines[1].split(" ");
        for (var i = 0; i < a.length; i++) {
            S[i] = parseInt(a[i]);
        }

        q = parseInt(lines[2]);
        var T = lines[3].split(" ");
        for (var i = 0; i < q; i++) {
            t = parseInt(T[i]);
            for (var j = 0; j < n; j++) {
                if (t == S[j]) {
                    C++;
                    break;
                }
            }
        }
        console.log(C);
    }
    search(contents);
})();

Measured memory_bytes: 17428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
    int num, gate,l,r;
    cin >> num >> gate;
    int boxa[100001]={};
    int boxb[100001]={};
    for(int i=0;i<gate;i++){
        cin >> l >> r;
        boxa[l]++;
        boxb[r]--;
    }

    int judge = 0;
    int ans = 0;
    for(int i=1;i<=num;i++){
        judge += boxa[i];
        if(judge >= gate){
            ans ++;
        }
        judge += boxb[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const int maxn=1E5+5; 
ll n,sum,pre[maxn];
struct pt
{
	ll x,y;
	bool operator<(const pt&A)const
	{
		return max(x,y)<max(A.x,A.y);
	}
}a[maxn];
inline int get(int pos)
{/*
	int l=1,r=n,p=0,d=max(a[pos].x,a[pos].y);
	while(l<=r)
	{
		int mid=l+r>>1;
		long long uf=pre[mid];if(mid>=pos)uf-=d;
		if(uf<=sum)p=mid,l=mid+1;
		else r=mid-1;
	}return p;
	*/
	int l=0,r=n,mid;
	int d=max(a[pos].x,a[pos].y);
	while(l<r)
	{
		mid=(l+r+1)>>1;
		ll s=pre[mid];
		if(mid>=pos)
			s-=d;
		if(s<=sum)
			l=mid;
		else
			r=mid-1;
	}
	return l;
}
ll gcd(ll x,ll y)
{
	if(y==0)
		return x;
	return x%y==0?y:gcd(y,x%y);
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i].x>>a[i].y;
		sum+=max((ll)0,a[i].y-a[i].x);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
		pre[i]=pre[i-1]+max(a[i].x,a[i].y);
	ll ax=0,ay=1;
	for(int i=1;i<=n;++i)
	{
		int pos=get(i);
		ll s=sum-pre[pos];
		if(pos>=i)
			--pos,s+=max(a[i].x,a[i].y);
		if(a[i].y>a[i].x)
			s-=a[i].y-a[i].x;//!!!!!!!!!!!!! 
		ll x=(ll)pos*a[i].y+min(s+a[i].y-a[i].x,a[i].y);
		ll y=n*a[i].y;
		if(x<=0)
			continue;
		ll z=gcd(x,y);
		x/=z,y/=z;
		if((ld)ay*x>(ld)y*ax)
			ax=x,ay=y;
	}
	cout<<ax<<" "<<ay<<endl;
	return 0;
}


Measured memory_bytes: 5988
#include<iostream>
using namespace std;
int main(){
	int n,a,b,x,y;
	while(cin>>n,n){
		a=0;b=0;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			if(x>y)
			a=a+x+y;
			else if(y>x)
			b=b+x+y;
			else if(x==y){
			a+=x;b+=y;
			}
		}
		cout<<a<<' '<<b<<endl;
		
	}
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int m;
    cin >> m;
    cout << 48 - m;
}

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

string s, t = "100100100100110101101001001011001010011000011011111001110101100001011001001111000010011000100110011100000101111110011100010101100111001000000100011100010000100011010011111001010101010110010010000110000100010101000001011101000111100010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

int dp[100010][360], n, ans[100010];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s; n = s.length();
    for(int i = 0; i < n; i++) dp[i][0] = i + (s[i] == 'R' ? 1 : -1);
    for(int j = 1; j < 350; j++) {
        for(int i = 0; i < n; i++) dp[i][j] = dp[dp[i][j-1]][j-1];
    }
    for(int i = 0; i < n; i++) {
        int pos = i;
        for(int j = t.length()-1; j >= 0; j--) {
            if(t[j] == '1') pos = dp[pos][t.length() - 1 - j];
        }
        ans[pos]++;
    }
    for(int i = 0; i < n; i++) printf("%d ", ans[i]);
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

ll x;


int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  cin >> x;
  cout << 1000*(x/500)+ 5*((x-(x/500)*500)/5) << endl;  
 
 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  double a,b,c;
  cin>>a>>b>>c;
  if(b==(a+c)/2){
    cout<<"YES"<<endl;
  }else{
    cout << "NO" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ int from, to, cost; } ;

static const ll INF  = 1LL << 50;
static const int MAX_E = 5e3;
static const int MAX_V = 2500;

edge es[MAX_E];     //辺

ll d[MAX_V];
int V, E, P;

void shortest_path(int s){
    for(int i = 0; i < V; i++) d[i] = INF;
    d[s] = 0;
    int cnt = 0;
    while (true){
        cnt++;
        bool update = false;
        for(int i = 0; i < E; i++){
            edge e = es[i];
            if( d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
        if(cnt > E + 10){
            for(int i = 0; i < V + 10; i++){
                for(int j = 0; j < E; j++){
                    edge e = es[j];
                    if ( d[e.from] != INF && d[e.to] > d[e.from] + e.cost ){
                        d[e.to] = -INF;
                        update = true;
                    }
                }
            }
            break;
        }
    }
    if(d[V-1] == -INF ) cout << -1 << endl;
    else if(d[V-1] < 0)cout << d[V-1] * (-1) << endl;
    else cout << 0 << endl;
}
/*
bool find_negative_loop(){
    memset(d, INF, sizeof(d));
    d[0] = 0;

    for(int i = 0; i < V; i++){
        for(int j = 0; j < E; j++){
            edge e = es[j];
            //cout << "e.from: " << e.from << " e.to :" << e.to << " e.cost " << e.cost << endl; 
            if( d[e.to] > d[e.from] + e.cost){
                //cout << "d[e.to]: " << d[e.to] << " d[e.from]" << d[e.from] << endl;
                d[e.to] = d[e.from] + e.cost;

                //cout << "i "<< i << " j " << j <<  " e.from: " << e.from << " e.to :" << e.to << " e.cost " << e.cost << endl; 
                
                //V回目にもゴールの点の更新があるなら負の閉路が存在する
                if( i == V - 1 && e.to == V - 1) return true;
            }
        }
    }
    return false;
}
*/
int main(){
    cin >> V >> E >> P;
    for(int i = 0; i < E; i++){
        int a, b, c; cin >> a >> b >> c; a--, b--;
        es[i] = {a, b, -(c - P)};
    }
    /*if(find_negative_loop()) {
        cout << -1 << endl;
        return 0;
    }*/
    shortest_path(0);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    string S;
    cin>> S;
    string ans;
    for (int i = 0; i < S.size(); i++)
    {
        if (i%2==0)

        {
           ans+=S.at(i);
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>

#define N 200010

using namespace std;

char s[N];
int ans,mod[2019];

int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    mod[0]=1;
    for(int i=len,x=0,cnt=1;i>=1;i--,cnt=cnt*10%2019)
    {
        x=((s[i]-'0')*cnt+x)%2019;
        ans+=mod[x];
        mod[x]++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    vector<int> h(n);
    int ans = 0;
    rep(i,n) {
        cin>>h[i];
        if (h[i]>=k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    int main(){
      int n,k;
      cin>>n>>k;
      long long a[n];
      for(int i=0;i<n;i++)
        cin>>a[i];
      long long dp[n];
      dp[0]=0;
     // dp[1]=abs(a[1]-a[0]);
      for(int i=1;i<n;i++){
	long long mi=INT_MAX;
	for(int j=1;j<=k;j++){
		if(i-j>=0)
        	mi=min(mi,dp[i-j]+abs(a[i]-a[i-j]));
	}
	dp[i]=mi;
      }
      cout<<dp[n-1];
      return 0;
    }

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
int i,j,k,n,x;
while(1){
int d=0;
scanf("%d %d",&n,&x);
if(n==0&&x==0)  break;
else{
for(i=1;i<=n-2;i++){
  for(j=i+1;j<=n-1;j++){
    for(k=j+1;k<=n;k++){
if(i+j+k==x)  d++;
    }
  }
}
 printf("%d\n",d);
}
}
return 0;
}

Measured memory_bytes: 600
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
      if (n & 1) res = res * a % MOD;
      a = a * a % MOD;
      n >>= 1;
  }
  return res;
}
ll inv_mul(ll x, ll y){
 return (x % MOD* modpow(y,MOD-2))%MOD;
}
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }

int main() {
    ll n,m,k;
    // ll mod = 1000000007;
    std::cin >> n>>m>>k;
    COMinit();
    
    ll base = inv_mul(COM(n*m,k)*COM(k,2)%MOD,COM(n*m,2));
    // std::cout << base << std::endl;
    
    ll result = 0;
    for (ll i = 1; i <= n+m; i++) {
        // std::cout << i << std::endl;
        for (int l = max((ll)0,i-m); l <= min(i,n); l++) {
            ll r = i-l;
            // m-r>=0
            // std::cout <<result <<" "<<i<<" "<< l<<" "<<r <<" "<<(n-l)*(m-r) << std::endl;
            if(l == 0 || l == i){
                result += i*( max ((ll)0, (n-l)*(m-r) ) )%MOD;
                // result += ( max ((ll)0, (n-l)*(m-r) ) )%MOD;
            }else{
                result += i*2 *( max ((ll)0, (n-l)*(m-r) ) )%MOD;
                // result += 2 *( max ((ll)0, (n-l)*(m-r) ) )%MOD;
            }
            // std::cout << result << std::endl;
        }
        result%=MOD;
        // std::cout << i<<" "<<result << std::endl;
    }
    
    std::cout << base*result % MOD << std::endl;
    
}


Measured memory_bytes: 12160
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int H,W;
int taka[509][509], aoki[509][509];
int dh[] = { -1, 0, 1, 0};
int dw[] = { 0, 1, 0, -1};

bool ck(int i,int j){
    return (i>=0&&i<H&&j>=0&&j<W&&aoki[i][j]==1);
}

void bfs(int i,int j){
    aoki[i][j]=2;
    rep(l,4){
        int ni=i+dh[l], nj=j+dw[l];
        if(ck(ni,nj)) bfs(ni,nj);
    }
}

void pr(int ans[509][509]){
    rep(i,H){
        rep(j,W){
            cout<<(ans[i][j]?'#':'.');
        }
        cout<<endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W;
    rep(i,H)rep(j,W){
        char c; cin>>c;
        if(c=='#'){
            taka[i][j]=aoki[i][j]=1;
            continue;
        }
        if(j==0){
            taka[i][j]=1;
        }else if(j==W-1){
            aoki[i][j]=1;
        }else if(i%2){
            taka[i][j]=1;
        }else{
            aoki[i][j]=1;
        }
    }
    
    pr(taka);
    cout<<endl;
    pr(aoki);
}


Measured memory_bytes: 2688
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> x(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &x[i]);
        }
        vector<int> y = x;
        sort(y.begin(), y.end());
        int l = y[n / 2 - 1], r = y[n / 2];
        for (int i = 0; i < n; i ++) {
                if (x[i] <= l) {
                        printf("%d\n", r);
                } else {
                        printf("%d\n", l);
                }
        }
        return 0;
}



Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int q = in.nextInt();
		String s = in.next();

		int[] t = new int[n+1];
		for(int k =0; k<n+1; k++) {
			t[k]=0;
		}
		for(int i=0; i<n-1; i++) {
			String sub = s.substring(i,i+2);
			t[i+1] = t[i] + (sub.equals("AC")? 1:0);
		}

		for(int j=0; j<q; j++) {
			int l= in.nextInt();
			int r= in.nextInt();
			System.out.println(t[r-1]-t[l-1]);
		}

	}
}


Measured memory_bytes: 84368
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
B.extend([0,0])
C = [0]*(N+2)
sum = 0
for i in range(N+1):
    if A[i]-C[i]<=0:
        sum += A[i]
        C[i+1] = B[i]
    elif A[i]-B[i]-C[i]>0:
        sum += B[i]+C[i]
    else:
        sum += A[i]
        C[i+1] = B[i]-A[i]+C[i]
print(sum)

Measured memory_bytes: 19004
n = int(input())
a = [int(_) for _ in input().split()]
ruiseki = [0] * n
ruiseki[0] = a[0]
for i in range(1, n):
    ruiseki[i] = ruiseki[i-1] + a[i]

if n == 2:
    print(abs(a[0] - a[1]))
    exit()

total = ruiseki[n-1]
ans = 10000000000000
for i in range(1, n-1):
    ans = min(ans, abs((total - ruiseki[i]) - ruiseki[i]))
print(ans)

Measured memory_bytes: 24824
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define MAX 1000000007

using namespace std;

int main() {
	int N;
	char s[102];
	cin >> N;
	cin >> s;
	int r = 0;
	rep0(i, N) {
		if (s[i] == 'R')r++;
	}
	if (r * 2 > N) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
  sort(begin(v),end(v),f);
  v.resize(unique(begin(v),end(v))-begin(v));
}

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

  int n;
  string a,b,c;
  cin >> n >> a >> b >> c;
  int ans=0;
  REP(i,n) {
    vector<char> v;
    v.PB(a[i]);
    v.PB(b[i]);
    v.PB(c[i]);
    sort_uniq(v);
    ans+=(int)v.size()-1;
  }
  cout << ans << '\n';
  return 0;
}











Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

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

    cout << "A" << (r < 1200 ? "B" : (r < 2800 ? "R" : "G")) << "C" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sg(int n,int k){
    if(n<k)return 0;
    if(n%k==0)return n/k;
    return sg(n-((n-n/k*k+n/k)/(n/k+1))*(n/k+1),k);
}
int main(){
    int n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        int a,k;cin>>a>>k;
        ans^=sg(a,k);
    }
    cout<<(ans?"Takahashi":"Aoki")<<"\n";
    return 0;
}

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

int main()
{
    int l,r,ans;

    cin >> l >> r;

    ans = INT_MAX;
    for (int i=l;i<r;++i) {
        for (int j = i + 1;j <= r;++j) {
            ans=min(ans,(int)(((ll)i * j) % 2019));
            if (ans == 0)
                goto OWARI;
        }
    }
OWARI:
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3512
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int ans=0;
	for(int i=0;i!=a;i++) {
		int c=scan.nextInt();
		if(Math.abs(c)<Math.abs(c-b)) {
			ans+=c*2;
		}
		else {
			ans+=Math.abs(c-b)*2;
		}
	}
	System.out.println(ans);
	scan.close();
}
}

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

const int A = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(A);
  rep(i,n) {
    cin >> a[i];
    c[a[i]]++;
  }

  bool pairwise = true;
  for (int i = 2; i < A; i++) {
    int cnt = 0;
    for (int j = i; j < A; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }

  if (pairwise) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = 0;
  rep(i,n) g = gcd(g,a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;
  return 0;
}


Measured memory_bytes: 11040
//\\                            ||                     ||
            ////          //  \\                           ||                     ||
                         //    \\          //\\    //\\    ||                     ||
            ////        //      \\       //   \\  //  \\   ||                     ||
            ////       ____________     ||     \\//    ||  ||_______      ________||
            ////      //          \\    ||             ||  ||______\\    //_______||
            ////     //            \\   ||             ||  ||       ||   ||       ||
            ////    //              \\  ||             ||  ||_______||   ||_______||
            ////   //                \\ ||             ||  ||______//     \\______||







                     /*WHO CARES IF ONE MORE LIGHT GOES OUT ?
                           IN A SKY OF A MILLION STARS
                               IT FLICKERS,FLICKERS
                       WHO CARES WHEN SOMEONE'S TIME RUNS OUT ?
                            IF A MOMENT IS ALL WE ARE.
                       WHO CARES IF ONE MORE LIGHT GOES OUT ?
                                WELL I DO...*/
#include<bits/stdc++.h>
using namespace std;
long long int fa[1022];

long long int powe(long long int d,long long int s)
{
    if(s==1) return d;
    else if(s==0) return 1;
    else
    {
        long long int u,v=d;
        for(u=1;u<s;u++)
        {
            d=d*v;
        }
        return d;
    }
}
long long int phi(long long int n)
{
    double result=n;
    for (long long int p=2;p*p<=n;++p){
        if (n%p==0){
            while(n%p==0)
                n/=p;
            result*=(1.0-(1.0/(double)p));
        }
    }
    if(n>1)
        result*=(1.0-(1.0/(double)n));
    return (long long int) result;
}
long long int bigmod(long long int a, long long int b,long long int m)
{
    long long int r;
    if(b==0) return 1;
    if(b%2==0) { r=(r*r)%m;
        return  r;
    }
        return ((a%m)*bigmod(a,b-1,m)%m)%m;
}
int main()
{
    map<string,long long int>mp;
    long long int a,b,c,d,i;
    cin>>a>>b>>c>>d;
    for(;;)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            break;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No"<<endl;
            break;
        }
    }




    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)


constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;



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

	int n; cin >> n;
	int* a = new int[n];
	rep(i, 0, n) cin >> a[i];

	rrep(i, 0, n - 1) {
		if (a[i] > a[i + 1] + 1) {
			cout << "No" << endl;
			return 0;
		}
		if (a[i] > a[i + 1]) {
			a[i]--;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
const double pi=3.1415926535898;
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	double n;
	cin>>n;
	n=n/180.0*pi;
	double x=0,y=1,cita=n+pi/2.0;
	int ans=1;
	while(1)
	{

		x+=cos(cita);
		y+=sin(cita);
		cita+=n/1;
		ans++;

		if((abs(x)<1e-9&&abs(y)<1e-9))break;
		//cout<<ans;
	}
cout<<ans;
}


Measured memory_bytes: 4112
import sys
from sys import stdin

n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))
tmp = a[0]
for i in range(1, len(a)):
    tmp = tmp ^ a[i]
for i in range(1, len(a)):
    if a[i] ^ tmp == a[i]:
        print('Yes')
        sys.exit()
print('No')

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

using namespace std;

const int mod = 1e9 + 7;

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

long long mul(long long a, long long b) {
    return (((a % mod) * (b % mod)) % mod);
}

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

/*bool good(vector<int> &v, int d, int mid){
    vector<int> p(v.size());
    p[0] = v[0] - mid;
    for(int i = 1;i < v.size();i++){
        p[i] = p[i - 1] + (v[i] - mid);
    }
    vector<int> m(v.size());
    m[0] = p[0];
    int mi = m[0];
    for(int i = 1;i < v.size();i++){
        mi = min(mi, p[i]);
        m[i] = mi;
    }
    for(int r = 0;r < v.size();r++){
        if(r - d > 0){
            if(m[r - d - 1] <= p[r]){
                L = r - d;
                R = r;
                return true;
            }
        }
    }
    return false;
}*/

int main(){
    string s, t;
    cin >> s >> t;
    int ans = t.length();
    for(int i = 0;i < s.length() - t.length() + 1;i++){
        int tmp = 0;
        int k = i;
        for(int j = 0;j < t.length();j++){
            if(s[k] != t[j]){
                tmp++;
            }
            k++;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;














    /*int n, d;
    cin >> n >> d;
    vector<int> v(n);
    for(int i = 0;i < n;i++){
        cin >> v[i];
    }
    int l = -1,
        r = 101;
    while(r > l + 1){
        int mid = (l + r) / 2;
        if(good(v, d, mid)){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    cout << L + 1 << " " << R + 1<< endl;
    cout << l << endl;*/
}
/*
5 2
-1 -2 -3 4 5
2 3
4

-3 -2 -1 4 5
2 3
5 + (-3) = 2
4 + -2 = 2
ans = 4

-3 -2 -1 4 5
3 2
5 + -3 = 2
4 + -1 = 3
ans = 5
*/


Measured memory_bytes: 3616
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
j = [341,561,645,1105,1387,1729,1905,2047,2465,2701,2821,3277]
lis = [x * 10 + 1 for x in range(1,5556)]
li = [x for x in lis if is_prime(x) and not x in j]
print(*li[:int(input())])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
	const int MAX = 1e7;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  COMinit();
  int N , M ;
  cin >> N >> M ;
  int A = 0 , B = 0 ;
  if(N >= 2 )A = COM(N,2) ;
  if(M >= 2) B = COM(M,2) ;
  cout << A + B << endl ;
} 


Measured memory_bytes: 234624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum;
  cin >> N;
  sum = 0;
  int A[N];
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
  }
  for ( int i = 0; i < N; i++ ) {
    if ( ( A[i] % 2 ) == 0 ) {
      A[i] = A[i] / 2;
      if ( i == N - 1 ) {
        i = 0;
        sum++;
        continue;
      }
    }
    else {
      break;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
int n;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	string s;
	cin>>s;
	cout<<string(s.size(),'x');
}





Measured memory_bytes: 636
import sys
import numpy as np

# import os
# path = os.getcwd()
# path = os.path.join(path,"input.txt")
# sys.stdin = open(path)

input = sys.stdin.readline
N = int(input())
p = [int(input()) for i in range(N)]
p.sort(reverse=True)
p[0] = int(p[0]/2)
print(sum(p))

Measured memory_bytes: 12424
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x: x[1])

time = 0
for i in range(N):
    time += AB[i][0]
    if time > AB[i][1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 33968
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int n = Integer.parseInt(sc.next());
      if(n == 0) break;
      int first = Integer.parseInt(sc.next());
      int max = first;
      int min = first;
      int sum = first;
      for(int i = 1; i < n; i++){
        int n2 = Integer.parseInt(sc.next());
        if(max < n2) max = n2;
        if(min > n2) min = n2;
        sum += n2;
      }
      double ave = Math.floor((sum - min - max) / (n - 2));
      System.out.printf("%.0f\n", ave);
    }
  }
}


Measured memory_bytes: 28856