akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const ll dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int a, b, c;
	cin >> a >> b >> c;

	rep(i, 2) {
		rep(j, 2) {
			rep(k, 2) {
				int A = 0, B = 0;
				if (i)A += a; else B += a;
				if (j)A += b; else B += b;
				if (k)A += c; else B += c;
				if (A == B) {
					cout << "Yes" << endl; return 0;
				}
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

vector <bool> used;

void yaru(ll remain, vector<ll> retu){
    if (remain == 0){
        REP(i, retu.size()-1) {
            char hoge = 'a';
            hoge += retu[i];
            cout << hoge;
        }
        char hoge = 'a';
        hoge = hoge + retu[retu.size()-1];
        cout << hoge << endl;
        return;
    }
    REP(i, used.size()){
        vector <ll> tugi = retu;
        if (used[i] == false){
            used[i] = true;
            tugi.push_back(i);
            yaru(remain-1, tugi);
            used[i] = false;
            break;
        }
        tugi.push_back(i);
        yaru(remain-1, tugi);
    }
}



int main(void){
    ll n; cin >> n;
    REP(i, n){
        used.push_back(false);
    }
    vector<ll> kara;
    yaru(n, kara);
    return 0;
}

Measured memory_bytes: 1536
N,M=gets.split.map(&:to_i)
K=M.times.map {
    t = gets.split.map{|x|x.to_i-1}
    t.shift
    t
}
P=gets.split.map(&:to_i)

=begin
N,M=10, 10
k=[]
M.times do |i|
    a=N.times.map{rand(0..N-1)}
    k<<a
end
K=k
P=N.times.map{0}
=end

cnt=0
(2**N).times do |i|
    flag=true
    M.times do |j|
        switch=0
        K[j].each do |n|
            switch += i>>n & 1
        end
        if switch % 2 != P[j]
            flag=false
            break
        end
    end
    cnt +=1 if flag
end
p cnt


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
typedef vector<double> vec;
typedef vector<vec> mat;
const double eps = 1e-8;
const double INF = 1e20;

bool gauss_jordan(const mat &A, const vec &b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      B[i][j]=A[i][j];
    }
  }
  for(int i=0;i<n;i++)B[i][n]=b[i];

  


  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    }
    swap(B[i],B[pivot]);
    if(abs(B[i][i])<eps)continue;
    
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j){
	for(int k=i+1;k<=n;k++){
	  B[j][k]-=B[j][i]*B[i][k];
	}
      }
    }
  }

  if( abs(B[n-1][n]) < 1e-3)return true;
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      cout<<B[i][j]<<' ';
    }
    cout<<endl;
  }

  
  for(int i=0;i<n;i++){
    cout<<B[i][n]<<' ';
  }
  cout<<endl;
  cout<<endl;
  */
  for(int i=0;i<n;i++){
    if(abs(B[i][i])<eps){
      // if(abs(B[i][n])>eps)return true;
    }
  }
  
  /*
  for(int i=0;i<n;i++){
    for(int j=0;j<=n;j++){
      cout<<B[i][j]<<' ';
    }
    cout<<endl;
  }
  cout<<endl;
  
  vec x(n);
  for(int i=0;i<n;i++){
    x[i]=B[i][n];
  }
  */
  return false;//  return x;
}

int n;
double t[10];

bool check(int x){
  mat A(n+2,vec(n+2));
  vec b(n+2);
  

  int c1=0;
  for(int i=0;i<n+3;i++){
    if(x==i)continue;
    for(int j=0;j<n+2;j++){
      A[c1][j]=pow(i,j);
      if(j==n+1)A[c1][j]=0;
    }
    b[c1]=t[i];
    c1++;
    if(c1==n+2)break;
  }
  /*
  for(int i=0;i<A.size();i++){
    for(int j=0;j<A[i].size();j++){
      cout<<A[i][j]<<' ';
    }
    cout<<b[i]<<endl;
  }
  cout<<endl;
  */
  if( gauss_jordan(A,b))return true;

  return false;
}

void solve(){
  for(int i=0;i<n+3;i++){
    if(check(i)){
      cout<<i<<endl;
      return;
    }
  }
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n+3;i++)cin>>t[i];
    solve();
  }
  return 0;
}

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



