akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    vi a1 = a;
    Sort(a1);
    map<int, int> pos;
    forn(i, n) pos[a1[i]] = i;
    int ans = 0;
    forn(i, n){
        if (i % 2 != pos[a[i]] % 2) ans++;
    }
    cout << ans / 2 << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

int digit[64];
long long K, N;
vector<long long> v;
map<long long, bool> memo;

long long calc(long long X) {
    long long ans = 0;
    for(long long x: v) {
        ans += x^X;
    }

    return ans;
}

long long conv(int S) {
    long long ret = 0;
    for(int i = 0; i < 64; i++) {
        if((S >> i) & 1) ret += 1LL << i;
    }

    return ret;
}

long long dp[64][2];

long long dfs(long long X, int i, bool ub_flag) {
    if(i == -1) {
        return 0;
    }

    if(dp[i][ub_flag] != -1) {
        return dp[i][ub_flag];
    }

    long long ret = 0;
    long long next_X = X | (1LL << i);

    // Kのbitが立っているとき
    if((K >> i) & 1) {
        // 1を設定
        ret = max(ret, dfs(next_X, i-1, ub_flag) + (N-digit[i]) * (1LL<<i));

        // 0を設定してub_flagをfalseに
        ret = max(ret, dfs(X, i-1, false) + (digit[i] * (1LL<<i)));
    }
    // Kのbitが立っていないとき
    else
    {
        // 上界で進んでいるとき
        if (ub_flag)
        {
            // 0を設定するしか無い
            ret = max(ret, dfs(X, i-1, ub_flag) + (digit[i]*(1LL<<i)));
        }
        // そうでないとき
        else
        {
            ret = max(ret, dfs(X, i-1, ub_flag) + (digit[i]*(1LL<<i)));
            ret = max(ret, dfs(next_X, i-1, ub_flag) + (N-digit[i]) * (1LL<<i));
        }
    }

    dp[i][ub_flag] = ret;
    return ret;
}


int main()
{
    long long A;
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        for (int j = 0; j < 64; j++)
        {
            if ((A >> j) & 1)
            {
                digit[j]++;
            }
        }
    }

    for(int i = 0; i < 64; i++) {
        for(int j = 0; j < 2; j++) {
            dp[i][j] = -1;
        }
    }

    cout << dfs(0LL, 40, true) << endl;
}


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

#define PI 3.14159265358979323846264338327950L

int A, B, H, M;
double res;

