akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}
};

typedef vector<set<Edge>> Graph;

void connect(Graph& g, int f, int t, ll w = 1) {
	g[f].insert({ f,t, w });
	g[t].insert({ t,f, w });
}
void erase(Graph& g, int f, int t) {
	g[f].erase({ f,t,1LL });
	g[t].erase({ t,f,1LL });
}
signed main(void) {
	int n, m;
	cin >> n >> m;

	vector<int> cou(n);
	Graph g(n);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		cou[a]++;
		cou[b]++;
		connect(g, a,b);
	}
	int fc = 0, sc = 0;
	REP(i, n) {

		if (cou[i] >= 4) fc++;
		if (cou[i] >= 6) sc++;
		if (cou[i] % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	if (fc >= 2 || sc >= 1) {
		if(fc > 2 || sc >= 1)
			cout << "Yes" << endl;
		else if (fc == 2) {
			
			while (1) {
				int st = -1, c;
				REP(i, n) {
					if (cou[i] == 4 && g[i].size() > 0) {
						c = i, st = i;
						break;
					}
				}
				if (st == -1) break;

				do {
					int nx;
					if (g[c].begin()->to != c)
						nx = g[c].begin()->to;
					else nx = g[c].rbegin()->to;

					erase(g, c,nx);
					c = nx;

				} while (cou[c] != 4);

				if (st == c) {
					cout << "Yes" << endl;
					return 0;
				}
			}

			cout << "No" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    char c;
    cin >> c;
    c++;
    cout << c << endl;
}

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

//#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

namespace SA{
    const int MAX=1000000;
    int N,K;
    int tmp[MAX+1],rank[MAX+1];
    bool compare_sa(int i,int j){
        if(rank[i]!=rank[j])return rank[i]<rank[j];
        else{
            int ri=(i+K<=N)?rank[i+K]:-1;
            int rj=(j+K<=N)?rank[j+K]:-1;
            return ri<rj;
        }
    }

    vector<int> construct_sa(string S){
        N=S.size();
        vector<int>sa(N+1);
        for(int i=0;i<=N;i++)sa[i]=i;
        for(int i=0;i<=N;i++){
            rank[i]=i==N?-1:S[i];
        }

        for(K=1;K<=N;K*=2){
            sort(sa.begin(),sa.end(),compare_sa);
            tmp[sa[0]]=0;
            for(int i=1;i<=N;i++){
                tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i])?1:0);
            }
            for(int i=0;i<=N;i++)rank[i]=tmp[i];
        }
        return sa;
    }
}


bool exist(string T){


    /*
    int lb=0,ub=S.size();
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(S.substr(sa[mid],min(S.size()-mid,T.size()))<T)lb=mid;
        else ub=mid;
    }
    if(ub<=S.size()&&S.size()-sa[ub]>=T.size()&&S.substr(sa[ub],T.size())==T)return true;
    return false;
    */
}

bool contain(string &S,vint &sa,string &T){
    int a=0,b=S.size();
    while(b-a>1){
        int c=(a+b)/2;
        if(S.compare(sa[c],T.size(),T)<0)a=c;
        else b=c;
    }
    return S.compare(sa[b],T.size(),T)==0;
}

