akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll        = long long;
using ld        = long double;
using vl        = vector<ll>;
using vd        = vector<ld>;
using vs        = vector<string>;
using vb        = vector<bool>;
using vvl       = vector<vector<ll>>;
using vvd       = vector<vector<ld>>;
using vvs       = vector<vector<string>>;
using vvb       = vector<vector<bool>>;
using pll       = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T& a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T& a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N;
    cin >> N;
    vl L(N);
    REP(i,N)cin >> L[i];
    sort(ALL(L));
    ll ans = 0;
    REP(i,N){
        for(int l = i+1;l < N;l++){
            ans += N - (L.end() - lower_bound(ALL(L),L[i] + L[l])) - l - 1;
        }
    }
    cout << ans << "\n";
}


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

using namespace std;

int main(){
    int x,y,z; cin >> x >> y >> z;
    int count = 0;
    while(y * count + z * (count+1) < x)
        count++;
    
    if(y * count + z * (count+1) > x)
        count--;
    
    cout << count << endl;
}


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;

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;}
ll f(ll x, int c, int d){
  return x-x/c-x/d+x/(lcm(c,d));
}

int main() {
  ll a, b;
  int c, d;
  cin >> a >> b >> c >> d;
  ll ans = f(b,c,d)-f(a-1,c,d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author CompuWare
 */

#include <bits/stdc++.h>

using namespace std;

class ERedScarf {
public:
    void solve(istream &in, ostream &out) {
        int c;
        in >> c;
        vector<int> v(c);
        int64_t res = 0;
        bool f = 1;
        for (int i = 0; i < c; i++) {
            in >> v[i];
            if (f) {
                res = v[i];
                f = 0;
            }
            else res ^= v[i];
        }
        for (int i = 0; i < c; i++) {
            out << abs((res ^ ~v[i]) + 1) << " ";
        }
    }
};


int main() {
    ERedScarf solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 4024
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
constexpr long long int MOD = 1000000007;
long long int power(const long long int base, const int exp) {
	switch (exp) {
	case 0: return 1LL;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp >> 1) * power(base, exp & 1) % MOD;
	}
}
int main() {
	int k; std::string str; std::cin >> k >> str;
	std::vector<long long int> factorial(3000001, 1), div(3000001, 1), inverse(3000001, 1);
	for (auto i = 2; i < factorial.size(); ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		div[i] = (MOD - MOD / i) * div[MOD % i] % MOD;
		inverse[i] = div[i] * inverse[i - 1] % MOD;
	}
	const auto combination = [&factorial, &inverse](const int n, const int r) {return factorial[n] * inverse[r] % MOD * inverse[n - r] % MOD; };
	long long int result{ 0 };
	const auto len = k;
	for (auto i = 0; i <= k; ++i) {
		result = (result + combination(i + str.size() - 1, str.size() - 1) * power(25, i) % MOD * power(26, len - i) % MOD) % MOD;
	}
	std::cout << result << '\n';
}

Measured memory_bytes: 74720
N, X, Y = gets.split.map(&:to_i)

m = ->(a, b){a > b ? b : a}
d = ->(x, y){m[y - x, (X - x).abs + 1 + (y - Y).abs]}
puts [*1 .. N].combination(2).each_with_object(Array.new(N, 0)){|(x, y), a| a[d[x, y]] += 1}.drop(1)

Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int cnt = 0;
	bool ok = false;
	rep(i,n){
		int a, b;
		cin >> a >> b;
		if(a == b) ++cnt;
		else cnt = 0;
		if(cnt == 3) ok = true;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int i = Integer.parseInt(br.readLine());

		if(i%2 == 0)System.out.println(i);
		else System.out.println(i*2);



	}
}


Measured memory_bytes: 22612
#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>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s;
  cin >> s;
  bool N=false;
  bool S=false;
  bool W=false;
  bool E=false;
  rep(i,s.size()){
    if(s[i]=='N')N=true;
    else if(s[i]=='S')S=true;
    else if(s[i]=='E')E=true;
    else W=true;
  }
  if((N && S && W && E)||(N && S && !W && !E)||(!N && !S && W && E))cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <cmath>
#include <stack>
#include <algorithm>
#include <queue>
#include <iterator>
#include <limits>
#define PI 3.1415926535
#include <sstream>
#define MAX 100
#define swap(a,b,t) (t=a,a=b,b=t)
using namespace std;

int main()
        { 
        int N,i,c=0;
        cin>>N;
        int cost[N],val[N];
        for(i=0;i<N;i++)
        cin>>val[i];
        for(i=0;i<N;i++)
        cin>>cost[i];
        for(i=0;i<N;i++)
        {
        if(val[i]>cost[i])
        c+=val[i]-cost[i];
        }
        cout<<c;
        //system("pause");
        }
        



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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{

    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<int>());

    int a=0,b=0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            a += v[i];
        }else{
            b += v[i];
        }
    }

    cout << a-b << endl;

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector


// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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 (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  bool zero = false;
  rep (i, n) {
    cin >> a[i];
    if (a[i] == 0) zero = true;
  }

  ll ans = 1;
  if (!zero) {
    for (int i = 0; i < n; i++) {
      if (1000000000000000000 / ans < a[i]) {
	cout << -1 << endl;
	return 0;
      } else {
	ans *= a[i];
      }
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3996
using System;
namespace aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
			string[] input;
			while((input = Console.ReadLine().Split())[0] != "0"){
				DateTime date = new DateTime(2004,int.Parse(input[0]), int.Parse(input[1]));
				Console.WriteLine(date.DayOfWeek);
			}
        }
    }
}

Measured memory_bytes: 5820
#include<bits/stdc++.h>
using namespace std;
const int N=55;
int n,tot,d[N],vis[N];
vector<int>v;
int main()
{
    scanf("%d",&n);
    vis[0]++;
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);vis[x]++;
    }
    for(int i=0;i<12;i++)
        if(vis[i]>=3){printf("0\n");return 0;}
    else
    {
        if(vis[i]==2) d[++tot]=i,d[++tot]=24-i;
        else if(vis[i]) v.push_back(i);
    }
    if(vis[12]>=2){printf("0\n");return 0;}
    else if(vis[12]) d[++tot]=12;
    int up=1<<v.size();
    int ans=0;
    for(int i=0;i<up;i++)
    {
        int sum=tot;
        for(int j=0;j<v.size();j++)
            if(i>>j&1)
            d[++sum]=24-v[j];
            else d[++sum]=v[j];
        int res=24;
        for(int j=1;j<=sum;j++)
            for(int k=j+1;k<=sum;k++)
        {
            int p=abs(d[k]-d[j]);
            res=min(res,min(p,24-p));
        }
        ans=max(ans,res);
    }
    printf("%d\n",ans);
}


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