int main()
{
    cin >> A >> B >> H >> M;

    res = sqrt(A * A + B * B - 2 * A * B * cos(abs((H * 30 + M * 0.5) - (M * 6)) * PI / 180));
    cout << fixed << setprecision(9) << res << endl;

    return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i;
	cin >> n;
	vi a(n);
	map<int, int> mp;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		mp[a[i]]++;
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (i = 0; i < n; i++) {
		if (mp[a[i]] < a[i]) {
			ans += mp[a[i]];
			mp[a[i]] = a[i];
		}
		else if (mp[a[i]] > a[i]) {
			ans += mp[a[i]] - a[i];
			mp[a[i]] = a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct{
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN; 
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int main(void){
	int e = 0;
	int i ,q ,c;
	P u;
	scanf("%d %d", &n, &q);
	for(i = 1; i <= n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1;
	tail = n + 1;
	while(head != tail){
		u = dequeue();
		if(q < u.t){
			c = q;
		}
		else{
			c = u.t;
		}
		u.t -= c;
		e += c;
		if(u.t > 0){
			enqueue(u);
		}
		else{
			printf("%s %d\n", u.name, e);
		}
	}
	return 0;
}


Measured memory_bytes: 11868
while True :
  m, n, N = map(int, input().split())
  if(m == 0 and n == 0 and N == 0) :
    break
  else :
    p = [0] * m
    for i in range(m) :
      p[i] = int(input())
    s = 0
    for j in range(n - 1, N) :
      if(p[j] - p[j + 1] >= s) :
        s = p[j] - p[j + 1]
        a = j + 1
      else :
        pass
    print(a)


Measured memory_bytes: 5616
let n, m, x = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c - 1
let a_s = Array.init m @@ fun _ -> Scanf.scanf " %d" pred
let ans = ref @@ max_int
let f n = Array.fold_left (fun c a -> if a = n then 1 else c) 0 a_s
let _ = let c = ref 0 in for i = 0 to x - 1 do c := !c + f i done;
  ans := !c; let c = ref 0 in for i = x + 1 to n - 1 do c := !c + f i done;
  ans := min !ans !c; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=200005;
ll sum[maxn],a[maxn];
ll n,b,c,d,e;
ll ans=1e15+7;
bool check(ll x,ll y,int i)
{
    if(abs((x+a[i])-(y-a[i]))<abs(x-y))
    return 1;
    return 0;
}
int main()
{
    cin>>n;
    ll s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
        sum[i]=s;
    }
    int j=0,k=2;
    for(int i=1;i<n-2;i++)
    {
        b=sum[j];
        c=sum[i]-sum[j];
        d=sum[k]-sum[i];
        e=sum[n-1]-sum[k];
        while(check(b,c,j+1) && j+1<i)
        {
            j++;
            b=sum[j];
            c=sum[i]-sum[j];
        }
        while(check(d,e,k+1) && k+1<n-1)
        {
            k++;
            d=sum[k]-sum[i];
            e=sum[n-1]-sum[k];
        }
        ll test[10];
        test[0]=b;test[1]=c;
        test[2]=d;test[3]=e;
        sort(test,test+4);
        ans=min(ans,test[3]-test[0]);
    }
    cout<<ans<<endl;
    return 0;
}



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

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

    int ans=0;

    for (int i=1; i<=N; i+=2){
        int num=0;
        for (int j=1; j<=i; j++){
            if (i%j==0) num++;
        }
        if (num==8) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define ll long long int

using namespace std;

string s;

int main()
{
    ///freopen("INA.txt","r",stdin);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    cin>> s;

    if(s[s.length()-1]=='s'){
        cout << s << "es" << endl;
    }
    else{
        cout << s << "s" << endl;
    }

    return 0;
}



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

using namespace std;
int main(){
 
  long n,m;
  cin >> n >> m;
  
  long res;
  for(long i=m/n;i>0;i--){
   if(m%i==0) {
     res=i; 
     break;
   }
  }
  
  cout << res << endl;
  
  
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;
int main(){
  vector<long long int> p,q,r;
  long long int n,s=0,k=0,c=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    p.push_back(x);
  }
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    q.push_back(x);
  }
  for(int i=0;i<n;i++){
    int x;
    x=p.at(i)-q.at(i);
    s+=x;
    r.push_back(x);
  }
   sort(r.begin(),r.end());
 reverse(r.begin(),r.end());
  if(s<0){
    cout<<-1;
  }
 
  else{
    for(int p:r){
    if(p<0){
      k+=p;
      c++;
    }
  }
    for(int p:r){
    if(k<0){
      k+=p;
      c++;
    }
  }}
    if(s>=0){cout<<c;}
}


Measured memory_bytes: 3316
using System;
using System.Linq;
using System.Collections.Generic;

namespace lineAralgebra
{
	class Program
	{
		public static void Main(String[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

			bool ok = true;
			for (var i = 0; i < input.Length; i++)
			{
				if (input[i] % 2 == 0)
				{
					if (input[i] % 3 != 0 && input[i] % 5 != 0)
					{
						ok = false;
					}
				}
			}
			if (ok)
			{
				System.Console.WriteLine("APPROVED");
			}
			else
			{
				System.Console.WriteLine("DENIED");
			}

		}
	}
}



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

int main() {

    int n, h;

    cin >> n >> h;

    vector<int> attack(n);
    vector<int> throwing(n);

    int maxAttack = 0;

    for(int i = 0; i < n; ++i) {
        cin >> attack[i] >> throwing[i];
        maxAttack = max(maxAttack, attack[i]);

    }

    sort(throwing.begin(), throwing.end(), greater<int>());

    int count = 0;
    int index = 0;
    while(index < n && throwing[index] > maxAttack && h > 0) {
        h -= throwing[index];
        index++;
        count++;
    }

    while(h > 0) {
        h -= maxAttack;
        count++;
    }

    cout << count << endl;

    return 0;
}

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


#define For(k) for(int i=0;i<k;i++)

using namespace std;
using ll = long long;

int main() {
    int ans = 0;
    ll n,m,pi,t;
    pi = 0;
    t = 0;
    cin >> n >> m;
    string s;
    array<bool,100001> ac = {false};
    array<int ,100001> pena = {0};
    For(m) {
        cin >> pi >> s;
        if (s == "AC" && ac[pi] == false) {
            ac[pi] = true;
            ans++;
        } else if (s =="WA" && (ac[pi] == false)){
            ++pena[pi];
            // cout << pena[pi] <<"\n";
        }
    }
    For(100001){
        if (ac[i] == true){
            t += pena[i];
        }
    }
    cout << ans << " " << t;
}


Measured memory_bytes: 768
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    d, t, s = MII()
    if d/s <= t:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include<iostream>
using namespace std;
#include<cmath>
long long A,B,C;
long long mm;
long long box1,box2,ans;
int main()
{
	cin>>A>>B>>C;
	mm=A>>1;
	box1=mm*B*C;
	box2=(A-mm)*B*C;
	ans=abs(box1-box2);
	
	mm=B>>1;
	box1=mm*A*C;
	box2=(B-mm)*A*C;
	if(abs(box1-box2)<ans)
	ans=abs(box1-box2);
	
	
	mm=C>>1;
	box1=mm*B*A;
	box2=(C-mm)*B*A;
		if(abs(box1-box2)<ans)
	ans=abs(box1-box2);
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		String ans = "No";
		char[] c = str.toCharArray();
		for (int i=0; i < str.length(); i++) {
			if (c[i] == '7') {
				ans = "Yes";

				break;
			}
		}

		System.out.println(ans);
	}
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
  cin >> a >> b >> c;
  cout << min(a * b, c);
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

int main() {
  
  int N, C;
  while(cin >> N >> C && N && C) {
    int panel[N]; memset(panel, 0, sizeof panel);
    rep(i, N) rep(j, 16) {
      int x; cin >> x;
      if(x) { panel[i] |= 1<<j; }
    }
    
    int jubi[C]; memset(jubi, 0, sizeof jubi);
    rep(i, C) rep(j, 16) {
      int x; cin >> x;
      if(x) { jubi[i] |= 1<<j; }
    }
    
    int dp[2][1<<16];
    memset(dp, -1, sizeof dp);
    dp[0][0] = 0;
    
    int const mask = (1<<16)-1;
    rep(i, N) rep(S, 1<<16) {
      if(dp[i&1][S] == -1) continue;
      dp[(i+1)&1][panel[i]|S] = max(dp[(i+1)&1][panel[i]|S], dp[i&1][S]);
      rep(j, C) {
        int nS = (panel[i]|S)&(mask^jubi[j]);
        int score = __builtin_popcount(panel[i]|S) - __builtin_popcount(nS);
        dp[(i+1)&1][nS] = max(dp[(i+1)&1][nS], dp[i&1][S] + score);
      }
    }
    cout << *max_element(dp[N&1], dp[N&1]+(1<<16)) << endl;
  }
  
  return 0;
}

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

using namespace std;
int main(){
  long n,k;
   cin >> n >> k;
  
   long res=(n/k)*(n/k)*(n/k);
  
  if(!(k%2)) res+=(n/(k/2)-n/k)*(n/(k/2)-n/k)*(n/(k/2)-n/k);
  
  cout << res << endl;
  
}


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

using namespace std;

int main()
{
	string w;
	cin >> w;
	bool check[26] = {};
	bool tmp[26] = {};
	for (auto&& c : w) check[c-'a'] = !check[c-'a'];
	if (memcmp(check, tmp, sizeof(check)))
		cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	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;
}

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


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll n,x,y,ans=0;
	in(n);
	
	vll a(n);
	vector<vll> b(n, vll(n, -1));
	rep(i, 0, n) {
		in(a[i]);
		rep(j, 0, a[i]) {
			in(x);
			in(y);
			b[i][x - 1] = y;
		}
	}

	rep(i, 0, (1 << n)) {
		ll tmp = 0;
		bool flg = true;
		rep(j, 0, n) {
			if (i & (1 << j)) {
				tmp++;
				rep(k, 0, b[j].size()) {
					if (b[j][k] == 1 && !(i & (1 << k))) {
						flg = false;
						break;
					}
					else if (b[j][k] == 0 && (i & (1 << k))) {
						flg = false;
						break;
					}
				}
				if (!flg) {
					break;
				}
			}
		}
		if (flg) {
			ans = max(ans, tmp);
		}
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
 
 
 
 
int main() {
 
int n=D(),m=D();
char a[n][n];
char b[m][m];
for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
   cin>>a[i][j];
 
   }
 
}
for(int i=0;i<m;i++){
   for(int j=0;j<m;j++){
cin>>b[i][j];
   }
 
}
 
 
 
for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
int cnt=0;
 
     for(int ii=0;ii<m;ii++){
       for(int jj=0;jj<m;jj++){
 
       if(b[ii][jj]==a[i+ii][j+jj]){
       cnt++;
 
       }
 
       }
 
 
 
 
 
     }
     if(cnt==(m*m)){
     cout<<"Yes";
     return 0;
     }
 
 
 
   }
 
}
cout<<"No";
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

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

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int c = 0;
    vector<int> ans;
    for(int i = 1;i<101;i++){
        if(a%i==0&&b%i==0){
            ans.push_back(i);
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans[k-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n) cin >> h[i];

    vi dp(n+k, INF);
    dp[0] = 0;
    rep(i, n) {
        for (int j = 1; j <= k; ++j) {
            chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
  int H, W, M, max_y = 0, max_x = 0;
  set< pair<int, int> > set_M;
  map<int, int> count_y, count_x;
  vector<int> vec_max_y, vec_max_x;

  cin >> H >> W >> M;
  for (int i=0; i < M; i++) {
    int y, x;
    cin >> y >> x;
    set_M.insert( {y, x} );
  }

  for (auto m : set_M) {
    // m.first = y of target. m.second = x of target.
    count_y[m.first]++; count_x[m.second]++;

    // update max_y, max_x for later use
    max_y = max( max_y, count_y[m.first] );
    max_x = max( max_x, count_x[m.second] );
  }
  //cout << "max_y:" << max_y << " max_x:" << max_x << "\n";

  // update vec_max_y, vec_max_x to have the list of max numbers (= candidate to search)
  for (auto tmp_y : count_y) {
    if (tmp_y.second == max_y) {
      //cout << "push_back tmp_y.first:" << tmp_y.first << " tmp_y.second:" << tmp_y.second << "\n";
      vec_max_y.push_back(tmp_y.first);
    }
  }
  for (auto tmp_x : count_x) {
    if (tmp_x.second == max_x) {
      //cout << "push_back tmp_x.first:" << tmp_x.first << " tmp_x.second:" << tmp_x.second << "\n";
      vec_max_x.push_back(tmp_x.first);
    }
  }

  // candidate pair of search
  int ans = max_y + max_x - 1;
  for (auto tmp_y : vec_max_y) {
    for (auto tmp_x : vec_max_x) {
      //cout << tmp_y << " & " << tmp_x << "\n";

      if ( set_M.find( {tmp_y, tmp_x} ) == set_M.end() ) {
        ans++;
        cout << ans << "\n";
        return 0;
      }
    }
  }
  cout << ans << "\n";
}


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

float dist(float a,float b,float c,float d)
{
    float x=a-b,y=c-d;
    return sqrt(x*x + y*y);
}

int main()
{
    int n;
    cin>>n;
    float a[n],b[n];
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i];
    double ans=0;
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
                ans+=2*dist(a[i],a[j],b[i],b[j]);
    cout<<fixed;
    cout<<setprecision(10)<<ans/n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	int K, S; cin >> K >> S;
	int ans = 0;

	eREP(i, K) {
		eREP(j, K) {
			if (S - i - j >= 0 && S - i - j <= K)ans++;
		}
	}




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



Measured memory_bytes: 256
x = [int(i) for i in input().split()]
h = x[0]
w = x[1]
aim = [[0 for i in range(w+2)] for j in range(h+2)]#aim[h+2][w+2]
for height in range(h):
    ipt = list(input())
    for width in range(w):
        if ipt[width] == '#':
            aim[height+1][width+1] =1

judge = 0
for height in range(h):
    for width in range(w):
        if aim[height+1][width+1] == 1:
            if aim[height][width+1] == 0 and aim[height+2][width+1] == 0 and aim[height+1][width] == 0 and aim[height+1][width+2] == 0:
                judge = 1

if judge == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
Q, H, S, D = list(map(int, input().split()))
N = int(input())

x = min(4 * Q, 2 * H, S)
y = min(8 * Q, 4 * H, 2 * S, D)

if N == 1:
	print(x)
elif N == 2:
	print(y)
else:
	if N % 2 == 0:
		print(min(N * x, int(N // 2) * y))
	else:
		print(min(N * x, int(N // 2) * y + x))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>
#include <climits>
using namespace std;

int* pa;
int* v;
int n;
int q;
queue<int> qr;
void init(int n) {
	pa = new int[n];
	v = new int[n];
	for (int i = 0; i < n; ++i) {
		pa[i] = i;
		v[i] = 0;
	}
}

int find(int x) {
	if (x != pa[x]) {
		int p = pa[x];
		pa[x] = find(pa[x]);
		v[x] += v[p];
	}
	return pa[x];
}

void unite(int x, int y, int z) {
	int px = find(x);
	int py = find(y);
	if (px != py) {
		pa[px] = py;
		v[px] = v[y] - v[x] + z;
	}
}

bool check(int x, int y) {
	int px = find(x);
	int py = find(y);
	return px == py;
}

int main() {
	cin >> n >> q;
	init(n);
	for(int i = 0; i < q; i++)
	{
		int op;
		cin >> op;
		if (op == 0) {
			int x, y, z;
			cin >> x >> y >> z;
			unite(x, y, z);
		}
		else {
			int x, y;
			cin >> x >> y;
			if (check(x, y)) {
				qr.push(v[x] - v[y]);
			}
			else {
				qr.push(INT_MAX);
			}
		}
	}
	while (!qr.empty())
	{
		int t = qr.front();
		if (t == INT_MAX)
			cout << "?" << endl;
		else
			cout << t << endl;
		qr.pop();
	}
	return 0;
}


Measured memory_bytes: 5852
package main

import (
	"fmt"
	//	"os"
	"strconv"
)

const (
	LARGE_NUM = 1000000007
)

func stringToint(s string) int {
	i, _ := strconv.ParseInt(s, 10, 64)
	return int(i)
}

func main() {
	var x int
	fmt.Scan(&x)
	hoge := x / 11
	if x%11 > 6 {
		fmt.Println(hoge*2 + 2)
	} else {
		if x%11 != 0 {
			fmt.Println(hoge*2 + 1)
		} else {
			fmt.Println(hoge * 2)
		}
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2))
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
};

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!";
	}
	else {
		cout << ":(";
	}

}

Measured memory_bytes: 256
a = int(input())
counter = 1
sum_num = 26 ** counter
before_sum_num = 0

while True:
  if a <= sum_num:
    a -= before_sum_num
    a -= 1
    for i in range(counter, 0, -1):
      z = a // (26 ** (i - 1))


      a = a % (26 ** (i-1))
      print(chr(ord('a') + z), end='')
    break

  else:
    before_sum_num = sum_num
    counter += 1
    sum_num += 26 ** counter

print()



Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a,b;
    cin >> a >> b;
    if (a == 'H'){
        if (b == 'H') cout << "H" << endl;
        else if(b == 'D') cout << "D" << endl;
    }else if(a == 'D'){
        if (b == 'H') cout << "D" << endl;
        else if(b == 'D') cout << "H" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
#define int long long
signed main(){
int a,b,c,k;
cin>>a>>b>>c>>k;
if(k%2==0){
  cout<<a-b<<endl;
}else{
  cout<<b-a<<endl;
}


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <atcoder/modint>

#include <atcoder/math>
#include <atcoder/fenwicktree>
#include <atcoder/convolution>
#include <atcoder/scc>
#include <atcoder/twosat>
#include <atcoder/string>
#include <atcoder/lazysegtree>

#include <string>
#include <cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

using namespace atcoder;

ll mod2 = 998244353;

using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    mint a, b;
};

S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{r.a * l.a + r.size * l.b, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }

F id() { return F{1, 0}; }

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        a[i] = S{x, 1};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int l, r;
            int c, d;
            scanf("%d %d %d %d", &l, &r, &c, &d);
            seg.apply(l, r, F{c, d});
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%d\n", seg.prod(l, r).a.val());
        }
    }
    return 0;
}

Measured memory_bytes: 19404
/*
TASK: ditch
LANG: C++11
 */
//#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;
const int N = 5e3 + 3, M = 2 * 3e4 + 3;


int main() {
    //freopen("test.in", "r", stdin);
    int a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a*b)<<endl;
    return 0;
}


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

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

    int N, K, jump;
    cin >> N >> K;
    int H[N], dp[N + 1];
    for (int i = 0; i < N; i++) {
        cin >> H[i];
        dp[i + 1] = INT_MAX;
    }

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        jump = N - i < K ? N - i : K;
        for (int j = 1; j <= jump; ++j) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i] - H[i + j]));
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
	//cout.precision(10);
	//cout << (double)(n-n/2)/(double)n << endl;
      cout.precision(10);
    cout << (double)(N - N / 2) / (double)N << 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 afterOpenDate = b - a;        // 食べた日が賞味期限の何日後か
        String result;

        if (afterOpenDate <= 0) {
            result = "delicious";
        } else if (afterOpenDate <= x) {
            result = "safe";
        } else {
            result = "dangerous";
        }

        System.out.println(result);
	}

}

Measured memory_bytes: 21716
import os,re,sys,operator,math
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
n,k=map(int,stdin.readline().rstrip().split())
a=[int(i) for i in stdin.readline().rstrip().split()]
t=deque(Counter(a).most_common())
ans=0
while len(t)>k:
    now=t.pop()
    ans+=now[1]
print(ans)

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

using namespace std;

#define N 120000

int n,m,in[N],out[N];
vector<int> g[N];
bool vis[N],fl;

void add(int x,int y){
	++out[x+=m]; ++in[y+=m];
	g[x].push_back(y); g[y].push_back(x);
}

void dfs(int u){
	vis[u]=1;
	fl|=in[u]!=out[u];
	if (u<=m&&in[u]<out[u]){puts("NO"); exit(0);}
	if (u>m&&in[u]>out[u]){puts("NO"); exit(0);}
	for (int v:g[u]) if (!vis[v]) dfs(v);
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i){
		int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
		int x=c?-c:a,y=d?d:-b;
		add(x,y);
	}
	for (int i=1;i<=m*2;++i)
		if (in[i]+out[i]&&!vis[i]){
			fl=0;
			dfs(i);
			if (!fl){puts("NO"); return 0;}
		}
	puts("YES");
	
	return 0;
}
			

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;
const int N=1e9+5;