signed main(){
    string S;
    vint sa;
    int Q;
    cin>>S;
    sa=SA::construct_sa(S);
    cin>>Q;

    while(Q--){
        string T;cin>>T;
        if(contain(S,sa,T))cout<<1<<endl;
        else cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 18732
#include <iostream>

using namespace std;

int main(void)
{
    long long N, N1, SN=0;

    cin >> N;

    N1 = N;

    while(N!=0){
        SN += (N%10);

        N /= 10;
    }

    if(N1%SN==0){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n,k; cin>>n>>k;
  vector<int> h(n); rep(i,n) cin>>h.at(i);
  sort(h.begin(),h.end());
  if(k>=n) cout<<0<<endl;
  else{
    long long ans=0;
    rep(i,n-k) ans+=h.at(i);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1024
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)998244353;
//}}}

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

int A[100000];
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  bool ans = (B - A) % 2 == 0;
  puts(ans ? "Alice" : "Borys");
  return 0;
}


Measured memory_bytes: 256
N,a,b = map(int,input().split())
ball = a + b
if a == 0 :
    ans = 0
elif N % ball == 0 :
    ans = a*(N // ball)
elif N % ball <= a :
    ans = a*(N // ball) + (N % ball)
else :
    ans = a*(N // ball) + a
print(ans)    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  int ans=0;
  for(int i=1;i<=n;i++){
    string s=to_string(i);
    if(s.size()%2==1){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
int main(void)
{
	std::vector<int> A;
    int q,x,cmd;
    std::cin >> q;
    for(int i = 0; i < q; i++)
    {
        std::cin >> cmd;
        switch(cmd)
        {
            case 0:
                std::cin >> x;
                A.push_back(x);
                break;

            case 1:
                std::cin >> x;
                std::cout << A[x] <<std::endl;
                break;
            case 2:
                A.pop_back();
                break;
        }
    }

    return 0;
}


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


#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define vi vector<int>

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

clock_t first_attempt = clock();
inline void cek_time(){
	clock_t cur = clock()- first_attempt;
	cerr<<"TIME : "<<(double) cur/CLOCKS_PER_SEC<<endl;
}
inline void OPEN (string s) {
	freopen ((s + ".in").c_str (), "r", stdin);
	freopen ((s + ".out").c_str (), "w", stdout);
}

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> bbst;
//find_by_order(idx) : i-th index 
//order_of_key(val)  : val has which index

//end of template

int n;
string s;
int main() {
	cin >> s;
	n = s.size();
	
	if (s[n-1] == '1') {
		puts("-1");
		return 0;
	}
	
	if (s[0] != '1' || s[n - 2] != '1') {
		puts("-1");
		return 0;
	}
	for (int ki = 0, ka = n - 2; ki <= ka; ki++, ka--) {
		if (s[ki] != s[ka]) {
			puts("-1"); return 0;
		}
	}
	
	vector<pii> ans;
	int cur = 1;
	rep(k, 0, n) if (s[k] == '1') {
		int sz = k + 1;
		while (cur < sz) {
			ans.pb({cur, sz});
			cur++;
		}
	}
	ans.pb({n-1, n});
	
	for (auto a : ans) {
		printf("%d %d\n", a.fi, a.se);
	}
}

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

using namespace std;

#define EPS (1e-7)
#define INF (1e9)


typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rep2(i, n) for(int i = 1; i <= (n); i++)
#define all(a) begin(a),end(a)
#define endl '\n'




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

//////////////////////////////////////////


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}

inline void init(vector<int>& uf) {

    iota(all(uf), 0);
}

inline int root(vector<int>& uf, int x) {

    if(uf[x] == x) {

        return x;
    }
    else {

        return uf[x] = root(uf, uf[x]);
    }
}

inline bool same(vector<int>& uf, int x, int y) {

    return root(uf, x) == root(uf, y);
}

inline void unite(vector<int>& uf, int x, int y) {

    x = root(uf, x);
    y = root(uf, y);

    if(x == y) return;

    uf[x] = y;
}

map<int, int> mp;
int n;
void Input() {

    cin >> n;
}



void Solve() {


    vector<int> v(n);

    for(int i = 0; i < n; i++) {

        int x;
        cin >> x;
        if(mp[x] == 0) {

            mp[x] = 1;


        }
        else {
            cout << "NO" << endl;
            return;
        }
    }

    cout << "YES" << endl;

}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 10368
#include<iostream>
#include<queue>
#include<cassert>

using namespace std;

struct Point{
  int score,player;

  bool operator < (const Point& p) const {
    if( score != p.score ) return score < p.score;
    return player > p.player;
  }
};

/*
  ostream& operator << (ostream& os,const Point& p) {
  os << "(" << p.score << "," << p.player <<")";
}
*/
int main(){
  
  int N,R,L;
  int d,t,x;
  priority_queue<Point> PQ;
  priority_queue<Point> PQ2;
  int score_sum[100001],time_sum[100001];
  int data[3]={1,0,0};
  
  cin >>N>>R>>L;
  
  for(int i=0 ; i < 100001 ; i++){
    score_sum[i]=0;
    time_sum[i]=0;
  }

  for(int i=1 ; i <= R ; i++){
    
    cin >>d>>t>>x;
    
    PQ.push((Point){score_sum[data[0]],data[0]});
    
    while(1){
      if(!PQ.empty() && PQ.top().score == score_sum[PQ.top().player]){
	time_sum[PQ.top().player]+=t-data[1];
	break;
      }else{
	assert( PQ.size() );
	PQ.pop();
      }
    }  
    PQ2.push((Point){time_sum[PQ.top().player],PQ.top().player});
  
    score_sum[d]+=x;  
    data[0]=d;data[1]=t;data[2]=x;  
  }

  PQ.push((Point){score_sum[data[0]],data[0]});
  while(1){
    if(!PQ.empty() && PQ.top().score == score_sum[PQ.top().player]){
      time_sum[PQ.top().player]+=L-data[1];
      break;
    }else{
      assert( !PQ.empty() );
      PQ.pop();
    }
  }
  //cout << PQ.size() << " " << PQ.top().player << endl;
  PQ2.push((Point){time_sum[PQ.top().player],PQ.top().player});
  

  cout <<PQ2.top().player<<endl;
  //cout <<PQ2.top().score<<endl;
  
  return 0;
}

Measured memory_bytes: 18256
# C Walk on Multiplication Table
import math

def calc():
    #約数求める
    yakusuu_list = [1]
    for i in range(2, int(math.sqrt(N) + 1e-9) + 1):
        if N % i == 0:
            yakusuu_list.append(i)
            #if N != i**2:
            #    if N % i**2 == 0:
            #        yakusuu_list.append(i**2)
    
    yakusuu_list.append(N)

    min_walk = 10000000000000
    for yak in yakusuu_list:
        ans = N / yak
        walk = ans + yak
        if walk < min_walk:
            min_walk = walk
    
    final_ans = min_walk - 2
    print(int(final_ans))

if __name__ == "__main__":
    N = int(input())
    calc()

Measured memory_bytes: 3064
n = int(input())
keta = len(str(n))
if keta == 1:
    print(n)
elif keta == 2:
    print(9)
elif keta == 3:
    print(n-90)
elif keta == 4:
    print(909)
elif keta == 5:
    print(n-9090)
else:
    print(90909)

Measured memory_bytes: 3060
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::Str str = data->getStr();
	const std::string s = str[0];

	if ("RRR" == s) {
		printf("3\n");
	} else if ("SSS" ==  s) {
		printf("0\n");
	} else if ("RSR" == s) {
		printf("1\n");
	} else if ("RSS" == s) {
		printf("1\n");
	} else if ("SSR" == s) {
		printf("1\n");
	} else if ("SRS" == s) {
		printf("1\n");
	} else if ("RRS" == s) {
		printf("2\n");
	} else if ("SRR" == s) {
		printf("2\n");
	}

	delete(data);

	return 0;
}

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

string S;

int main(){
	cin >> S;
	while(S != "ABC"){
		if(S.length()  < 3){
				cout << "No" << endl;
				return 0;
		}
		string T;
		if(S.substr(0, 3) == "ABC") T = "A";
		else if(S.substr(S.length() - 3, 3) == "ABC") T = "C";
		else if(S.substr(0, 2) == "AA" && S.substr(S.length() - 2, 2) == "CC") T = "B";
		else{
			cout << "No" << endl;
			return 0;
		}
		int cnt = 0;
		for(int i = 0; i < S.length() - 2; i++){
			if(S.substr(i, 3) == "ABC"){
				S = S.substr(0, i) + T + S.substr(i + 3, S.length() - i - 3);
				cnt++;
			}
		}
		if(cnt == 0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3260
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int i;
  char hoge[5];
  scanf("%s", hoge);
  for (i = 0; i < 3; ++i)
  {
    if (hoge[i] == hoge[i + 1])
    {
      puts("Bad");
      return 0;
    }
  }
  puts("Good");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b;
    cin>>a;
    if(a>=100000) cout<<"90909"<<endl;
    else if(a>=10000) cout<<(a-9999)+900+9<<endl;
    else if(a>=1000) cout<<"909"<<endl;
    else if(a>=100) cout<<(a-99)+9<<endl;
    else if(a>=10) cout<<"9"<<endl;
    else cout<<a<<endl;
}



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

int num;
int a[21][21];

int retcost(int Island){
	int x=0;
	for(int i=1;i<=num;i++){
		if(a[Island][i]){
			a[i][Island]=0;
			x=max(x,a[Island][i]+retcost(i));
		}
	}
	return x;
}

int main(void){
	while(cin>>num,num){
		int I1,I2,t,ans,I[num+1]={},Cost=0;
		memset(a,0,sizeof(a));
		for(int i=1;i<num;i++){
			cin>>I1>>I2>>t;
			a[I1][I2]=a[I2][I1]=t;
			I[I1]++,I[I2]++;
			Cost+=t*2;
		}
		for(int i=1;i<=num;i++){
			for(int j=1;j<=num;j++){
				if((I[i]==1||I[j]==1)&&!((I[i]==1&&i==1)||(I[j]==1&&j==1))){
					Cost-=a[i][j]*2;
					a[i][j]=a[j][i]=0;
				}
			}
		}
		ans=Cost-retcost(1);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    map<int,string>m;
    vector<string>v;
    int l,n;
    string s,str;
    cin>>l>>n;
    for(int i=0;i<l;i++)
    {
        cin>>s;
        //m[i]=s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());


    for(int i=0;i<l;i++)
    {
        cout<<v[i];
    }
v.clear();
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,N;
	scanf("%d",&N);
	N>=10&&N<=99;
	a=N/10;
	b=N%10;
	if(a==9)
	{
		printf("Yes");
		
	 } 
	 else if(b==9)
	 {
	 	printf("Yes");
	 }
	 else 
	 {
	 	printf("No");
	 }
	 return 0;
	 
}
 

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

struct point{
    int x, y;
}w[110];
int n;
double P[210];
const double PI = acos(-1.0);

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> w[i].x >> w[i].y;
    }
    for(int i = 1; i <= n; i++)
    {
        int cnt = 0;
        for(int j = 1; j <= n; j++)
        {
            if(i == j) continue;
            P[cnt++] = atan2(w[j].y - w[i].y, w[j].x - w[i].x);
        }
        sort(P, P+cnt);
        for(int j = 0; j < cnt; j++) P[j + cnt] = P[j]+2* PI;
        double res = 0.0;
        for(int j = 0; j < cnt; j++) {
            res = max(res, PI - P[j + cnt - 1] + P[j]);
        }
        printf("%.10f\n", res/(2*PI));
    }
    return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);
  vector<int64_t> Lucas(N + 1);
  for (int i = 0; i < Lucas.size(); i++) {
    if (i == 0) {
      Lucas.at(i) = 2;
    }
    else if (i == 1) {
      Lucas.at(i) = 1;
    }
    else {
      Lucas.at(i) = Lucas.at(i - 1) + Lucas.at(i - 2);
    }
  }
  printf("%ld" , Lucas.at(N));
}

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>), (<*))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl read <*> getLine <*> getLine >>= print

solve :: Int -> String -> String -> Int
solve n s t = f n s t
  where
    f a [] _ = a
    f a xs ys
      | xs `isPrefixOf` ys = a
      | otherwise = f (a+1) (tail xs) ys

getl :: (String -> a) -> IO a
getl f = f <$> getLine


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

void Main()
{
    int64_t X, Y, Z;
    cin >> X >> Y >> Z;

    int64_t temp;
    temp = X;
    X = Y;
    Y = temp;

    temp = Z;
    Z = X;
    X = temp;    
    cout << X << " " << Y << " " << Z << endl;
}

int main()
{
    Main();
}


Measured memory_bytes: 256
type UF
	n::Int
	pr::Array{Int}
	sz::Array{Int}
	UF(n)=new(n,1:n,ones(Int,n))
end
function find(uf::UF,a::Int)
	if uf.pr[a]==a
		a
	else
		uf.pr[a]=find(uf,uf.pr[a])
	end
end
same(uf::UF,a::Int,b::Int)=find(uf,a)==find(uf,b)
function unite(uf::UF,a::Int,b::Int)
	ap=find(uf,a)
	bp=find(uf,b)
	if ap==bp
		false
	else
		if uf.sz[ap]<uf.sz[bp]
			uf.pr[ap]=bp
			uf.sz[bp]+=uf.sz[ap]
		else
			uf.pr[bp]=ap
			uf.sz[ap]+=uf.sz[bp]
		end
		true
	end
end
size(uf::UF,a::Int)=uf.sz[find(uf,a)]
function main()
	N,M=map(x->parse(Int,x),split(readline()))
	pr=-ones(Int,M)
	uf=UF(N)
	for i=1:N
		L=map(x->parse(Int,x),split(readline()))
		shift!(L)
		for l=L
			if pr[l]<0
				pr[l]=i
			else
				unite(uf,pr[l],i)
			end
		end
	end
	for i=1:N
		if !same(uf,1,i)
			println("NO")
			exit()
		end
	end
	println("YES")
end
main()


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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 SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int n;
const int NMAX = 100010;
VVL tree(NMAX);
VL depth_s(NMAX), depth_g(NMAX);

void dfs(LL v, LL p, LL d,bool s){
    if (s) {
        depth_s[v] = d;
    }
    else {
        depth_g[v] = d;
    }

    for (auto&& var : tree[v]) {
        if (var == p) {
            continue;
        }
        dfs(var,v,d+1,s);
    }
}

int main(int argc, char const* argv[])
{
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a,b;
        cin  >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    dfs(1,-1,0,true);
    dfs(n,-1,0,false);
    LL w = 0,b = 0;
    for (int i = 1; i < n+1; i++) {
        if (depth_s[i] > depth_g[i]) {
            w++;
        }
        else {
            b++;
        }
    }

    if (w >= b) {
        cout << "Snuke" << endl;
    }
    else {
        cout << "Fennec" << endl;
    }
    return 0;
}



Measured memory_bytes: 13568
#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(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 2e5 + 5;

ll P[N];
ll n;
ll a[N];
ll R[N][22];
ll B[N];

ll ans;

ll RMQ (ll l, ll r){
    if (l < 1 || n < r)
        return N;
    ll x = B[r - l + 1];
    ll y = r - P[x] + 1;
    return max (R[l][x], R[y][x]);
}

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    P[0] = 1;
    for (ll i = 1; i <= 20; i++)
        P[i] = P[i - 1] * 2;
    cin >> n;
    for (ll i = 2; i <= n; i++){
        B[i] = B[i - 1];
        if ((i & (i - 1)) == 0)
            B[i]++;
    }
    for (ll i = 1; i <= n; i++){
        cin >> a[i];
        R[i][0] = a[i];
    }
    for (ll I = 1; (1 << I) <= n; I++)
        for (ll i = 1; i + P[I] <= n + 1; i++)
            R[i][I] = max (R[i][I - 1], R[i + P[I - 1]][I - 1]);
    for (ll i = 1; i <= n; i++){
        ll l1, l2, r1, r2;
        ll l = 0, r = i - 1;
        while (l < r){
            ll mid = l + r + 1 >> 1;
            if (RMQ (mid, i - 1) >= a[i])
                l = mid;
            else
                r = mid - 1;
        }
        l2 = l;
        l = 0, r = l2 - 1;
        while (l < r){
            ll mid = l + r + 1 >> 1;
            if (RMQ (mid, l2 - 1) >= a[i])
                l = mid;
            else
                r = mid - 1;
        }
        l1 = l;
        l = i + 1, r = n + 1;
        while (l < r){
            ll mid = l + r >> 1;
            if (RMQ (i + 1, mid) > a[i])
                r = mid;
            else
                l = mid + 1;
        }
        r1 = l;
        l = r1 + 1, r = n + 1;
        while (l < r){
            ll mid = l + r >> 1;
            if (RMQ (r1 + 1, mid) > a[i])
                r = mid;
            else
                l = mid + 1;
        }
        r2 = r;
        ll num = (r2 - r1) * (i - l2) + (l2 - l1) * (r1 - i);
        ans += num * a[i];
        //cout << i << " " << num << " " << l1 << " " << l2 << " " << r1 << " " << r2 << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24064
import java.util.BitSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static int[][] cost;
	public static int allcost;
	public static int[][][][] dp;
	public static int[][][][] max;
	public static int[][][][] min;
	public static int h, w, s;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			h = in.nextInt();
			w = in.nextInt();
			s = in.nextInt();
			if(h == 0) return;
			cost = new int[h][w];
			dp = new int[h][w][h][w];
			max = new int[h][w][h][w];
			min = new int[h][w][h][w];
			allcost = 0;
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					cost[i][j] = in.nextInt();
					allcost += cost[i][j];
					dp[i][j][i][j] = cost[i][j];
					max[i][j][i][j] = 1;
				}
			}
			for(int i=0; i<h; i++){
				for(int j=0; j<w-1; j++){
					for(int k=j+1; k<w; k++){
						dp[i][j][i][k] = dp[i][j][i][k-1] + cost[i][k];
					}
				}
			}
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					min[i][j][i][j] = s - allcost + cost[i][j];
					for(int k=j; k<w; k++){
						for(int l=i+1; l<h; l++){
							dp[i][j][l][k] = dp[i][j][l-1][k] + dp[l][j][l][k];
						}
					}
				}
			}
			dfs(0, 0, w-1, h-1);
			System.out.println(max[0][0][h-1][w-1]+" "+min[0][0][h-1][w-1]);
		}
	}
	
	public static int dfs(int x1, int y1, int x2, int y2){
		if(max[y1][x1][y2][x2] != 0) return min[y1][x1][y2][x2];
		if(s - allcost + dp[y1][x1][y2][x2] < 0){
			max[y1][x1][y2][x2] = -1;
			return -1;
		}
		int mincand = s;
		int maxcand = 0;
		for(int x=x1; x<x2; x++){
			int tmp = Math.min(dfs(x1, y1, x, y2), dfs(x+1, y1, x2, y2));
			if(tmp < 0) continue;
			if(maxcand == max[y1][x1][y2][x] + max[y1][x+1][y2][x2]){
				mincand = Math.max(mincand, tmp);
			}else if(maxcand < max[y1][x1][y2][x] + max[y1][x+1][y2][x2]){
				maxcand = max[y1][x1][y2][x] + max[y1][x+1][y2][x2];
				mincand = tmp;
			}
		}
		for(int y=y1; y<y2; y++){
			int tmp = Math.min(dfs(x1, y1, x2, y), dfs(x1, y+1, x2, y2));
			if(tmp < 0) continue;
			if(maxcand == max[y1][x1][y][x2] + max[y+1][x1][y2][x2]){
				mincand = Math.max(mincand, tmp);
			}else if(maxcand < max[y1][x1][y][x2] + max[y+1][x1][y2][x2]){
				maxcand = max[y1][x1][y][x2] + max[y+1][x1][y2][x2];
				mincand = tmp;
			}
		}
		if(maxcand == 0){
			maxcand = 1;
			mincand = s - allcost + dp[y1][x1][y2][x2];
		}
		max[y1][x1][y2][x2] = maxcand;
		return min[y1][x1][y2][x2] = mincand;
	}
	
	public static String dump(int[][] map, int h, int w){
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				sb.append(map[i][j]+" ");
			}
			sb.append("\n");
		}
		return sb.toString();
	}
}

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