int main() {
    ll h;
    cin >> h;
    ll a=0;
    while (h>0) {
        h/=2;
        a++;
    }
    ll ans=0;
    rep(i,a) {
        ans=ans*2+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    string s;
    cin >> s;
    int ans = s.size() / 2;
    rep(i, s.size()) ans -= (s[i] == 'p');
    cout << ans << endl;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;

class AC
{

    void Solve()
    {
        var n = io.String;
        foreach (var c in n.ToCharArray())
        {
            if (c == '1')
            {
                Write('9');
            }
            else
            {
                Write('1');
            }
        }
        WriteLine();
    }

    IoTiny io = new IoTiny();

    public static void Main(string[] args) => new AC().Stream();

    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }

}

class IoTiny
{    
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };

    public IoTiny()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }

    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "") st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }

    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);

    public void Flush() => Out.Flush();

}


Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, l[10];
	cin >> n;
	REP(i, n) cin >> l[i];
	sort(l, l + n, std::greater<int>());
	int sum = 0;
	for (int i = 1; i < n; i++) sum += l[i];
	if (l[0] < sum) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	  
	  int a[10];
	  scanf("%d %d %d",&a[0],&a[1],&a[2]);
	  sort(a,a+3);
	  int cost;
	  cost=abs(a[1]-a[0]);
	  cost=cost+abs(a[2]-a[1]);
	  printf("%d\n",cost);
	 return 0;
} 


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int y = saori.saori_hayami();
		if(x%y == 0){
			System.out.println(-1);
			return;
		}
		System.out.println(x);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22612
#include<stdio.h>
#define MAX 100000



struct Card{
  char s;
  int v;
};

