akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string s1 = "";
            string s2 = "";
            
            List<char> c = new List<char>();
            for(int i = 0 ; i < s.Length ; i++) c.Add(s[i]);
            
            int ans = 1;
            
            while(c.Count > 0)
            {
                c.RemoveAt(c.Count-1);
                if(c.Count % 2 == 1) c.RemoveAt(c.Count-1);
                
                s1 = "";
                s2 = "";
                int index = c.Count / 2;
                
                for(int i = 0 ; i < index ; i++)
                {
                    s1 += c[i];
                    s2 += c[i+index];
                }
                if(s1 == s2)
                {
                    ans = c.Count;
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13268
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();
		long[] vec1 = new long[n];
		long[] vec2 = new long[n];
		for(int i = 0; i < n; i++){
			vec1[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			vec2[i] = sc.nextInt();
		}
		
		long m_dist = 0;
		for(int i = 0; i < n; i++){
			m_dist += Math.abs(vec1[i] - vec2[i]);
		}
		System.out.println(m_dist);
		
		long u_dist = 0;
		for(int i = 0; i < n; i++){
			u_dist += (vec1[i] - vec2[i]) * (vec1[i] - vec2[i]);
		}
		System.out.println(Math.sqrt(u_dist));
		
		long t_dist = 0;
		for(int i = 0; i < n; i++){
			t_dist += Math.abs((vec1[i] - vec2[i]) * (vec1[i] - vec2[i]) * (vec1[i] - vec2[i]));
		}
		System.out.println(Math.pow(t_dist, 1 / 3.0));
		
		long c_dist = 0;
		for(int i = 0; i < n; i++){
			c_dist = Math.max(c_dist, Math.abs(vec1[i] - vec2[i]));
		}
		System.out.println(c_dist);
	}
}

Measured memory_bytes: 20368
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int w=18;
const int k=130;
const int n=26;
int d;

VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

vector<st> f(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,w)
		ret.push_back(tmp[n-1-i]);
	return ret;
}