def main():
    S = input().strip()
    ch = "abcdefghijklmnopqrstuvwxyz"
    check = [False] * len(ch)
    for c in S:
        for i in range(len(ch)):
            if c == ch[i]:
                check[i] = True
    
    ans = "None"
    for i in range(len(ch)):
        if not check[i]:
            ans = ch[i]
            break
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector<pair<int,int> > v[n+1];
    for(int i=0;i<n-1;i++)
    {
        int a,b,w;
        scanf("%d%d%d",&a,&b,&w);
        v[a].push_back(make_pair(b,w));
        v[b].push_back(make_pair(a,w));
    }
    vector<bool> vis(n+1,0);
    queue<int> q;
    vector<bool> res(n+1);
    vis[1]=1;
    q.push(1);
    res[1]=0;
    while(!q.empty())
    {
        int e=q.front();
        q.pop();
        for(pair<int,int> p:v[e])
        {
            if(!vis[p.first])
            {
                vis[p.first]=1;
                q.push(p.first);
                if(p.second&1) res[p.first]=!res[e];
                else res[p.first]=res[e];
            }
        }
    }
    for(int i=1;i<=n;i++) printf("%d\n",(res[i]?0:1));
    return 0;
}


Measured memory_bytes: 6400
n = int(input())
a = [int(i) for i in input().split()]
print(' '.join([str(i) for i in a]))