struct Card L[MAX], R[MAX];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;



  for( i = 0 ; i < n1 ; i++ ){
    L[i] = A[left + i];
  }



  for( i = 0 ; i < n2 ; i++ ){
    R[i] = A[mid + i];
  }
  L[n1].v = R[n2].v = 2000000000;
  i = j = 0;
  for( k = left ; k < right ; k++){



    if( L[i].v <= R[j].v ){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}

void m_s(struct Card A[], int n, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    m_s(A, n, left, mid);
    m_s(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}



int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;

  x = A[r];
  i = p - 1;
  for( j = p ; j < r ; j++ ){
    if( A[j].v <= x.v ){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i + 1;
}

void quick(struct Card A[], int n ,int p, int r){
  int q;
  if( p < r ){

    q = partition(A, n, p, r);

    quick(A, n, p, q-1);
    quick(A, n, q+1, r);
  }
}

int main(){
  int i, n, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);
  for( i = 0 ; i < n ; i++){
    scanf("%s %d", S, &v);
    A[i].s = B[i].s = S[0];
    A[i].v = B[i].v = v;
  }
  m_s(A, n, 0, n);
  quick(B, n, 0, n-1);

  for( i = 0 ; i < n ; i++){
    if( A[i].s != B[i].s ) stable = 0;
  }

  if( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0 ; i < n ; i++){
    printf("%c %d\n", B[i].s, B[i].v);
  }
  return 0;
}



Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()

int main () {
  vector<int> vec({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
});
  int k;
  cin >> k;

  cout << vec[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#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 ull unsigned long long
#define f(a, b) for (ll i = a; i < b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define ld long double
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
#define print(x) cout << #x << " is " << x << endl;
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll dp[3005][3005], a[3005], n;

ll rec(ll l, ll r)
{
    if (r < l)
        return 0;
    if (dp[l][r] != 1e18)
        return dp[l][r];
    ll t, k = 0;
    if (((r - l) & 1) == (n & 1))
        t = 0;
    else
        t = 1;
    if (t == 0)
    {
        dp[l][r] = 1e18;
        dp[l][r] = min(dp[l][r], min(-1 * a[l] + rec(l + 1, r), -1 * a[r] + rec(l, r - 1)));
    }
    else
    {
        dp[l][r] = -1e18;
        dp[l][r] = max(dp[l][r], max(a[l] + rec(l + 1, r), a[r] + rec(l, r - 1)));
    }
    return dp[l][r];
}

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

    f(1, 3005) fi(1, 3005) dp[i][j] = 1e18;
    cin >> n;
    f(1, n + 1) cin >> a[i];
    ll ans = rec(1, n);
    cout << ans;

    return 0;
}

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

int main(void) {
    int N;
    string S;
    cin>>N>>S;
    if (N % 2 == 1) cout << "No" << endl;
    else {
        string T = S.substr(0, N / 2);
        if (S == T + T) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const int mod=1e9+7;
const int M=10100;
string a,b,c,tmp="";
int asz,bsz,csz;
 int dp1[M][2007];
 int dp2[M][2007];
 int dp3[M][2007];
bool chk(int bl,int br,int cl,int cr)
{
    if(br<cl || cr<bl)return true;
    int lft=max(bl,cl);
    int rgt=min(br,cr);
    int len=rgt-lft+1;
    int bst=lft-bl;
    int cst=lft-cl;
    if(dp3[bst][cst]>=len)return true;
    return false;
}
 main()

{
    //fast
    //freopen("005.txt", "r", stdin);
    cin>>a;
    cin>>b;
    cin>>c;
//    cout<<"#"<<a<<endl;
//    cout<<"#"<<b<<endl;
//    cout<<"#"<<c<<endl;
    int ctmp=4002;
    while(ctmp--)tmp+="?";
    int alen=a.size();
    a=a+tmp;
    a=tmp+a;
    asz=a.size();
    bsz=b.size();
    csz=c.size();
   // cout<<alen<<" "<<bsz<<" "<<csz<<endl;
    int al=4002;
    int ar=al+alen-1;
    rf(i,asz-1,0)
    {
        rf(j,bsz-1,0)
        {
            if(a[i]==b[j] || a[i]=='?' ||  b[j]=='?')
            {
                dp1[i][j]=1+dp1[i+1][j+1];
            }
        }
    }
    rf(i,asz-1,0)
    {
        rf(j,csz-1,0)
        {
            if(a[i]==c[j] || a[i]=='?' ||  c[j]=='?')
            {
                dp2[i][j]=1+dp2[i+1][j+1];
            }
        }
    }
    rf(i,bsz-1,0)
    {
        rf(j,csz-1,0)
        {
            if(b[i]==c[j] || b[i]=='?' || c[j]=='?')
            {
                dp3[i][j]=1+dp3[i+1][j+1];
            }
        }
    }
    int ses=alen+bsz+csz;
   f(bst,0,asz-1)
   {
       f(cst,0,asz-1)
       {
           if(dp1[bst][0]==bsz && dp2[cst][0]==csz)
           {
               int bl=bst;
               int br=bst+bsz-1;
               int cl=cst;
               int cr=cst+csz-1;
               if(chk(bl,br,cl,cr)){

               int lft=min(al,bl);
               lft=min(lft,cl);
               int rgt=max(ar,br);
               rgt=max(rgt,cr);
               int sz=rgt-lft+1;
               ses=min(ses,sz);

               }
           }
       }
   }
   cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 176228
import java.util.*;

public class Main {
    static public void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0; i<3; i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
            System.out.printf("%d %d %d\n", a[0], a[1], a[2]);
            sc.close();
    }
}


Measured memory_bytes: 26392
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn = 100007;
int f[maxn],d[maxn];
int n,m,l,r,v;
int find(int x)
{
    if(x==f[x])return x;
    int now = f[x];
    f[x]=find(f[x]);
    d[x]=d[x]+d[now];
    return f[x];
}
int main()
{
    scanf("%d %d",&n,&m);
    int ok = 1;
    for(int i=1;i<=n;i++)f[i]=i;
    for(int i=1;i<=m;i++)
    {
        scanf("%d %d %d",&l,&r,&v);
        int fl = find(l);
        int fr = find(r);
        if(fl==fr)
        {
            if(d[l]-d[r]!=v)ok = 0;
        }
        else
        {
            f[fl]=fr;
            d[fl]=v+d[r]-d[l];
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N;
   cin >> N;
   int s[2][N + 1];
   s[0][0] = 0;
   s[1][0] = 0;
   int tmp;
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      s[0][i + 1] = s[0][i] + tmp;
   }
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      s[1][i + 1] = s[1][i] + tmp;
   }
   int ans = -1;
   int sum;
   for (int i = 0; i < N; i++) {
      sum = 0;
      sum += s[0][i + 1] - s[0][0];
      sum += s[1][N] - s[1][i];
      if (ans == -1) ans = sum;
      else if (ans < sum) ans = sum;
   }
   cout << ans << endl;
   return 0;
}


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

using namespace std;

const int N = (int) 1e5 + 5;

vector<int> g[N];

int dfs(int v, int p = -1) {
  int cnt = 0;
  int sm = 0;
  for (int to : g[v]) {
    if (to != p) {
      int x = dfs(to, v);
      sm += x;
      cnt += (x == 0);
    }
  }
  sm += max(0, cnt - 1);
  return sm;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int root = -1;
  for (int i = 0; i < n; i++) {
    if ((int) g[i].size() >= 3) {
      root = i;
      break;
    }
  }
  if (root == -1) {
    cout << 1 << endl;
    return 0;
  }
  int res = dfs(root);
  cout << res << endl;
  return 0;
}


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

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

int main(){
  int x, y;
  cin >> x >> y;
  if(x > y) cout << gcd(x, y) << endl;
  else      cout << gcd(y, x) << endl;
  return 0;
}


Measured memory_bytes: 3092
// Aizu Vol-5 0514: Quality Checking
// 2017.8.30 bal4u@uu

#include <stdio.h>

#define NG 0
#define OK 1
#define UK 2

typedef struct { int p[3]; } T;
T t[1003]; int len;
int p[303], m;

int main()
{
	int a, b, c, n, i, j, k, r;

	while (scanf("%d%d%d", &a, &b, &c) && (a | b | c)) {
		m = a + b + c, len = 0;
		for (i = 1; i <= m; i++) p[i] = UK;
		scanf("%d", &n); while (n-- > 0) {
			scanf("%d%d%d%d", &i, &j, &k, &r);
			if (r) p[i] = p[j] = p[k] = OK;
			else t[len].p[0] = i, t[len].p[1] = j, t[len++].p[2] = k;
		}
		for (i = 0; i < len; i++) {
			for (r = 0, k = 1, j = 0; j < 3; j++, k <<= 1) if (p[t[i].p[j]] == OK) r += k;
			if      (r == 6) p[t[i].p[0]] = NG;
			else if (r == 5) p[t[i].p[1]] = NG;
			else if (r == 3) p[t[i].p[2]] = NG;
		}
		for (i = 1; i <= m; i++) putchar(p[i]+'0'), putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    int n2 = n;
    int sn = 0;
    while(n2) {
        sn += n2 % 10;
        n2 /= 10;
    }
    if(n % sn == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

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

    int n, m;

    cin >> n >> m;
    vector<pair<int, int>> g(m);
    for (int i = 0; i < m; ++i)
        cin >> g[i].first >> g[i].second;

    sort(g.begin(), g.end());

    int cnt = 0, idx = 0;
    while (idx < m) {
        ++cnt;

        int r = g[idx].second;
        while (idx + 1 < m && g[idx + 1].first < r)
            r = min(r, g[++idx].second);
        ++idx;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
n = gets.chomp.to_i
p = []
n.times { p << gets.chomp.split.map(&:to_i) }

r_sum = 0
allroutes = p.permutation.to_a

allroutes.each do |route|
  route.each_with_index do |place, i|
    next if i.zero?

    x1, y1 = place[0], place[1]
    x2, y2 = route[i - 1][0], route[i - 1][1]
    r_sum += Math.sqrt((x1 - x2)**2.to_f + (y1 - y2)**2.to_f)
  end
end

puts r_sum / allroutes.size


Measured memory_bytes: 9624
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

a=INT()
b =INT()
if a+b ==3:
    print(3)
elif a+b==4:
    print(2)
else:
    print(1)


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

int main() {
    /* Input */
    int n;
    cin >> n;

    /* Main Logic */
    long int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }

    /* Output */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
a, b, c, d, e, f = list(map(int, input().split(' ')))


rate = 0
water = 0
suger = 0

al = f // (a * 100)
bl = f // (b * 100)
for i in range(al + 1):
    for j in range(bl + 1):
        for k in range(100 + 1):
            for l in range(100 + 1):
                w = 100 * a * i + 100 * b * j
                s = c * k + d * l
                if w + s <= 0:
                    break
                temp = w + s
                r = (s * 100) / temp
                if temp <= f and (a * i + b * j) * e >= s:
                    if rate <= r:
                        water = w
                        suger = s 
                        rate = r
print(water + suger, suger)


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

string f(ll n) {
  if (n == 0) return "";
  n--;
  return f(n/26) + string(1,'a'+n%26);
}

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

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    int x,n,l[256],d[256],count=0;
    d[0]=0;
    cin >> n >> x;
    
    for(int i=0;i<n;i++) cin >> l[i];
    
    for(int i=1;i<=n;i++){
        d[i]=d[i-1]+l[i-1];
        if(d[i]<=x) count++;
    }
    cout << count+1 <<endl;
    
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/12/13  Problem: a / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

	int A, B; cin >> A >> B;
	string s; cin >> s;
	int ok = 1;
	FOR(i, 0, SZ(s)) {
		if (i == A) {
			ok &= (s[i] == '-');
		}
		else {
			ok &= isdigit(s[i]);
		}
	}

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

N = cin()
A = cin()
INF = 10 ** 9 + 7

res = [0 for _ in range(65)]
for i in range(65):
    c0, c1 = 0, 0
    for j in range(N):
        if bool(A[j] & (1 << i)):  c1 += 1
        else:  c0 += 1
    res[i] = c0 * c1
ans = 0
for i in range(65):  ans = (ans + (1 << i) * res[i]) % INF
print(ans)

Measured memory_bytes: 124144
import numpy as np
N = int(input())
h = list(map(int, input().split()))
h = np.array(h)
h_diff = h[1:] - h[:N-1]
count = 0
for i in range(N-1):
    count -= min(h_diff[i], 0)
    
print(count + h[N-1])

Measured memory_bytes: 17824
def main():
    n = int(input())
    ans = n * (n + 1) * (n + 2) // 6
    
    for i in range(n-1):
        x, y = map(int, input().split())
        if x > y:
            y, x = x, y
        ans -= x * (n - y + 1)
    print(ans)
    
main()


Measured memory_bytes: 9100
#include <iostream>
#include <climits>
#include <array>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define MODULE 1000000007
#define MP make_pair

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {   //structとclassの違いは，メンバが初期状態でpublicとなっているかprivateとなっているか
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
string w;   //alpha=26
int chars[26];
int main(){
    ios::sync_with_stdio(false);
    cin>>w;
    for (int i = 0; i < 26; ++i) {
        chars[i]=0;
    }
    for(int i=0;i<w.length();i++){
        chars[w[i]-97]++;
    }
    bool flag=true;
    for (int i = 0; i < 26; ++i) {
        if(chars[i]%2!=0){
            flag=false;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    } else{
        cout<<"No"<<endl;
    }
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int N;
  ll A, B;
  cin >> N >> A >> B;
  vl X(N);
  rep(i, 0, N) {
    cin >> X[i];
  }

  ll ans = 0;
  rep(i, 1, N) {
    ll dist = X[i] - X[i-1];
    ans += min<ll>(dist * A, B);
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int x,y,i,j,k,n,z,a,b,c;
    vector<long long int>v,u,w;
    //string s;
    map<long long int ,long long int>m;
    cin>>a>>b>>c>>x>>y;
    if(2*c>a+b)
    {
        cout<<a*x+b*y<<endl;
    }
    else
    {
        i=min(x,y);
        j=max(x,y);
        if(x>y)
        cout<<min(j*c*2,i*c*2+(j-i)*a)<<endl;
        else
            cout<<min(j*c*2,i*2*c+(j-i)*b);
    }

    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll A[200010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++) cin>>A[i];
    if(N==1){
        cout<<0;
        return 0;
    }
    sort(A,A+N,greater<ll>());
    ll ans=A[0];
    ll now=1;
    bool f=false;
    for(ll i=2;i<N;i++){
        ans+=A[now];
        if(f){
            now++;
            f=false;
        }else{
            f=true;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5156
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from math import floor, ceil
#from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
#inf = 10**17
#mod = 10**9 + 7

s=input().rstrip()
s2=input().rstrip()
if s[0]==s2[2] and s[1]==s2[1] and s[2]==s2[0]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38256
#include <iostream>
#include <cstring> // memset()
#include <cmath> // pow(a, b)
#include <string> // string, stoi(string)
#include <cstdlib> //abs(int x)
#include <bitset> //bitset<int>(int)
using namespace std;


const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

int solve(string S){
  for (int i=0; i<pow(2, 3); i++){
    int acc = S[0]-'0';
    if (i&BIT_FLAG_0){
      acc += (S[1]-'0');
    } else {
      acc -= (S[1]-'0');
    }
    if (i&BIT_FLAG_1){
      acc += (S[2]-'0');
    } else {
      acc -= (S[2]-'0');
    }
    if (i&BIT_FLAG_2){
      acc += (S[3]-'0');
    } else {
      acc -= (S[3]-'0');
    }
    if (acc == 7){
      if (i&BIT_FLAG_0){
        cout << S[0] << '+';
      } else {
        cout << S[0] << '-';
      }
      if (i&BIT_FLAG_1){
        cout << S[1] << '+';
      } else {
        cout << S[1] << '-';
      }
      if (i&BIT_FLAG_2){
        cout << S[2] << '+' << S[3] << "=7";
      } else {
        cout << S[2] << '-' << S[3] << "=7";
      }
      break;
    }
  }
  return 0;
}

int main(){
  string S; cin >> S;
  
  solve(S);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int ret = 0;
    for(auto i = s.begin(); i != s.end(); i++){
        if(*i == '2'){
            ret++;
        }
    }
    cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

ll n,m,x;
ll c[13]={0};
ll d[13][13]={0};
ll min=0;
vector<vector<int>> adj;
void printSubsequences(vector<int> arr, int index,vector<int> subarr) 
{ 

    if (index == arr.size()) 
    { 
        int l = subarr.size(); 
        if (l != 0) 
            adj.pb(subarr); 
    } 
    else
    { 

        printSubsequences(arr, index + 1, subarr); 
  
        subarr.push_back(arr[index]); 

        printSubsequences(arr, index + 1, subarr); 
    } 
    return; 
} 
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    
    cin>>n>>m>>x;
    vector<int> temp;
    vector<int> arr(n);
    f(i,n){
        arr[i]=i+1;
    }
    f1(i,n+1){
        cin>>c[i];
        f1(j,m+1){
            cin>>d[i][j];
        }
    }
    printSubsequences(arr,0,temp);
    // f(i,adj.size()){
    //     f(j,adj[i].size()){
    //         cout<<adj[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    bool flag=0;
    int fin=1e9;
    f(i,adj.size()){
        int ans=0;
        int check=0;
        f1(j,m+1){
            int val=0;
            f(k,adj[i].size()){
                val+=d[adj[i][k]][j];
            }
            if(val<x){
                check=1;
                break;
            }
        }
        if(check==0){
            flag=1;
            f(j,adj[i].size()){
                ans+=c[adj[i][j]];
            }
            if(ans<fin){
                fin=ans;
            }
        }
    }
    if(flag==0){
        cout<<-1<<endl;
    }
    else{
        cout<<fin<<endl;
    }
    return 0;
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int k; ll ans =0;
	cin >>k;
	
	rep2(i, 1, k+1) rep2(j, 1, k+1) rep2(z, 1, k+1){
		ll w = gcd(i, j);
		w = gcd(w, z);
		ans += w;
		//dbg(i,j,k);
	}


	
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 3636
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
import numpy as np
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

n=inp()
a = inpl()
b = inpl()
ans=0
for i in range(n):
    tmp=a[i] - b[i]
    if tmp >= 0:
        ans += b[i]
    else:
        ans += a[i]
        tmp=-tmp
        temp = a[i + 1] - tmp
        if temp >= 0:
            ans += tmp
            a[i + 1] -= tmp
        else:
            ans += a[i + 1]
            a[i + 1] = 0
print(ans)
    


Measured memory_bytes: 27684
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
int main()
{
  long people[6],capacity[5],N,i,min_cap=10000000000000001,min_cap_n;
  
  scanf("%ld",&N);
  for(i=0;i<5;i++){
    scanf("%ld",&capacity[i]);
    if(capacity[i]<min_cap){
      min_cap=capacity[i];
      min_cap_n=i;
    }
  }
  
  printf("%ld", 4+(N+(min_cap-1))/min_cap);
  
  
  return 0;

}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr long long INF = 1e12;

int main() {

    int N;
    cin >> N;

    vector<long long> h(N);
    for (int i = 0; i < N; i++)cin >> h[i];

    vector<long long> dp(N, INF);
    dp[0] = 0;

    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= 2; j++) {
            int index = max(0, i - j);
            dp[i] = min(dp[i], dp[index] + abs(h[i] - h[index]));
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}
















































Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

N, M = [int(x) for x in input().split()]
k = []
s = []
for _ in range(M):
    tmp = [int(x) for x in input().split()]
    k.append(tmp[0])
    s.append(tmp[1:])
p = [int(x) for x in input().split()]

ans = 0

for i in range(2 ** N):
    flag = 1
    for j in range(M):
        cnt = 0
        for k in s[j]:
            cnt += (i >> (k - 1)) & 1
        if cnt % 2 != p[j]:
            flag = 0
            break
    ans += flag

print(ans)




Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();

		if(x < a) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}


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

int main(){
  int N, ans = 0;
  cin >> N;
  for(int i = 357; i <= N; i += 2){
    int num = i;
    int bit = 0;
    int f = 1;
    if((num / 10) % 10 % 2 == 0) i += 10;
    while(num != 0){
      int m = num % 10;
      num /= 10;
      if(m == 3 || m == 5 || m ==7){
        bit |= 2 << m;
      }else{
        f = 0;
        break;
      }
    }
    if(f == 1 && bit == 336){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0; 
}

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

int main() {
    string s;
    cin >> s;

    int len = s.length();
    for (int i=0; i<len; i++) {
        for (int j=i+1; j<len; j++) {
            if (s[i] == s[j]) {
               cout << "no" << endl;
               return 0;
            }
        }
    }

    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n,d;
    cin>>n>>d;
    vector<vector<int>> x(n,vector<int>(d));
    REP(i,n){
        REP(j,d){
            cin>>x[i][j];
        }
    }

    int v=0;
    REP(i,n-1){
        REP2(j,i+1,n){
            int l2=0;
            REP(k,d) l2+=pow(x[i][k]-x[j][k],2);
            double l=sqrt(l2);
            if(pow(int(l),2)==l2) v++;
        }
    }

    cout<<v<<endl;
    
	return 0; 
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n')
const keys = ['AC', 'WA', 'TLE', 'RE']
const resultMap = {
  'AC': 0,
  'WA': 0,
  'TLE': 0,
  'RE': 0
}
const len = parseInt(input[0])
for (let i=1; i<=len; i++) {
  resultMap[input[i]] ++
}
keys.forEach(key => {
  console.log(key + ' x ' + resultMap[key])
})

Measured memory_bytes: 37260
n, m = map(int, input().split())
k=[list(map(int,list(input().split()))) for i in range(n)]


ans = 0
k.sort()
for i in range(n):
    ml = min(k[i][1],m)
    ans += k[i][0] * ml
    m -= k[i][1]
    if m <= 0:
        break
print(ans)

Measured memory_bytes: 27820
#include <bits/stdc++.h>
/* S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
clock()/CLOCKS_PER_SEC で秒数
vector v.push_back(x),v.pop_back()
q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
<deque>(push/pop)_(front/back)/fornt/back/insert/
priority_queue 宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに*/
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repl(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;(i)--)
#define vep(i,v) for(auto (i)=v.begin();(i)<(v.end());(i)++)
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; }
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
typedef pair<long long,long long> P;
typedef pair<int,int> PI;
typedef std::vector<int> vi;
typedef std::vector<long long> vl;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
using Graph = std::vector<std::vector<int> >;
const long long inf = 10e17;
const long long mod = 1000000007;
//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
#define print(i) std::cout << (i) << '\n'
int n;
ll x[15],y[15],p[15];
int main(){
cin>>n;
vi xs,ys,unused;
ll pow3=1ll;
rep(i,n){cin>>x[i]>>y[i]>>p[i];pow3*=3;}

vl res(n+1,inf);
for(ll t=0ll;t<pow3;t++){
    xs.clear();
    ys.clear();
    unused.clear();
    ll i=t;
    rep(j,n){
        switch(i%3){
            case 0:
                unused.emplace_back(j);
                break;
            case 1:
            xs.emplace_back(j);
            break;
            case 2:
            ys.emplace_back(j);
        }
        i/=3;
    }
    ll dist=0ll;
    for(int uin:unused){
        ll ret=min(abs(x[uin]),abs(y[uin]));
        for(int xin:xs){
            ret=min(ret,abs(x[uin]-x[xin]));
        }
        for(int yin:ys){
            ret=min(ret,abs(y[uin]-y[yin]));
        }
    dist+=ret*p[uin];
    }
    res[xs.size()+ys.size()]=min(res[xs.size()+ys.size()],dist);

}
for(auto h:res)print(h);
}


Measured memory_bytes: 3636