int main(){
    int X, Y; cin >> X >> Y;
    bool ans=false;
    for(int i=0; i<=X; i++){
        if(2*i+4*(X-i) == Y){
            ans=true;
            break;
        }
    }
    cout << (ans ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iomanip>

int main() {

    int N, X, A, B, C, tmp1, tmp2, i = 0, ans = 0, cnt = 0, W, H;
    double S = 0, x, y;

    std::cin >> A >> B >> C;

    int tmp = B + C;

    if(B+C <= A){
        std::cout << 0 << std::endl;
    }else{
        std::cout << B+C-A << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, k;
   cin >> n >> k;
   hr();
   int ans = k;
   rep(i, 1, n) { ans *= k - 1; }
   cout << ans << endl;
   return 0;
}

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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    long long n, h;
    cin >> n >> h;

    vll a(n), b(n);

    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end(), greater<long long>());
    sort(b.begin(), b.end(), greater<long long>());

    long long cnt = 0;
    long long sum = 0;
    rep(i, n) {
        if (a[0] < b[i]) {
            sum += b[i];
            cnt++;
        }
        if (sum >= h) {
            break;
        }
    }

    if (sum < h) {
        if ((h - sum) % a[0] != 0) {
            cnt++;
        }
        cnt += (h - sum) / a[0];
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=1;
  int t[100010];
  int a[100010];
  bool ok=false;
  for(int i=0;i<100010;i++){
    t[i]=0;
    a[i]=0;
  }
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int i=0;i<n;i++){
    a[t[i]]++;
  }
  for(int i=0;i<n;i++){
    if(a[i]==2)
      ans=(2*ans)%1000000007;
    if(n%2==1){
      if(i==0 and a[i]>1)
      ok=true;
      if(i%2==0 and i!=0){
        if(a[i]<2 or a[i]>2)
        ok=true;
      }
      if(a[i]>=1 and i%2==1)
      ok=true;
    }
    if(n%2==0){
      if(a[i]!=2 and i%2==1)
      ok=true;
      if(a[i]!=0 and i%2==0)
      ok=true;
    }
  }
  if(ok)
    cout<<0<<endl;
  else
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
# Problem A: ?????????????¨????

require 'scanf'

def search_trade_card(taro, hanako)
  taro.each do |t|
    hanako.each do |h|
      taro_sum = taro.inject(:+) - t + h
      hanako_sum = hanako.inject(:+) - h + t

      return [t, h] if taro_sum == hanako_sum
    end
  end

  return [-1]
end

while true
  n, m = gets.scanf('%d %d')

  break if n == 0 && m == 0

  taro = []
  hanako = []

  n.times do
    taro << gets.to_i
  end

  m.times do
    hanako << gets.to_i
  end

  puts search_trade_card(taro, hanako).join(' ')
end

Measured memory_bytes: 6412
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i;
	char str[256];
	gets(str);

	for(i=0; i<256; i++){
		if(str[i]>='a' && str[i]<='z')
			str[i] -= 'a' - 'A';
	}
	puts(str);
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
}

int solve(){
    ll X = 0;
    for(auto a:A) X^=a;
    vector<ll> ans;
    for(auto a:A) ans.push_back(X^a);
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 6888
al=input()
bl=input()
cl=input()
turn="a"
winner="A"
while True:
    if turn=="a":
        if len(al)>0:
            turn=al[0]
            al=al[1:]
        else:
            winner="A"
            break
    elif turn=="b":
        if len(bl)>0:
            turn=bl[0]
            bl=bl[1:]
        else:
            winner="B"
            break
    else:
        if len(cl)>0:
            turn=cl[0]
            cl=cl[1:]
        else:
            winner="C"
            break
print(winner)


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

int main () {
	double min, max,x;
	cin >> min;
	max = min;
	while(cin >> x) {
		if(min > x) {
			min = x;
		}
		if(max < x) {
			max = x;
		}
	}
	cout << max - min << endl;
	return 0;
}

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

using ll = long long;
const long long MOD = 1000000007;

// まずはdp[N][K]というので考えてみる
// 例えばA=dp[3][50], B=dp[2][50]を比べると、(残り50個、今の制約が3と2)
// A = dp[1][49] + dp[2][49] + .. dp[N/3][49]
// B = dp[1][49] + dp[2][49] + .. dp[N/3][49] + dp[N/3+1][49] + .. + dp[N/2][49]
// よって
// B = A + dp[N/3+1][49] + .. dp[N/2][49]
// ところで、 dp[N/3+1][49] = dp[N/2][49]である
// なぜなら隣りにおけるのは2までなので
// よって
// B = A + (N/2 - N/3) * dp[N/2][49]である

// また、上のように大きいnが参照できない場合
// dp[N][K] = dp[1][K-1]である

// 実際にdp[N]は状態数が多すぎるので、
// x^2 > Nならばdp[x] = dp[1][N/x]というふうに割り当てる(x^2<=Nならばdp[0][x])
// 以下略

ll N;
ll n;
#define ROOT 35000
ll dp[2][ROOT][101];
void setv(int i, int j, int k, ll v, char mark=' ') {
    dp[i][j][k] = v;
}
ll solve(ll K) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < 2; i++) 
        for (int j = 0; j < ROOT; j++)
            dp[i][j][0] = 1;
    for (int k = 1; k <= K; k++) {
        // 大きい数から
        // i = 1
        // -- j == N (1,1)
        setv(1, 1, k, dp[0][1][k-1]);
        // -- j = N-1 .. N/n
        for (ll j = 2; j <= n; j++) {
            ll a = N/(j-1);
            ll b = N/j;
            setv(1, j, k, (dp[1][j-1][k] + ((N/b - N/a) * dp[0][j][k-1]) % MOD) % MOD, '-');
        }
        // i = 0
        for (ll j = n; j >= 1; j--) {
            setv(0, j, k, (((j + 1) * (j + 1) > N ? dp[1][N/(j+1)][k] : dp[0][j+1][k]) + ((N/j - N/(j+1)) * dp[1][j][k-1]) % MOD) % MOD, '*');
        }
    }
    return dp[0][1][K];
}