for i in range(1, n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    print(' '.join([str(i) for i in a]))


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(c-b == b-a){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N;
    cin >> N;
    vector<ll> lucas(100);
    lucas[0]=2;
    lucas[1]=1;
    for(int i=2;i<100;i++){
        lucas[i]=lucas[i-1]+lucas[i-2];
    }
    cout <<lucas[N]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  int N ;
  cin >> N ;
  double ans=0;
  for(int i=0;i<N;i++){
  double num;
  string str;
    cin >> num >> str ;
  if (str=="BTC") num*=380000;
    ans+=num;
  }
cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,a,b;
	char c[100];
	while(1){
		a = 0; b = 0; i = 0;
		scanf("%s",c);
		if(c[0] == '0')
			break;
		while(1){
			if(c[i+1] == 'A')
				a++;
			else if(c[i+1] == 'B')
				b++;
			else
				break;
			i++;
		}
		if(a > b)
			a++;
		else
			b++;
		printf("%d %d\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 536
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static final int MAX = 20000;
	public static final int SQRT = (int)(Math.ceil(Math.sqrt(MAX)));
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int t = sc.nextInt();
		
		boolean[] is_prime = new boolean[MAX + 1];
		Arrays.fill(is_prime, true);
		is_prime[0] = is_prime[1] = false;
		for(int i = 2; i <= SQRT; i++){
			if(is_prime[i]){
				for(int j = 2 * i; j <= MAX; j += i){
					is_prime[j] = false;
				}
			}
		}
		
		for(int tt = 0; tt < t; tt++){
			final int m = Math.abs(sc.nextInt());
			final int n = Math.abs(sc.nextInt());
			
			final int divide = m * m + n * n;
			/*
			int max = Math.max(Math.abs(m), Math.abs(n));
			
			max *= max;
			
			int count = 0;
			for(int p = -divide; p <= divide; p++){
				for(int q = -divide; q <= divide; q++){
					final int x_ = m * p + n * q;
					final int y_ = m * q - n * p;
					
					//System.out.println(p + " " + q);
					
					if(x_ % divide != 0 || y_ % divide != 0){
						continue;
					}else if(x_ == 0 && y_ == 0){
						continue;
					}
					
					final int x = x_ / divide;
					final int y = y_ / divide;
					
					final int pq = p * p + q * q;
					final int divide2 = x * x + y * y;
					
					if(divide * divide2 != pq){
						continue;
					}
					
					System.out.println("=> " +  p + " " + q + " " + x + " " + y);
					
					count++;
				}
			}
			*/
			
			boolean flag = false;
			
			if(m != 0 && n != 0){
				flag = is_prime[divide];
			}else if(m == 0){
				flag = is_prime[n] && n % 4 == 3;
			}else if(n == 0){
				flag = is_prime[m] && m % 4 == 3;
			}
			System.out.println(flag ? "P" : "C");
		}
		
	}

}

Measured memory_bytes: 21072
# -*- coding: utf-8 -*-
from heapq import heappush, heappop

if __name__ == '__main__':

    n = int(input())
    M = [set() for i in range(n)]

    for i in range(n):
        l = list(map(int, input().split(" ")))
        for k in range(l[1]):
            j = l[2 + 2 * k]
            c = l[2 + 2 * k + 1]
            M[i].add((j, c))

    d = [float("inf")] * n
    h = []

    def dijkstra(s):
        color = [0] * n
        p = [None] * n
        d[s] = 0
        heappush(h, (d[s], s))

        while h:
            _, u = heappop(h)

            color[u] = 2

            for v, c in M[u]:
                if color[v] != 2:
                    if d[u] + c < d[v]:
                        d[v] = d[u] + c
                        color[v] = 1
                        heappush(h, (d[v], v))

    dijkstra(0)
    for i in range(n):
        print(i, d[i])



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s;
    cin >> s;
    ll y = stoi(s.substr(0, 4));
    ll m = stoi(s.substr(5, 2));
    ll d = stoi(s.substr(8, 2));
    vector<ll> v1({2019, 4, 30}), v2({y, m, d});
    if(v2 <= v1) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
const int MaxN = 1e5;
long long T, n, m;
int a[MaxN + 5];
int main()
{
	scanf("%lld%lld", &n, &m);
	int ans = 0; 
	while(n <= m)
	{
		ans++;
		n *= 2;
	}
	printf("%d\n", ans);
}

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

using namespace std;

typedef unsigned long long ll;

const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};


int main(){
   int a,b;
   int m;
   cin >> a>>b>>m;
   
   vector<int> a_(a);
   vector<int> b_(b);
    rep(i, a) cin >> a_[i];
    rep(i, b) cin >> b_[i];
    
    vector<int> x_(m);
    vector<int> y_(m);
    vector<int> c_(m);

    rep(i, m) cin >> x_[i] >> y_[i] >> c_[i];
    int min_ = 100100100100100;
    rep(i, m){
        int sum_ = a_[x_[i]-1] + b_[y_[i]-1] - c_[i];
        min_ = min(sum_, min_);
    }
    sort(a_.begin(), a_.end());
    sort(b_.begin(), b_.end());

    min_ = min(a_[0]+b_[0], min_);

    cout << min_;

    return 0;

}

Measured memory_bytes: 2176
object Main extends App {
    val stdin = new java.util.Scanner(new java.io.BufferedInputStream(System.in))
    val stdout = new java.io.PrintWriter(new java.io.BufferedOutputStream(System.out))

    while (stdin.hasNext()) {
        val foo = stdin.nextInt()
        var bar : Long = 0
        for (i <- 1 to foo) {
            val x : Long = i
            val k : Long = foo / x
            bar += (x + x * k) * k / 2
        }
        stdout.printf("%d\n", bar.asInstanceOf[java.lang.Long])
    }

    stdin.close()
    stdout.close()
}

Measured memory_bytes: 55460
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:


    Int func(const vector<Int> &vec) {
        vector<Int> p;
        for (int i = 1; i <= vec.size(); ++i) p.push_back(i);

        Int ret = 0;
        do {
            ret++;
            if (vec == p) return ret;
        } while (next_permutation(all(p)));

        return ret;
    }

    void solve() {
        Int N;
        cin >> N;
        vector<Int> P(N), Q(N);
        for (int i = 0; i < N; ++i) {
            cin >> P[i];
        }

        for (int i = 0; i < N; ++i) {
            cin >> Q[i];
        }

        Int a = func(P);
        Int b = func(Q);

        Int ans = abs(a - b);
        cout << ans << endl;
    }

};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, n);
	VEC(int, a, n);
	sort(ALL(a));

	int ans = a.back() - a[0];
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pvar(x) clog<<"["<<#x<<":"<<x<<"]\n"
using namespace std;
using ll = long long int;
void solve(){
	int k;
	cin>>k;
	if(k%2 == 0 || k%5==0){
		cout<<"-1\n";
		return;
	}
	int num = 7%k, cnt=1 ,rem=num;
	while(rem!=0){
		num = ((num%k)*10)%k;
		rem = ((rem%k) + (num%k))%k;
	  ++cnt;
	}
	cout<<cnt;
}
int main(){
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while(t--){
		solve();
	}
}
 