int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		REP(j,k){
			if(q.empty())
				break;
			for(auto nx:f(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	REP(i,d)
		cout << q.top().a[i]+1 << endl;
	return 0;
}

Measured memory_bytes: 19936
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
set<int> A , B;
set<int>::iterator ita , itb;

int main(){
    int a , b , k , i;
    scanf( "%d%d%d" , &a , &b , &k );
    int limit = sqrt( a );

    for( i = 1 ; i <= limit ; ++i ){
        if( a % i == 0 ){
            A.insert( i );
            A.insert( a / i ); 
        }
    }

    limit = sqrt( b );

    for( i = 1 ; i <= limit ; ++i ){
        if( b % i == 0 ){
            B.insert( i );
            B.insert( b / i ); 
        }
    }

    i = 0;
    ita = A.end();
    --ita;

    while( true ){
        itb = B.find( *ita );

        if( itb != B.end() ){
            ++i;

            if( i == k ){
                printf( "%d\n" , *ita );
                return 0;
            }
        }

        if( ita == A.begin() ) break;
        --ita;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  string s;
  cin >> s;
  string ans;
  rep(i,sz(s)) {
    if(i&1) continue;
    ans += s[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
n = gets.to_i
p = gets.split.map(&:to_i)
cnt = 0
for i in 1..(n-2)
  pa = [p[i-1], p[i], p[i+1]]
  pa.sort!
  if pa[1] == p[i]
    cnt += 1
  end
end
puts cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t H, W;
  cin >> H >> W;
  int64_t A;
  A = (H * W) / 2;
  if(H%2 == 1 && W%2 == 1) A++;
  if(H==1 || W==1) A = 1;
  cout << A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int MAX = (int)1e6 + 5;

bitset<MAX> isPrime;
vi primeList;

inline void Sieve() {
	isPrime.set();
	isPrime[0] = isPrime[1] = 0;
	for (int i = 2; i < MAX; i++) {
		if (isPrime[i]) {
			primeList.push_back(i);
			for (ll j = 1ll*i*i; j < MAX; j += i) {
				isPrime[j] = 0;
			}
		}
	}
}

int Count(int x) {
	int ret = 1;
	int idx = 0;
	int p = primeList[idx];
	while (1ll*p*p <= x) {
		if (x % p == 0) {
			int tmp = 0;
			while (x % p == 0) {
				x /= p;
				tmp++;
			}
			ret *= tmp+1;
		}
		p = primeList[++idx];
	}

	if (x != 1) {
		ret *= 2;
	}
	return ret;
} 

int main() {
	Sieve();
	int n; scanf("%d", &n);
	int ans = 0;
	for (int i = 1; i < n; i++) {
		ans += Count(n-i);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4068
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

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

using namespace std;

typedef long long ll;

ll x, a;

int main() {

//    ifstream in("/Users/koichihasegawa/src/repository/cpp/AtCoder/ABC/abc130/input.txt");
//    cin.rdbuf(in.rdbuf());

    cin >> x >> a;

    if (x < a) {
        cout << 0;
    } else {
        cout << 10;
    }


    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(int argc, char const *argv[])
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll m = max(a*c,a*d);
	ll m2 = max(b*c,b*d);
	m = max(m,m2);
	cout<<m<<endl;	
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=1000000007;
char st[1005];
int p[1005][1005];
long long K;
int qpower(int a,long long b)
{
    int ans=1;
    for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)ans=1ll*ans*a%mod;
    return ans;
}
int calc(int n,int m,int l)
{
    if(n==l)return 1ll*K%mod*m%mod*qpower(n,K-1);
    return 1ll*m*qpower(n-l,mod-2)%mod*(qpower(n,K-1)-qpower(l,K-1))%mod;
}
int main()
{
//    freopen("data.txt","r",stdin);
    int H,W;
    scanf("%d%d%lld",&H,&W,&K);
    if(K==0){puts("1");return 0;}
    int n=0;
    for(int i=1;i<=H;i++)
    {
        scanf("%s",st+1);
        for(int j=1;j<=W;j++)
            p[i][j]=st[j]=='#',n+=p[i][j];
    }
    int n1=0,n2=0;
    for(int i=1;i<=H;i++)
        for(int j=1;j<W;j++)
            n1+=p[i][j]&&p[i][j+1];
    for(int i=1;i<H;i++)
        for(int j=1;j<=W;j++)
            n2+=p[i][j]&&p[i+1][j];
    int cnt1=0,cnt2=0;
    for(int i=1;i<=H;i++)cnt1+=p[i][1]&&p[i][W];
    for(int i=1;i<=W;i++)cnt2+=p[1][i]&&p[H][i];
    if(cnt1&&cnt2){cout<<1<<endl;return 0;}
    if(!cnt1&&!cnt2){cout<<qpower(n,K-1)<<endl;return 0;}
    int ans;
    if(cnt1)ans=calc(n,n1,cnt1);
    else ans=calc(n,n2,cnt2);
    cout<<((qpower(n,K-1)-ans)%mod+mod)%mod<<endl;
}

Measured memory_bytes: 7736
d, g = map(int, input().split())
comp_points = []
P = []
for i in range(d):
    p, c = map(int, input().split())
    comp_points.append([p, (i + 1) * 100 * p + c])
    P.append(p)

ans = 10**10
#bitallsearch
for i in range(2 ** d):
    bit = format(i, "b").zfill(d)
    count = 0
    point = 0
    for j, dot in enumerate(bit):
        if dot == "1":
            count += comp_points[j][0]
            point += comp_points[j][1]
    #add shortage form high point not comp_points
    for b in range(d-1, -1, -1):
        flag = False
        if point >= g:
            ans = min(ans, count)
            break
        if bit[b] == "0":
            flag = True
            for p in range(P[b] - 1):
                count += 1
                point += (b+1) * 100
                if point >= g:
                    ans = min(ans, count)
                    break
        if (point < g) & flag:
            break

print(ans)

Measured memory_bytes: 3064
Klis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(Klis[K])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
 
using namespace std;
const double g = 9.8;
const double EPS = 1e-8;
namespace solver{
    int n;
    double v, gx, gy;
    double x1[50], x2[50], y1[50], y2[50];
 
    double calc_y(double vx, double vy, double x){
        double t = x / vx;
        return vy * t - g * t * t / 2;
    }
 
    int sign(double x){
        if(x > EPS) return 1;
        if(x < -EPS) return -1;
        return 0;
    }
     
    int comp(double lb, double ub, double x){
        if(x < lb + EPS) return -1;
        if(x > ub - EPS) return 1;
        return 0;
    }
 
    bool check(double bx, double by){
        double a = g * g / 4.0;
        double b = g * by - v * v;
        double c = bx * bx + by * by;
        double D = b * b - 4 * a * c;
        //printf("D:%f\n", D);
        if(D < 0) return false;
        for(int s = -1; s <= 1; s += 2){
            double tt = (-b + s * sqrt(D)) / (2 * a);
            //printf("tt:%f\n", tt);
            if(tt < 0) continue;
            double t = sqrt(tt);
            double vx = bx / t;
            double vy = (by + g * t * t / 2) / t;
            assert(sign(vx * vx + vy * vy - v * v) == 0);
            double fh = calc_y(vx, vy, gx);
            if(sign(fh - gy) < 0) continue;
            bool ok = true;
            for(int i = 0; i < n; i++){
                if(x1[i] >= gx) continue;
                if(comp(x1[i], x2[i], gx) == 0 && comp(y1[i], y2[i], gy) <= 0 && comp(y1[i], y2[i], fh) >= 0) {
                    ok = false;
                }
                int yl = comp(y1[i], y2[i], calc_y(vx, vy, x1[i]));
                int yr = comp(y1[i], y2[i], calc_y(vx, vy, x2[i]));
                int xh = comp(x1[i], x2[i], vx * vy / g);
                int yh = comp(y1[i], y2[i], calc_y(vx, vy, vx * vy / g));
                if(xh == 0 && yh >= 0 && yl <= 0) ok = false;
                if(yl * yr <= 0) ok = false;
            }
            if(ok) return true;
        }
        return false;
    }
    bool solve(){
        cin >> n;
        cin >> v >> gx >> gy;
        REP(i, n) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        REP(i, n) x2[i] = min(x2[i], gx);
        bool ans = false;
        ans |= check(gx, gy);
        REP(i, n){
            ans |= check(x1[i], y2[i]);
            ans |= check(x2[i], y2[i]);
        }
        return ans;
    }
}
 
int main(){
    cout << (solver::solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3204
import sys
readline = sys.stdin.readline
N = int(readline())
X = list(map(int, readline().split()))
X.sort()

INF = 10**9+7
ans = INF
for p in range(0, 102):
    res = 0
    for x in X:
        res += (p-x)**2
    ans = min(ans, res)
print(ans)

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

bool dblsame(double l, double r) {return abs(l-r) < abs(l) * 1e-10 + 1e-10;}

struct Vec{
 double x,y;
 Vec(double xx, double yy) : x(xx),y(yy) {}
 Vec operator+() const {return Vec(x,y);}
 Vec operator-() const {return Vec(-x,-y);}
 Vec operator+(const Vec& r) const {return Vec(x+r.x,y+r.y);}
 Vec operator-(const Vec& r) const {return Vec(x-r.x,y-r.y);}
 Vec operator*(double r) const {return Vec(x*r,y*r);}
 Vec operator/(double r) const {return Vec(x/r,y/r);}
 Vec& operator+=(const Vec& r) {*this=*this+r; return *this;}
 Vec& operator-=(const Vec& r) {*this=*this-r; return *this;}
 Vec& operator*=(double r) {*this=*this*r; return *this;}
 Vec& operator/=(double r) {*this=*this/r; return *this;}
 bool operator==(const Vec& r) const {return dblsame(x,r.x)&&dblsame(y,r.y);}
 bool operator!=(const Vec& r) const {return !(*this==r);} 
 double operator*(const Vec& r) const {return x*r.x+y*r.y;}
 double abs() const {return sqrt(x*x+y*y);}
 double abs_squared() const {return x*x+y*y;}
 double product(const Vec& r) const {return x*r.y-y*r.x;}
};

Vec InputVec(){
 double x,y; scanf("%lf%lf",&x,&y);
 return Vec(x,y);
}

void PrintVec(Vec tg){
 printf("%.10f %.10f",tg.x,tg.y);
}

int main() {
 Vec O = InputVec();
 Vec A = InputVec() - O;
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  Vec B = InputVec() - O;
  double p = A.product(B);
  if(dblsame(p,0.0)){
   double dot = A*B;
   if(dot<0.0) printf("ONLINE_BACK\n");
   else if(B.abs()>A.abs()) printf("ONLINE_FRONT\n");
   else printf("ON_SEGMENT\n");
  }
  else{
   if(p>0.0) printf("COUNTER_CLOCKWISE\n");
   else printf("CLOCKWISE\n");
  }
  printf("\n");
 }
 return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const


template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 N;
  cin >> N;
  dynarr<i64> x(N);
  rep(i,0,N) cin >> x[i];
  x[0] = 1;
  i64 cnt = 0;
  dynarr<i64> vec(N, 0);
  vec[0]++;
  rep(i,1,N) {
    vec[(cnt + 1) / 2]++;
    if(x[i] - x[i - 1] == 1) {
      cnt++;
    }
    else {
      x[i] = x[i - 1] + 2;
    }
  }
  i64 sum = 0;
  i64 mod = 1e9 + 7;
  i64 res = 1;
  rep(i,0,N) {
    sum += vec[i];
    res = (res * (sum - i)) % mod;
  }
  cout << res << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, M;

void solve() {
    cin >> N >> M;
    priority_queue<int> q;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        q.push(a);
    }
    for (int i = 0; i < M; ++i) {
        int x = q.top(); q.pop();
        q.push(x / 2);
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        int x = q.top(); q.pop();
        ans += x;
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 1276
n = int(input())
a = list(map(int, input().split()))
b = [0] * ((n + 1) // 2)
c = [0] * (n // 2)
for i in range(n):
    if i % 2 == 0:
        b[i // 2] = a[i]
    else:
        c[i // 2] = a[i]
if n % 2 == 0:
    c.reverse()
    s = c + b
else:
    b.reverse()
    s = b + c
print(" ".join(map(str, s)))

Measured memory_bytes: 30404
#include <bits/stdc++.h>
using namespace std;
vector <long long int> v;
int main() {
    long long int n, m,k;
    cin >> n >> m >> k;
    v.push_back(n);
    v.push_back(m);
    v.push_back(k);
    sort(v.begin(),v.end());
    long long int a = v[0]*v[1];

    cout << a*(v[2]%2);
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int n, x[8], y[8], p[8];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        p[i] = i;
    }

    double sum = 0, d;
    int cnt = 0;
    do {
        d = 0;
        for (int i = 0; i < n - 1; ++i) {
            d += sqrt(pow(x[p[i]] - x[p[i + 1]], 2) + pow(y[p[i]] - y[p[i + 1]], 2));
        }
        sum += d;
        cnt++;
    } while (next_permutation(p, p + n));

    cout << fixed << setprecision(10);
    cout << sum / cnt << endl;

    return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()
i = 'a'
while True:
    if i == 'a':
        if len(a)==0:
            print('A')
            break
        i = a[0]
        a = a[1:]
    elif i == 'b':
        if len(b)==0:
            print('B')
            break
        i = b[0]
        b = b[1:]
    else:
        if len(c)==0:
            print('C')
            break
        i = c[0]
        c = c[1:] 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  int N; cin >> N;
  ll V; cin >> V;
  vector<ll> a(N),b(N),c(N),d(N);
  rep(i,N) cin >> a[i];
  rep(i,N) cin >> b[i];
  rep(i,N) cin >> c[i];
  rep(i,N) cin >> d[i];
  
  vector<ll> ab(0),cd(0);
  rep(i,N) {
    rep(j,N) {
      ab.push_back(a[i] + b[j]);
      cd.push_back(c[i] + d[j]);
    }
  }
  sort(all(ab)); sort(all(cd));
  int Nab = ab.size();
  int Ncd = cd.size();
  
  ll ans = 0;
  rep(i,Nab) {
    if (ab[i] + cd[Ncd - 1] < V || ab[i] + cd[0] > V) continue;
    ans += (upper_bound(all(cd),V - ab[i]) - lower_bound(all(cd),V - ab[i]));
  }

  cout << ans << endl;
}


Measured memory_bytes: 18836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x=0;cin>>n;
  lvector A(n),B(n-1),ans(n,0);rep(i,n) {cin>>A[i];x^=A[i];}
  rep(i,n-1) cout<<(x^A[i])<<' ';cout<<(x^A[n-1])<<endl;
  return 0;
}

Measured memory_bytes: 7852
#include <stdio.h>

int main(void)
{
	int r, c;
	int i, j;
	int num;
	int a[101][101]={};
	scanf("%d%d", &r, &c);
	for(i=0; i<r; i++) {
		for(j=0; j<c; j++) {
			scanf("%d", &num);
			a[i][j]+=num;
		}
	}
	
	/*??????????¨????????±???????*/
	for(i=0; i<r; i++) {
		for(j=0; j<c; j++)
			a[i][c]+=a[i][j];
	}
	
	/*??????????¨????????±???????*/
	for(j=0; j<c+1; j++) {
		for(i=0; i<r; i++)
			a[r][j]+=a[i][j];
	}
	
	for(i=0; i<r+1; i++) {
		for(j=0; j<c+1; j++) {
			printf("%d", a[i][j]);
			if(j<c) putchar(' ');
			if(j==c) putchar('\n');
		}
	}
	return 0;
}


Measured memory_bytes: 652
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy


def main():
    N = int(input())
    A = list(map(int, input().split()))
    sortedA = list(reversed(sorted(A)))
    ans = 0
    ans += sortedA[0]
    deq = deque()
    deq.append([sortedA[0], sortedA[1]])
    deq.append([sortedA[1], sortedA[0]])

    for i in range(2, N):
        tmp = deq.popleft()
        ans += min(tmp)
        deq.append([tmp[0], sortedA[i]])
        deq.append([sortedA[i], tmp[1]])

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  a -= b;
  cout << max(0, c - a) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> a >> b;
  cout << ((b-a)%2 ? "Borys" : "Alice") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=400000+19;

char s[N];
ll fib[100];
int Fail[N];
int n,flag,a,b,m;
ll l,r,ca,cb;
vector<ll> V1,V2;

void getfail(){
	Fail[1]=0;
	for (int i=2,j=0;i<=n;i++){
		while (j&&s[j+1]!=s[i]) j=Fail[j];
		if (s[j+1]==s[i]) j++;
		Fail[i]=j;
	}
}
vector<ll> Work(ll m){
	vector<ll> ans;
	ans.resize(26);
	ca=0;cb=0;
	if (flag){
		For(i,1,n+1) ans[s[i]-'a']+=m/n;
		For(i,1,m%n+1) ans[s[i]-'a']++;
	} else{
		while (m>n){
			int i=1;
			while (b*fib[i+1]+a*fib[i+2]<=m) i++;
			m-=b*fib[i]+a*fib[i+1];
			ca+=fib[i+1];
			cb+=fib[i];
		}
		For(i,1,m+1) ans[s[i]-'a']++;
		For(i,1,a+1) ans[s[i]-'a']+=ca;
		For(i,a+1,n+1) ans[s[i]-'a']+=cb;
	}
	return ans;
}

int main(){
	fib[0]=0;
	fib[1]=1;
	For(i,2,100) fib[i]=fib[i-1]+fib[i-2];
	scanf("%s",s+1);
	n=strlen(s+1);
	cin>>l>>r;
	getfail();
	for (m=Fail[n];m&&m>=(n+1)/2;m=Fail[m]);
	n-=m;
	m=Fail[n];
	if (m==0) flag=1;
	if (n%2==0){
		int chk=1;
		For(i,0,n/2) if (s[i+1]!=s[n/2+i+1]) chk=0;
		if (chk) flag=1;
	}
	b=m;
	a=n-m;
	V1=Work(r);
	V2=Work(l-1);
	For(i,0,26) printf("%lld ",V1[i]-V2[i]);
	puts("");
}

Measured memory_bytes: 1280
(() => {

    var lines = [];

    require('readline').createInterface({
        input: process.stdin,
    }).on('line', (line) => {
        lines.push(Number(line));
    });

    process.stdin.on("end", () => {
        console.log(lines.filter(isPrime).length);
    });

    const isPrime = function(x){
        if(x == 2){
            return true;
        }

        if(x < 2 || (x % 2) === 0){
            return false;
        }

        const sqrt_x = Math.sqrt(x);
        for(let i = 3; i <= sqrt_x; i+=2){
            if(x % i === 0){
                return false;
            }
        }
        return true;
    }


})();


Measured memory_bytes: 19496
#include<stdio.h>

int main(void)
{
	int hei1, wid1, hei2, wid2;
	int area1, area2;

	scanf("%d %d %d %d", &hei1, &wid1, &hei2, &wid2);

	area1 = hei1*wid1;
	area2 = hei2*wid2;

	if (area1 > area2)printf("%d", area1);
	else printf("%d", area2);

	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a*b//(gcd(a, b))

def num(n, c, d):
    dc = n//c
    dd = n//d
    dcd = n//(lcm(c, d))
    return n-dc-dd+dcd

a, b, c, d = map(int, input().split())
print(num(b, c, d) - num(a-1, c, d))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i, b, e)    for (int i = (int)b; i < (int)e; i++)
#define forr(i, b, e)    for (int i = (int)b; i < (int)e; i++)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);
#define tam 298764
int cant[tam];
int arr[tam];
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    ll tot=0;
    forr(i,0,n)
    {
        cin>>arr[i];
        tot+=cant[arr[i]];
        cant[arr[i]]++;
    }
    forr(i,0,n)
    {
        cout<<tot-(cant[arr[i]]-1)<<" ";
    }
}
// PLUS ULTRA!


Measured memory_bytes: 3712
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef unsigned long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}



int main(){
int N; cin >> N;
vector<int> L(N);
rep(i,N) cin >> L[i];
sort(all(L));
ll cnt = 0;
rep(i,N-2){
    for(int j = i+1; j < N -1; j++){
        for(int k= j+1; k < N; k++){
            if(L[i] + L[j] > L[k]){
                cnt++;
            }
            else break;
    }
}
}
cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,M;
    cin>>N>>M;
    vector<bool> like(M,true);
    rep(i,N){
        int K;
        cin>>K;
        vector<int> now(M,1);
        rep(j,K){
            int A;
            cin>>A;
            --A;
            now.at(A)=0;
        }
        rep(j,M){
            if(now.at(j))like.at(j)=false;
        }
    }
    int cnt=0;
    rep(i,M){
        if(like.at(i))cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int64_t dpow(int64_t a, int64_t b, int64_t MOD) {
  if (b == 0) {
    return 1;
  }
  if (b % 2 == 0) {
    return dpow(a * a % MOD, b / 2, MOD);
  } else {
    return dpow(a, b - 1, MOD) * a % MOD;
  }
}

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

  vector<int> dp(N);
  dp[0] = 0;
  rep(i, N - 1) {
    int cnt = bitset<32>(i + 1).count();
    dp[i + 1] = dp[(i + 1) % cnt] + 1;
  }

  string x;
  cin >> x;

  int pc = 0;
  rep(i, x.size()) {
    if (x[i] == '1') {
      pc++;
    }
  }

  int rem1 = 0, rem2 = 0;
  rep(i, N) {
    int c = x[i] - '0';
    rem1 = rem1 * 2 + c;
    rem2 = rem2 * 2 + c;

    // cerr << "\t" << i << " rem1: " << rem1 << endl;

    rem1 %= pc + 1;
    if (pc - 1 > 0) {
      rem2 %= pc - 1;
    }
  }

  rep(i, N) {
    int next;
    if (x[i] == '0') {
      next = (rem1 + dpow(2, N - i - 1, pc + 1)) % (pc + 1);
    } else {
      if (pc - 1 == 0) {
        cout << 0 << "\n";
        continue;
      } else {
        next = (rem2 - dpow(2, N - i - 1, pc - 1) + pc - 1) % (pc - 1);
      }
    }
    // cerr << i << " next: " << next << "\n";

    cout << 1 + dp[next] << "\n";
  }

  // cerr << rem1 << " " << rem2 << " " << pc << "\n";
  // rep(i, N) { cerr << i << " " << dp[i] << "\n"; }

  return 0;
}

Measured memory_bytes: 4264
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<LL> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL mod = 1000000007;
const LL LINF = 1e18 + 10;
const LL MAX = 1e5 + 1;

int n;
int m;
VI g[MAX];
int ye = 0;
int path[MAX];
char used[MAX];

void dfs(int v)
{
	used[v] = 1;
	path[ye++] = v;
	for (auto i : g[v])
		if (used[i] == 0)
		{
			dfs(i);
			return;
		}
}

bool solve(int v)
{
	ye = 0;
	memset(used, 0, sizeof(used));
	used[v] = 1;
	if (SZ(g[v]) == 1)
	{
		path[ye++] = v;
		dfs(g[v][0]);
		return 1;
	}

	path[ye++] = v;
	dfs(g[v][0]);
	for (auto i : g[v])
		if (used[i] == 0)
			return 0;

	return 1;
}

int cmp(int x, int y)
{
	return SZ(g[x]) < SZ(g[y]);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n >> m;
	int u, v;
	FOR(i, 0, m)
	{
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	if (n == 2)
	{
		cout << 2 << endl << 1 << " " << 2;
		return 0;
	}

	bool x;
	VI all;
	FOR(i, 0, n)
		all.push_back(i);

	sort(ALL(all), cmp);
	srand(time(NULL));
	int best = 0;
	while (1)
	{
		x = solve(all[best]);
		if (x)
			break;

		best++;
	}

	cout << ye << endl;
	FOR(i, 0, ye)
		cout << path[i] + 1 << " ";
	cin >> n;
	return 0;
}

Measured memory_bytes: 7668
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, cnt[40];
bool can[40];
signed main() {
	cin >> n;
	rep(i, n) {
		int a; cin >> a;
		bool flag = false;
		rep(j, 32) {
			if (!flag && (a >> j & 1)) {
				can[j] = 1; flag = 1;
			}
			if (a >> j & 1)cnt[j]++;
		}
	}
	int ans = 0;
	for (int i = 32; i >= 0; i--) {
		if (cnt[i] % 2 == 0)continue;
		if (cnt[i] % 2 && !can[i]) {
			cout << -1 << endl; return 0;
		}
		rep(j, i)cnt[j]++;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
leng = len(S)
ans = 0
for i in range(leng//2):
    if S[i]!=S[-i-1]:
        ans += 1
print(ans)

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

int main()
{
    int a, b;
    cin >> a >> b;
    
    cout << a * b << ' ' << (a + b) * 2 << endl;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  ll s;
  cin >> s;
  if(s==1000000000000000000){
    cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000 << endl;
    return 0;
  }
  cout << 0 << " " << 0 << " ";
  ll a=sqrt(s);
  a++;
  ll b=a*a-s;
  cout << a << " " << b  << " " <<  1 << " " << a << endl;
}


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

int main()
{
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k % 2 == 0)
  {
    if (abs(a - b) > pow(10, 18))
    {
      cout << "Unfair" << endl;
    }
    else
    {
      cout << a - b << endl;
    }
  }
  else
  {
    if (abs(a - b) > pow(10, 18))
    {
      cout << "Unfair" << endl;
    }
    else
    {
      cout << b - a << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k,x;
    cin >> k >> x;
    int minnum = max(-1000000,x - (k-1));
    int maxnum = min(1000000, x + (k-1));

    for (int i = minnum; i < maxnum ; i++)
    {
        cout << i << " ";
    }
    cout << maxnum << 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 N = sc.nextInt();
		 int count = 0;
		 int P[] = new int[N];
		 int Pj = 0;
		 for(int i=0; i<N; i++) {
			P[i]= sc.nextInt();
			Pj = P[0];
		 }
		 //最初に[0]番目をみてカウントする
		 //その後前の数と次の数を比べるようにし条件を満たせばカウントする
		 for(int i=0; i<N; i++) {
			if(P[i]<=Pj) {
				count++;
				Pj = P[i];
				}
		 }
		 System.out.println(count);
    }
}

Measured memory_bytes: 60456
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <random>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b)*c / 2 << endl;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long a,b;
    cin>>a>>b;
    if(a>=b)
    {
        while(a)
        {
            cout<<b;
            a--;
        }
    }
    else
    {
        while(b)
        {
            cout<<a;
            b--;
        }
    }
    return 0;
}


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

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

    set<string> st;

    rep(i, n) {
        string s;
        cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 19060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	a %= MOD;
}

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	cout << ((min(a,b)<=c&&c<=max(a,b))?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let c:Vec<char> = read::<String>().chars().collect();
    let ans = match c[0] {
        'A' => 'T',
        'T' => 'A',
        'C' => 'G',
        'G' => 'C',
        _ => panic!(),
    };
    println!("{}",ans);
}

Measured memory_bytes: 4352
from random import randint
import sys
input = sys.stdin.readline
INF = 9223372036854775808


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    コンテストi 0-indexed
    d 0-indexed
    """
    score = 0
    last = [0]*26  # コンテストiを前回開催した日
    for d, t in enumerate(T):
        last[t] = d + 1
        for i in range(26):
            score -= (d + 1 - last[i]) * C[i]
        score += S[d][t]
    return score


def update_score(D, C, S, T, score, ct, ci):
    """
    ct日目のコンテストをコンテストciに変更する
    スコアを差分更新する

    ct: change t 変更日 0-indexed
    ci: change i 変更コンテスト 0-indexed
    """
    last = [0]*26  # コンテストiを前回開催した日
    for d in range(ct):
        last[T[d]] = d + 1
    prei = T[ct]  # 変更前に開催する予定だったコンテストi
    score -= S[ct][prei]
    score += S[ct][ci]
    for d in range(ct, D):
        if d != ct and T[d] == prei:
            break
        score += C[prei]*(d + 1 - ct - 1)
        score -= C[prei]*(d + 1 - last[prei])
    for d in range(ct, D):
        if d != ct and T[d] == ci:
            break
        score += C[ci]*(d + 1 - last[ci])
        score -= C[ci]*(d + 1 - ct - 1)
    T[ct] = ci
    return score, T


def local_search():
    pass


def main(D, C, S):
    T = []
    for d in range(D):
        # d日目終了時点で満足度が一番高くなるようなコンテストiを開催する
        max_score = -INF
        best_i = 1
        for i in range(26):
            T.append(i)
            score = calc_score(D, C, S, T)
            if max_score < score:
                max_score = score
                best_i = i
            T.pop()
        T.append(best_i)
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = [int(input())-1 for i in range(D)]
    M = int(input())
    DQ = [[int(i) for i in input().split()] for j in range(M)]
    score = calc_score(D, C, S, T)
    for d, q in DQ:
        score, T = update_score(D, C, S, T, score, d-1, q-1)
        print(score)


Measured memory_bytes: 97596
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> S(H); cin >> S;
    vector<vector<int>> L(H, vector<int>(W)), R(H, vector<int>(W)), D(H, vector<int>(W)), U(H, vector<int>(W));
    rep(i,H) rep(j,W){
        if(S[i][j] == '#') continue;
        else if(j == 0) L[i][j] = 1;
        else L[i][j] = L[i][j-1] + 1;
    }
    rep(j,W) rep(i,H){
        if(S[i][j] == '#') continue;
        else if(i == 0) U[i][j] = 1;
        else U[i][j] = U[i-1][j] + 1;
    }
    rep(i,H) for(int j = W-1; j >= 0; j--){
        if(S[i][j] == '#') continue;
        else if(j == W-1) R[i][j] = 1;
        else R[i][j] = R[i][j+1] + 1;
    }
    rep(j,W) for(int i = H-1; i >= 0; i--){
        if(S[i][j] == '#') continue;
        else if(i == H-1) D[i][j] = 1;
        else D[i][j] = D[i+1][j] + 1;
    }
    int ans = 0;
    rep(i,H) rep(j,W){
        if(S[i][j] == '#') continue;
        else ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 67200