int main(){
    scanf("%lld",&N);
    n = (ll)sqrt(N);
    long long K;
    scanf("%lld",&K);
    ll res = solve(K);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 55424
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n, m; cin >> n >> m;
	int k;
	vector<int > cnt(m);
	for (int i = 0; i < n; ++i) {
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int a; cin >> a;
			--a;
			cnt[a]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < cnt.size(); ++i) {
		if (cnt[i] == n) ans++;
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
def selection_sort(arr, n):
    mini = 0
    sw = 0
    for i in range(n-1):
        mini = i
        for j in range(i, n):
            if arr[j] < arr[mini]:
                mini = j
        arr[i], arr[mini] = arr[mini], arr[i]

        if i != mini:
            sw += 1

    return sw



def print_result(arr, n):
    for i in range(n):
        if i > 0:
            print(' ', end='')
        print(arr[i], end='')
    print('\n', end='')



n = eval(input())
arr = [eval(x) for x in input().split()]
sw = selection_sort(arr, n)
print_result(arr, n)
print(sw)



Measured memory_bytes: 5604
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

d = {}
for i in s:
    d[i] = d.get(i, 0)+1
for i in t:
    d[i] = d.get(i, 0)-1
ans = max(0, max(d.values()))
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int n, k;
int arr[100005];
int dp[1000005];
int rec(int x){
	if(dp[x] != -1)return dp[x];
	int check = 0;
	for(int i = 0; i < n; i++){
		if(x + arr[i] <= k){
			if(rec(x + arr[i]) == 0)check = 1;
		}
	}
	return dp[x] = check;
}
int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++)cin >> arr[i];
	for(int i = 0; i <= k; i++)dp[i] = -1;
	int ans = rec(0);
	if(ans)cout <<"First";
	else cout <<"Second";
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,n) for(int i=0;i<n;i++)
    ll a,b,c,d,e,f,g,n,m,k,t,p,x;
 
    ll mod = 998244353;
    
    void solve(){
        string str;
        cin >> str;
        if(str[2] == str[3] && str[4] == str[5]){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }
 
    int main(){
        ios_base::sync_with_stdio(false);
       
        int cases = 1; 
        //cin >> cases;
       
        while(cases--){
            solve();
        }
        return 0;
 
    }

Measured memory_bytes: 256
w, h, n = map(int, input().split())

x_left = 0
x_right = w
y_upper = h
y_lower = 0
t = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x_left = max(x, x_left)
    elif a == 2:
        x_right = min(x, x_right)
    elif a == 3:
        y_lower = max(y, y_lower)
    else:
        y_upper = min(y, y_upper)
    if x_left < x_right and y_lower < y_upper:
        continue
    else:
        t = 1
        break
if t == 1:
    print(0)
else:
    print((x_right - x_left) * (y_upper - y_lower))

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

int main() {
	int H = 0,W = 0,count=0,cut=0;
	char sw[60][60];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> sw[i][j];
			//if (sw[i][j] == '#') cut++;
		}
	}

	//if (cut == 0) {
		//printf("No\n");
         //return 0;
	//}
		

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {

			if (sw[i][j] == '#') {
				if(sw[i - 1][j] != '#'&&sw[i][j - 1] != '#'&&sw[i + 1][j] != '#' && sw[i][j + 1]!='#')
					count++;
			}
				
		}
	}

	if (count == 0) cout << "Yes" << endl;
	else  cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, X[1010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> X[i];

    int ans = inf;
    rep(shukaijo, 0, 2001) {
        int ma = 0;
        rep(i, 0, N) chmax(ma, abs(shukaijo - X[i]));
        chmin(ans, ma);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3200
import java.util.*;
public class Main {
	public static int[] val;
	public static int n;
	public static int x;
	public static boolean[] dp;
	public static int[] PrimeTable;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			int d = stdIn.nextInt();
			int ans = sorv(d,d);
		
			System.out.println(ans);
		}
	}
	public static int sorv(int d, int s) {
		if(s == 600) {
			return 0;
		}
		int tmp = d*d * s;
		if(600 - s >= d + s) {
			return tmp + sorv(d + s, s);
		}
		return tmp;
	}

	
}

Measured memory_bytes: 17180