Measured memory_bytes: 3624
const MOD: usize = 998244353;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let m = sc.read();
    let a: Vec<Vec<i64>> = (0..n).map(|_| sc.vec(m)).collect();
    let rank = f2_gauss_jordan(a);
    let ans = (pow(2, n) + MOD - pow(2, n - rank)) % MOD * pow(2, m - 1);
    println!("{}", ans % MOD);
}

fn f2_gauss_jordan(mut a: Vec<Vec<i64>>) -> usize {
    let n = a.len();
    let m = a[0].len();
    let mut rank = 0;
    let mut row = 0;
    for col in 0..m {
        match (row..n).filter(|&i| a[i][col] == 1).next() {
            Some(pivot) => {
                a.swap(row, pivot);
                rank += 1;
                for k in (row + 1)..n {
                    if a[k][col] == 1 {
                        for i in 0..m {
                            a[k][i] ^= a[row][i];
                        }
                    }
                }

                row += 1;
            }
            None => {}
        }

        if row >= n {
            break;
        }
    }
    rank
}

fn pow(mut x: usize, mut e: usize) -> usize {
    let mut result = 1;
    while e > 0 {
        if e & 1 == 1 {
            result *= x;
            result %= MOD;
        }
        e >>= 1;
        x *= x;
        x %= MOD;
    }
    result
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
  ll n,k,cur=1,count=0,check,span;
  cin >> n >> k;
  vector<ll> a(n+10),b(n+10,0);
  rep(i,n){
    cin >> a.at(i+1);
  }
  
  while(true){
    if(b.at(cur) == 1){
      check = count;
      b.at(cur)++;
      count++;
      cur = a.at(cur);
      break;
    }
    if(count == k){
      cout << cur << endl;
      return 0;
    }
    b.at(cur)++;
    count++;
    cur = a.at(cur);
  }
  while(true){
    if(b.at(cur) == 2){
      span = count - check;
      k = (k-count) % span;
      count = 0;
      // cur = a.at(cur);
      break;
    }
    if(count == k){
      cout << cur << endl;
      return 0;
    }
    b.at(cur)++;
    count++;
    cur = a.at(cur);
  }
  while(true){
    if(count == k){
      cout << cur << endl;
      return 0;
    }
    count++;
    cur = a.at(cur);
  }
  
  return 0;
}


Measured memory_bytes: 6428
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = [0] + list(map(int, readline().split()))
    dp = [0] * (n + 1)
    dp[0] = 1000

    for i in range(1, n + 1):
        dp[i] = dp[i - 1]
        for j in range(1, i):
            s = dp[j] // a[j]
            m = s * a[i] + dp[j] % a[j]
            dp[i] = max(dp[i], m)

    print(dp[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 64032
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF -1000000000
#define pi atan(1)*4
#define MOD 1000000000+7L
#define eps 0.0000006
#define MAX_V 10000
 
using namespace std;

vi a;
vi estado;

int solve(int i){
	if(i == 0) return 0;
	if(i == 1) return abs(a[1]-a[0]);

	if(estado[i] != INF) return estado[i];

	estado[i] = min(solve(i-1)+abs(a[i]-a[i-1]),solve(i-2)+abs(a[i]-a[i-2]));

	return estado[i];
}

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

	cin >> n;

	a.assign(n,0);
	estado.assign(n,INF);

	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}

	cout << solve(n-1) << '\n';

	return 0;
}

Measured memory_bytes: 3328