int main()
{
  int a, b, c;
  vector<int> arr(3);
  cin>>arr[0]>>arr[1]>>arr[2];
  sort(arr.begin(), arr.end());
  if(arr[0] == 5 && arr[1] == 5 && arr[2] == 7)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

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

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


double solution(vector<int>& x, vector<int>& y)
{
    int N = x.size();

    auto square_dist = [&](double x_c, double y_c){  // 円の中心を選んだときの最遠点との距離
        double ret = 0;
        REP(i, N) ret = max(ret, pow(x[i]-x_c, 2) + pow(y[i]-y_c, 2));
        return ret;
    };
    auto g = [&](double x_c){  // 円の中心の x 座標を選んだときの最遠点との距離
        double y_l = 0, y_r = 1e+3;
        REP(_, 80){  
            double c_l = (2*y_l+y_r)/3;
            double c_r = (y_l+2*y_r)/3;
            if(square_dist(x_c, c_l) > square_dist(x_c, c_r)) y_l = c_l;
            else y_r = c_r;
        }
        return square_dist(x_c, y_l);
    };

    double x_l = 0, x_r = 1e+3;
    REP(_, 80){  // double の探索では while 条件より回数を決めて for を回した方がエラーを避けやすい
        double c_l = (2*x_l+x_r)/3;
        double c_r = (x_l+2*x_r)/3;
        if(g(c_l) > g(c_r)) x_l = c_l;
        else x_r = c_r;
    }
    return g(x_l);
}

int main()
{
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    cout << fixed << setprecision(7) << sqrt(solution(x, y)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n; 
    std::vector<ll> a(n); rep(i,n) cin >> a[i];

    // 昇順
    std::deque<ll> dq;

    rep(i,n){
        int index = std::lower_bound(dq.begin(), dq.end(), a[i]) - dq.begin();

        if(index==0){
            dq.push_front(a[i]);
        } else {
            dq[index-1] = a[i];
        }
    }

    cout << dq.size() << endl;

    return 0;
}

Measured memory_bytes: 1920
def main():
    N = input()
    r = 0
    x = 0
    n = len(N)
    p = 0
    o = 0
    for i in N:
        j = int(i)
        np = min(p + j, o + j)
        if o != 0:
            no = min(o + 9 - j, p + 11 - j)
        else:
            no = p + 11 - j
        p = np
        o = no
    print(min(p,o))
main()


Measured memory_bytes: 5492
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

N = int(input())
A = list(map(int, input().split()))

minimum_score = float('inf')
for i in range(-100, 101):
    score = 0
    for a in A:
        score += (a - i) ** 2
    minimum_score = min(minimum_score, score)
print(minimum_score)


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

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	int ans = 1001001001;
	
	rep(i, n) {
		int next;
		if(i < n-1) {
			next = a[i+1];
		} else {
			next = k + a[0];
		}
		int now = k - (next - a[i]);
		ans = min(now, ans);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=1e9+7;
const int N=500000;


main(){
    string s,t;
    cin>>s>>t;
    map<int,int> mp;
    rep(i,s.size()){
        char e=s[i];
        if(mp[e]==0)mp[e]=t[i];
        else{
            if(t[i]!=mp[e]){
                cout<<"No";return 0;
            }
        }
    }
    map<int,int> m;
    for(auto e:mp){
        if(m[e.second]){
            cout<<"No";return 0;
        }
        else m[e.second]=1;
    }
    cout<<"Yes";return  0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> len(n);
  for(int i=0;i<n;i++){
	cin >> len.at(i);
  }
  sort( len.begin(),len.end() );
  int ans=0;
  for(int i=0;i<k;i++){
	ans += len.at( len.size() - i - 1 );
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N, M, W, T = map(int, readline().split())
    cur = 0
    n_map = {}
    ws = [0]*M; P = [0]*M
    for i in range(M):
        s, v, p = readline().split()
        n_map[s] = i
        ws[i] = int(v)
        P[i] = int(p)

    ts = [[] for i in range(N)]
    X = [0]*N; Y = [0]*N
    for i in range(N):
        l, x, y = map(int, readline().split())
        X[i] = x; Y[i] = y
        r = 0
        t = ts[i]
        for j in range(l):
            r, q = readline().split(); q = int(q)
            k = n_map[r]
            if P[k] <= q:
                continue
            t.append((k, P[k] - q))

    E = [[0]*N for i in range(N)]
    E1 = [0]*N
    for i in range(N):
        for j in range(i):
            E[i][j] = E[j][i] = abs(X[i] - X[j]) + abs(Y[i] - Y[j])
        E1[i] = abs(X[i]) + abs(Y[i])
    INF = 10**18
    SN = 1 << N
    D0 = [[0]*N for i in range(SN)]

    dp1 = [0]*(T+1)
    for s in range(1, SN):
        d1 = INF
        for i in range(N):
            bi = (1 << i)
            r = INF
            if s & bi:
                si = s ^ bi
                if si == 0:
                    r = E1[i]
                else:
                    for j in range(N):
                        if i == j or s & (1 << j) == 0:
                            continue
                        r = min(r, D0[si][j] + E[j][i])
            D0[s][i] = r
            d1 = min(d1, r + E1[i])

        vs = [-1]*M
        for i in range(N):
            if s & (1 << i):
                for k, d in ts[i]:
                    vs[k] = max(vs[k], d)
        dp0 = [0]*(W+1)
        for i in range(M):
            if vs[i] == -1:
                continue
            w = ws[i]; v = vs[i]
            for j in range(W-w+1):
                dp0[j + w] = max(dp0[j] + v, dp0[j + w])
        v1 = max(dp0)

        for j in range(T-d1+1):
            dp1[j + d1] = max(dp1[j] + v1, dp1[j + d1])
    write("%d\n" % max(dp1))
solve()


Measured memory_bytes: 6624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int s,w;
  cin>>s>>w;
  cout<<(w>=s?"unsafe":"safe")<<endl;
  return 0;
}


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

long long getrange(long long a) {
	if (a % 4 == 0) return a;
	if (a % 4 == 1) return 1;
	if (a % 4 == 2) return a+1;
	return 0;
}

int main() {

	long long a, b;
	cin >> a >> b;
	cout << (getrange(b) ^ getrange(a-1));
	
}


Measured memory_bytes: 256
S = input()
nQ = int(input())

Ques = []
nReverse = 0
nAddFront= 0
nAddBack = 0
for i in range(nQ):
  line = input().split()
  if int(line[0]) == 1:
    nReverse += 1
    Ques.append([int(line[0])])
  else:
    if int(line[1]) == 1:
      if nReverse % 2 == 0:
        nAddFront += 1
      else:
        nAddBack  += 1
    else:
      if nReverse % 2 == 0:
        nAddBack += 1
      else:
        nAddFront  += 1      
    Ques.append([int(line[0]),int(line[1]),line[2]])

#print(nAddFront,nAddBack)
SS = [-1] * (nAddFront + len(S) + nAddBack)
for i in range(len(S)):
   SS[nAddFront + i] = S[i]

left = nAddFront -1
right= nAddFront + len(S)

nReverseLoc = 0
for iQ in Ques:
   if iQ[0] == 1:
      nReverseLoc += 1
   if iQ[0] == 2:
    if int(iQ[1]) == 1:
      if nReverseLoc % 2 == 0:
        #nAddFront += 1
        SS[left] = iQ[2]
        left -= 1
      else:
        SS[right] = iQ[2]
        right += 1
    else:
      if nReverseLoc % 2 == 0:
        SS[right] = iQ[2]
        right += 1
      else:
        SS[left] = iQ[2]
        left  -= 1 

S = "".join(SS)
if nReverse % 2 == 1:
  S = S[::-1]
  
print(S)

Measured memory_bytes: 119896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        int result = (N * (N-1) / 2) + (M * (M-1) / 2);
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
n = int(input())
l = list(map(int,input().split()))
l1 = [0,0]
from collections import Counter
c = Counter(l)
for i in c.items():
  if i[1]>=2 :
    l1.append(i[0])
  if i[1]>=4 :
    l1.append(i[0])
l1.sort()
print(l1[-1]*l1[-2])

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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int num = (100 * r) + (10 * g) + b ; 
  if (num % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl ;
  }
}

Measured memory_bytes: 256
#include<sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstdlib> 
#include <iomanip> 
#include<numeric>
#include<set>
#include<bitset>
#include<cstring>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<vector>
#include<ctype.h>
#include <cctype>
#include <cstring>
#include <cstdio>
using namespace std;
int arr[200];
int main() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7)
		cout << "YES" << endl;
	else if (a == 5 && b == 7 && c == 5)
		cout << "YES" << endl;
	else if (a == 7 && b == 5 && c == 5)
		cout << "YES" << endl;
	else cout << "NO" << endl;

	system("pause");
		 //return 0;

}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

ll modpow(ll A, ll N) {
    ll RET = 1;
    // 例えば3=101(2)なので、下位bitから順に1ならa倍する
    while (N) {
        if (N & 1) RET = RET * A % mod;
        A = A * A % mod;
        N >>= 1;
    }
    return RET;
}

int main() {
    ll n,k;
    cin >> n >> k;
    ll c1[k];
    ll c2[k];
    c1[0] = n-k+1;
    c2[0] = 1;
    rep(i,k-1) {
        c1[i+1] = c1[i] * (n-k-i) % mod * modpow(i+2, mod-2) % mod;
        c2[i+1] = c2[i] * (k-1-i) % mod * modpow(i+1, mod-2) % mod;
    }
    rep(i,k) cout << c1[i] * c2[i] % mod << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>

using namespace std;


int calc_gcd(int num1, int num2) {
  int larger = max(num1, num2);
  int smaller = min(num1, num2);

  int remainder = larger % smaller;

  if(remainder == 0) {
    return smaller;
  }

  return calc_gcd(smaller, remainder);
}

int main() {
  int num1, num2;

  cin >> num1 >> num2;

  cout << calc_gcd(num1, num2) << endl;
}



Measured memory_bytes: 3128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const ll MOD = (ll)1000000007;//10^9+7
const ll INF2 = (ll)100000000000000000;//10^18


int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b || b==c || a==c){
        if(a==b && b==c){
            cout << 1 <<endl;
            return 0;
        }
        cout<<2<<endl;
    }else{
        cout<<3<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (9223372036854775807)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<ll> x(n), y(n);
    vector<ll> xx(n), yy(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        xx[i] = x[i];
        yy[i] = y[i];
    }
    sort(ALL(xx));
    sort(ALL(yy));

    ll ans = LLINF;

    for (int ix = 0; ix < n; ix++)
    {
        for (int jx = ix + 1; jx < n; jx++)
        {
            for (int iy = 0; iy < n; iy++)
            {
                for (int jy = iy + 1; jy < n; jy++)
                {
                    int cnt = 0;
                    ll mx[2], mn[2];
                    mn[0] = xx[ix];
                    mx[0] = xx[jx];
                    mn[1] = yy[iy];
                    mx[1] = yy[jy];
                    for (int i = 0; i < n; i++)
                    {
                        if (mn[0] <= x[i] && x[i] <= mx[0] && mn[1] <= y[i] && y[i] <= mx[1])
                        {
                            cnt++;
                        }
                    }
                    if (cnt >= k)
                    {
                        chmin(ans, (mx[0] - mn[0]) * (mx[1] - mn[1]));
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {

	string s;
	cin >> s;
	int len = s.length();



	ll sum = 0;
	ll cnt1 = 0;
	ll cnt2 = 0;

	for (int i = 0;i < len - 1;i++) {

		if (s[i] == '<') {
			cnt1++;
		}
		else {
			cnt2++;
		}
		
		if (s[i] == '>' && s[i + 1] == '<') {
			
			if (cnt1 < cnt2) {
				swap(cnt1, cnt2);
			}

			sum += ((cnt1 + 1)*cnt1) / 2;
			sum += ((cnt2 - 1)*cnt2) / 2;
			cnt1 = cnt2 = 0;
			continue;
		}

	}
	if (s[len-1] == '<') {
		cnt1++;
	}
	else {
		cnt2++;
	}
	if (cnt1 < cnt2) {
		swap(cnt1, cnt2);
	}

	sum += ((cnt1 + 1)*cnt1) / 2;
	sum += ((cnt2 - 1)*cnt2) / 2;


	cout << sum << endl;

}

Measured memory_bytes: 900
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
N = int(input())
ans = num2alpha(N)

print(ans.lower())

Measured memory_bytes: 9140
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

S = input()
print(S.replace('1', 'a').replace('9', '1').replace('a', '9'))


Measured memory_bytes: 13556
#include<cstdio>
using namespace std;
#define N 100500
long long v[N],su[N],n,s,as,l,r,tp[N],ct;
int main()
{
	scanf("%lld%lld",&n,&s);l=1,r=n;ct=n;
	for(int i=1;i<=n;i++)scanf("%lld%lld",&v[i],&su[i]);
	while(l<r)
	{
		if(s<v[l])su[l]=1e16;if(s>v[r])su[r]=1e16;
		if(su[l]>=su[r])su[l]+=su[r],tp[ct--]=v[r],r--;else su[r]+=su[l],tp[ct--]=v[l],l++;
	}
	tp[1]=v[l];tp[0]=s;
	for(int i=1;i<=n;i++)as+=tp[i]>tp[i-1]?tp[i]-tp[i-1]:tp[i-1]-tp[i];
	printf("%lld\n",as);
}//

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define For(i, a, b) for(int i=(a); i<(b); i++)
#define rFor(i, a, b) for(int i=(a)-1; i>=(b); i--)
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
using namespace std;

int main(){
  int h, w; cin >> h >> w;
  int c[10][10]; rep(i, 10)rep(j, 10) cin >> c[i][j];
  int cnt[10];
  rep(i, 10) cnt[i] = 0;
  rep(i, h)rep(j, w){
    int a; cin >> a;
    if(a >= 0) cnt[a]++;
  }
  rep(k, 10)rep(i, 10)rep(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  int ans = 0;
  rep(i, 10) ans += cnt[i] * c[i][1];
  cout << ans << endl;
}

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

ll MOD=1000000007;

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    vector<ll> sum(n);
    sum[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        sum[i]=(a[i]+sum[i+1])%MOD;
    }
    ll ans=0;
    rep(i,n-1)ans=(ans+(a[i]*sum[i+1])%MOD)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,cnt=0,ans=0;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  rep(i,n-1) {
    if(a[i]==a[i+1]) cnt++;
    else {
      ans+=(cnt+1)/2;
      cnt=0;
    }
  }
  ans+=(cnt+1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
A = [int(input()) for i in range(n)]
B = A[:]
B.sort()

a_max = B[len(B)-1]
a_next = B[len(B)-2]

for i in range(n):
    if A[i] != a_max:
        print(a_max)
    else:
        print(a_next)


Measured memory_bytes: 14132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
 
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}
 
map<ll,ll> Pf(ll n) {
  map<ll,ll> rep ;
  for (ll i = 2 ; i*i <=n ; i++){
    if (n%i) continue;
    while( n%i == 0 ){
      rep[i]++;
      n /= i ;
    }
  }
    if(n != 1 ) rep[n] = 1 ;
  return rep ;
}
 
int main() {
  ll A , B ;
  cin >> A >> B ;
  ll C = gcd(B,A) ;
  //cout << C << endl ;  
  auto D = Pf(C) ;
  //for(auto f : Pf(C) ) cout << f.first <<" "<< f.second << endl;
  ll E = D.size();
  cout << E+1 << endl ;
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, a, b, c, t;

// A*B
vector<vector<int> > mul(vector<vector<int> > &A, vector<vector<int> > &B) {
	vector<vector<int> > C(A.size(), vector<int>(B[0].size()));
	for (int i=0; i<A.size(); ++i)
		for (int k=0; k<B.size(); ++k)
			for (int j=0; j<B[0].size(); ++j)
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) %m;
	return C;
}

// A^n
vector<vector<int> > pow(vector<vector<int> > A, long long n) {
	vector<vector<int> > B(A.size(), vector<int>(A.size()));
	for (int i=0; i<A.size(); ++i) B[i][i] = 1;
	while (n>0) {
		if (n&1) B = mul(B,A);
		A = mul(A,A);
		n >>= 1;
	}
	return B;
}

signed main() {
	while (1) {
		cin >> n >> m >> a >> b >> c >> t;
		if (n==0) break;
		vector<vector<int> > s(n, vector<int>(1));
		rep(i,n) cin >> s[i][0];
		vector<vector<int> > A(n, vector<int>(n));
		reps(i,1,n-1) A[i][i-1] = a, A[i][i] = b, A[i][i+1] = c;
		A[0][0] = b, A[0][1] = c, A[n-1][n-2] = a, A[n-1][n-1] = b;
		A = pow(A,t), A = mul(A,s);
		rep(i,n) cout << A[i][0] << bln(i,n);
	}
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> S(H, std::vector<char>(W));

  rep(i, H) {
    rep(j, W) {
      std::cin >> S[i][j];
    }
  }

  std::vector<int> diff = {-1, 1};
  auto sub = [&](int x, int y) {
  std::vector<std::vector<int>> dp(H, std::vector<int>(W, -1));
  int ret = 0;
  dp[x][y] = 0;

  std::queue<std::pair<int, int>> q;
    q.push(std::make_pair(x,y));
    while(! q.empty()) {
      auto p = q.front(); q.pop();
      int px = p.first;
      int py = p.second;

      int d = dp[px][py] + 1;
      for(int dx : diff) {
        int new_x = px + dx;
        if(0 <= new_x && new_x < H && dp[new_x][py] < 0 && S[new_x][py] == '.') {
          ret = std::max(ret, dp[new_x][py] = d);
          q.push(std::make_pair(new_x, py));
        }
      }
      for(int dy : diff) {
        int new_y = py + dy;
        if(0 <= new_y && new_y < W && dp[px][new_y] < 0 && S[px][new_y] == '.') {
          ret = std::max(ret, dp[px][new_y] = d);
          q.push(std::make_pair(px, new_y));
        }
      }
    }

    return ret;
  };

  int ans = 0;
  rep(x, H) {
    rep(y, W) {
      if(S[x][y] != '.') continue;
      ans = std::max(ans, sub(x, y));
    }
  }

  std::cout << ans << '\n';

}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	bool yes=true;
	for(int i=0,ft=0,fx=0,fy=0;i<n;++i){
		int t,x,y; cin>>t>>x>>y;
		int X=abs(x-fx),Y=abs(y-fy),T=abs(t-ft);
		if(T<X+Y||T%2!=(X+Y)%2)yes=false;
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    for (int i = 1; i <= 5; i++) {
      int x = Integer.parseInt(sc.next());
      if (x == 0) {
        pw.println(i);
        return;
      }
    }
  }
}


Measured memory_bytes: 35616
def resolve():
  N, M, C = [int(i) for i in input().split()]
  B = [int(i) for i in input().split()]
  cnt = 0
  for i in range(N):
    A = list(int(item) for item in input().split())
    condition = sum([a*b for a, b in zip(A, B)]) + C
    if condition > 0:
      cnt += 1
  print(cnt)

resolve()

Measured memory_bytes: 3060
#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;

int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
	int i,n,d,x = 0;
	cin >> n >> d; d++;
	for(i=0;i<n;i++){
		int a; cin >> a;
		a--; a %= d;
		x ^= a;
	}
	if(x) cout << "First" << endl;
	else cout << "Second" << endl;
}


Measured memory_bytes: 3112
p=*0..gets.to_i
s=0
f,*t=->a{a!=p[a]?p[a]=f[p[a]]:a}
$<.map(&:split).transpose.map{|a|i=0
(x,i),*y=a.map{[_1.to_i,i+=1]}.sort
t+=y.map{[-x+x=_1,i,i=_2]}}
t.sort.map{|c,*a|a,b=a.map &f
a!=b&&(s+=c
p[b]=a)}
p s

Measured memory_bytes: 52904
import functools
import fractions
 
n,x = map(int,input().split())
cities = list(map(int,input().split()))
if n == 1:
    ans = abs(cities[0] - x)
    print(ans)
else:
    cities.append(x)
    cities.sort()
    dist = []
    for i in range(1,len(cities)):
        dist.append(cities[i] - cities[i-1])
    ans = functools.reduce(fractions.gcd, dist)
    print(ans)

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

using namespace std;

string S, T;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> S >> T;
  int s_n = S.length(), t_n = T.length();
  for(int i=s_n; i>=0; --i){
    int flag = 0, j = i, c;
    string SS = S;
    for(j=i, c = 0; c<t_n && j<s_n; ++j, ++c){
      if(SS[j] == '?' || SS[j] == T[c])
        SS[j] = T[c];
      else{
        flag = 1;
        break;
      }
    }
    if(!flag && c == t_n){
      for(int j=0; j<s_n; ++j)
        if(SS[j] == '?')
          SS[j] = 'a';
      cout << SS << "\n";
      return 0;
    }
  }
  cout << "UNRESTORABLE\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  string s;
  cin>>s;
  int max=0;
  REP(i,0,n){
    set<char> S;
    set<char> S2;
    rep(j,i+1){
      S.insert(s[j]);
    }
    int count=0;
    REP(j,i+1,n){
      if(S.find(s[j])!=S.end() && S2.find(s[j])==S2.end()){
        count++;
      }
      S2.insert(s[j]);     
    }
    chmax(max,count);
  }
  cout<<max<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int a;
	int n, k;
	int x, y, z;
	bool v = true;
	scanf("%d %d %d %d", &n, &k, &x, &y);
	z = x + 1;
	f(i, n){
		scanf("%d", &a);
		if (z < a + 1)z = a + 1;
	}
	if (y < z)v = false;
	f(i, k){
		scanf("%d", &a);
		if (a < z)v = false;
	}

	if(v)printf("No War\n");
	else printf("War\n");


	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
            #include<ext/pb_ds/assoc_container.hpp>
            #include<ext/pb_ds/tree_policy.hpp>
            using namespace __gnu_pbds;
            using namespace std;
            # define ll long long
          //  # define int long long  //comment it out when MLE
            # define endl "\n"
            template <typename T>
            using ordered_set = tree<T, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

            #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
            //# define m 163577857
            # define mo 1000000007
            # define pi acos(-1)
            # define fi first
            # define se second
            #define REP(i,n) for (int i = 1; i <= n; i++)
            const ll mod = 998244353;
            //const int K = 2;
            //typedef vector<vector<int> > matrix;

   /*        int add(int a, int b,int mod) {
                a%=mod;
                b%=mod;
                a += b;
                if (a >= mod) a -= mod;
                if(a<0)
                {
                    a += mod;
                    a %= mod;
                }
                return a;
            }

            int mul(ll a, int b,int mod) {
                a%=mod;
                b%=mod;
                a *= b;
                a += mod;
                return a % mod;
            }
            int po(int a,int b,int mod)
            {
                if(b==0)
                    return 1;
                if(b%2==0)
                    return po(mul(a,a,mod),b/2,mod);
                return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
            }


            ll fact[2000003];
            ll inv[2000003];

            void fact0()
            {
                int i,j;
                fact[0]=1;
                for(i=1;i<=2000000;i++)
                {
                    fact[i]=i*fact[i-1]%mod;
                }
                inv[0]=1;
                inv[1]=1;
                ll p=mod;
                for (i=2; i<=2000000; i++)
                    inv[i] = (p - (p/i) * inv[p%i] % p) % p;

                for(i=2;i<=2000000;i++)
                {
                    inv[i]*=inv[i-1];
                    inv[i]%=mod;
                }
            }
            int help(int a,int b)
            {
               // cout<<a<<" "<<b<<endl;
                int an = fact[a];
                //cout<<an<<endl;
                an *= inv[b];
                an %= mod;
                an *= inv[a-b];
                an %= mod;
                return an;
            }

        /*   void random()
            {
              srand(time(0));
            for (int i = 0; i < n; i ++)
                perm[i] = i + 1;
            random_shuffle(perm, perm + n);
            }
int ncr(int a,int b)
{
    int tt = fact[a];
    tt %= mod;
    tt *= inv[a-b];
    tt %= mod;
    tt *= inv[b];
    tt %= mod;
    return tt;
}*/

signed main() {
	gok

 int t=1;
// cin>>t;
 while(t--)
 {
     int n;
     cin>>n;

     int an = n + n*n + n*n*n;
     cout<<an;
 }


















  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)
#define SP(i)           fixed << setprecision(i) 

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

ll n,k;
ll arr[105];
ll dp[105][100005];
ll presum[105][100005];

void solve() {
    cin>>n>>k;
    rep(i,0,n)cin>>arr[i];
    rep(i,0,arr[0]+1)dp[1][i]=1;
    presum[1][0]=1;
    rep(i,1,k+1)presum[1][i]=presum[1][i-1]+dp[1][i];
    rep(i,2,n+1){
    	rep(j,0,k+1){
    		if (j-arr[i-1]-1<0)dp[i][j]=presum[i-1][j];
    		else dp[i][j]=(presum[i-1][j]%hell-presum[i-1][j-arr[i-1]-1]%hell+hell)%hell;
    	}
    	presum[i][0]=dp[i][0];
    	rep(j,1,k+1){
    		presum[i][j]=(presum[i][j-1]%hell+dp[i][j]%hell)%hell;
    	}
    }
    cout<<dp[n][k]<<endl;    
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 159232