akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2007;

int n, ans[maxn], D[maxn];
vector <int> adj[maxn];

void Dijkstra(int g)
{
    for (int i = 1; i <= n; ++i) D[i] = INT_MAX;
    D[g] = 0;
    set <pair <int, int> > S;
    S.insert({0, g});
    while ((int)S.size())
    {
        pair <int, int> p = *S.begin();
        S.erase(S.begin());
        int u = p.second;
        if (D[u] < p.first) continue;
        for (int v: adj[u])
            if (D[v] > D[u] + 1)
            {
                D[v] = D[u] + 1;
                S.insert({D[v], v});
            }
    }

    for (int i = 1; i <= n; ++i) ++ans[D[i]];
}

int main()
{
//    freopen("TEST.INP", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int x, y;
    cin >> n >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    for (int i = 2; i <= n; ++i)
        adj[i].push_back(i - 1), adj[i - 1].push_back(i);
    for (int i = 1; i <= n; ++i) Dijkstra(i);
    for (int i = 1; i < n; ++i)
        cout << ans[i] / 2 << '\n';
    return 0;
}


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

int n;
int res = 1;
vector<int> d(110);


int main(){
  cin >> n;
  rep(i, n)cin >> d.at(i);
  sort(d.begin(), d.begin()+n);
  for(int i = 1; i < n; i++){
    //cout << d.at(i);
    if(d.at(i-1) != d.at(i)){
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n-1);
    rep(i,n-1)cin >> a[i];
    int ans = a.front() + a.back();
    rep(i,n-2)ans += min(a[i],a[i+1]);
    cout << ans << endl;
}


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

#define INDEXED_SET 0

#if INDEXED_SET
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using indexed_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
//find_by_order(i) - iterator to i-th element
//order_of_key(x) - x's index in the set
#endif

#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define leading_0s(x) __builtin_clz(x)  //left 0s
#define trailing_0s(x) __builtin_ctz(x) //right 0s
#define count_1s(x) __builtin_popcount(x)
#define parity_1s(x) __builtin_parity(x) // 0 = even, 1 = odd
#define FORI(i,a,b) for (int i = int((a)); i <= int((b)); i++)
#define FORD(i,a,b) for (int i = int((a)); i >= int((b)); i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair

#define endl '\n'
#define MAX 200005

using ll = long long;
using pi = pair<int,int>;
using pll = pair<long,long>;
using vi = vector<int>;
using vll = vector<ll>;
using vpi = vector<pi>;
using vpll = vector<pll>;

const int mod = 1e9 + 7;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;


int main()
{
    FAST_IO;

    int n;
    cin >> n;
    vi v(n);
    for (auto &e:v)
        cin >> e;
    sort(v.begin(), v.end());
    
    int ans = 0;
    int teto = 1e5;
    FORI(i,1,teto) {
        auto it = lower_bound(v.begin(), v.end(), i);
        if (int(v.size() / 2) == it - v.begin())
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))

bad=set()
c=0
for i in range(M):
	A,B=list(map(int,input().split()))
	if (H[A-1]<=H[B-1])and(A-1 not in bad):
		bad.add(A-1)
	if (H[A-1]>=H[B-1])and(B-1 not in bad):
		bad.add(B-1)

print(N-len(bad))

Measured memory_bytes: 20104
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
int n;
string s;
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
bool search(string text, string pattern) 
{ 
    string concat = pattern + "$" + text; 
    int l = concat.length(); 
    vector<int> Z;
    Z = z_function(concat); 
    for (int i = 0; i < l; ++i) 
    { 
        if (Z[i] == pattern.length()) 
            return true;
    }
    return false; 
} 
bool check(int len)
{
    string sub = s.substr(0,len);
    string text = s.substr(len);
    if(search(text,sub))
    {
        return true;
    }
    for(int i=len;i+len<n;i++)
    {
        sub.erase(sub.begin());
        sub.pb(s[i]);
        text = s.substr(i+1);
        if(search(text,sub))
            return true;
    }
    return false;
}
signed main()
{
    fast;
    cin>>n;
    cin>>s;
    int low = 1,high = n/2;
    int ans = -1;
    while(low<=high)
    {
        int mid = (low+high)/2;
        //cout<<mid<<endl;
        if(check(mid))
        {
            ans = mid;
            low = mid+1;
        }
        else high = mid-1;
    }
    //cout<<check(6)<<endl;
    if(ans == -1)
        cout<<0;
    else cout<<ans;
}

Measured memory_bytes: 512
#include <stdio.h>

void bubbleSort(int *,int);

int main(){
  int i,N;
  int A[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  bubbleSort(A,N);
  return 0;
}

void bubbleSort(int *A,int N){
  int flag = 1; // 逆の隣接要素が存在する
    int j,x,count=0;
    while(flag){
      flag = 0;
	for(j=N-1;j>0;j--){
	  if(A[j] < A[j-1]){
	    x = A[j];
	    A[j]=A[j-1];
	    A[j-1]=x;
	    flag = 1;
	    count++;
	  }
	}
    }
    for(j=0;j<N;j++){
      printf("%d",A[j]);
      if(j!=N-1)printf(" ");
    }
    printf("\n%d\n",count);
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n;
  cin>>n;
  vector<int> a(n);
  deque<int> b;
  r(i,n)cin>>a.at(i);
  //reverse(a.begin(),a.end());

  for(int i=0;i<n;i++){
    //int tmp=(n-1)%2;
    if(i%2==n%2){
      b.push_back(a.at(i));
      //r(j,b.size())cout<<b.at(j)<<" ";
      //cout<<endl;
    }else{

      b.push_front(a.at(i));
      //r(j,b.size())cout<<b.at(j)<<" ";
      //cout<<endl;
    }
  }
  r(i,n){
    cout<<b.at(i)<<" ";
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 3840
fun main(args: Array<String>) = println(run {
    fun IntArray.accumulated(): List<Int> { var sum = 0; return this.map { sum += it; sum } }
    
    val (n,q) = readLine()!!.split(" ").map { it.toInt() }
    val s = "X" + readLine()!!
    val lr = (1..q).map { readLine()!!.split(" ").map { it.toInt() } }

    val ac = IntArray(s.length)
    Regex("AC").findAll(s).map { it.range.last }.forEach { ac[it] = 1 }
    val acs = ac.accumulated()

    lr.map { acs[it[1]]-acs[it[0]] }.joinToString("\n")
})



Measured memory_bytes: 85240
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    int n;
    int ans = 0;
    cin >> n;
    vector<long long> t(n);
    vector<long long> f(n);

    for (int i=0; i<n; i++) {
        int a; cin >> a;
        for (int j=0; j<a; j++) {
            int x,y;
            cin >> x >> y; x--;
            if (y) t[i] |= (1<<x);
            else f[i] |= (1<<x);
        }
    }

    for (int i=0; i<(1<<n); i++) {
        bool flag = true;
        int cnt = 0;

        for (int j=0; j<n; j++) {
            if (i>>j&1) {
                cnt++;
                if ((i|t[j]) != i) flag = false;
                if ((i&f[j]) != 0) flag = false;
            }
        }

        if (flag) {
            ans = max(ans, cnt);
        }
    }

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

Measured memory_bytes: 888
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
from numba import njit
def main():
    n = int(input())
    @njit
    def s(n):
        res = 0
        for i1 in range(1, n + 1):
            for i2 in range(1, n + 1):
                if i1 * i2 >= n:
                    break
                else:
                    res += 1
        return res
    r = s(n)
    print(r)

if __name__ == '__main__':
    main()


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

int main() {
	
  int X, Y;
  cin >> X >> Y;
  if(Y%2 != 0){
    cout << "No" << endl;
  }
  else if(Y < 2*X){
    cout << "No" << endl;
  }
  else if(Y > 4*X){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    final String LINE_SPR = System.getProperty("line.separator");
    final int BIG_MOD = 1000000007;

    void run() throws Exception {
        String line;
        while((line = br.readLine()) != null) {
            String[] nums = line.split(" ");
            System.out.println(Integer.parseInt(nums[0]) + Integer.parseInt(nums[1]));
        }
    }


    /*
     * Templates
     */
    void dumpObjArr(Object[] arr, int n) {
        for(int i = 0; i < n; i++) {
            System.out.print(arr[i]);
            if(i < n - 1)
                System.out.print(" ");
        }
        System.out.println("");
    }

    void dumpObjArr2(Object[][] arr, int m, int n) {
        for(int j = 0; j < m; j++) 
            dumpObjArr(arr[j], n);
    }

    int ni() throws Exception {
        return Integer.parseInt(br.readLine().trim());
    }

    long nl() throws Exception {
        return Long.parseLong(br.readLine().trim());
    }

    String ns() throws Exception {
        return br.readLine();
    }

    boolean isPrime(int n) {
        for(int i=2;i<n;i++) {
            if(n%i==0)
                return false;
        }
        return true;
    }

    int getPrime(int n) {
        List<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        int count = 1;

        int x = 1;
        while(primes.size() < n) {
            x+=2;
            int m = (int)Math.sqrt(x);
            for(int p : primes) {
                if(p > m) {
                    primes.add(x);
                    break;
                }

                if(x % p == 0) 
                    break;
            }
        }

        return primes.get(primes.size() - 1);
    }

    long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    long gcd(long a, long b) {
        if(a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        // a >= b
        long mod = a % b;
        if(mod == 0) 
            return b;
        else 
            return gcd(b, mod);
    }

    void gcjPrint(String str, int t) {
        System.out.println("Case #" + t + ": " + str);
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 17004
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int a,b,c;

  cin >>  a >> b >> c ;


  if(a+b==c) cout << "Yes" << endl;

  else if(a+c==b) cout << "Yes" << endl;

  else if(b+c==a) cout << "Yes" << endl;

  else cout << "No" << endl;


  
  return 0;
}

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




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

    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
    ll a,b,c;
    cin >> a >> b >> c;

    if(a+b >= c)
    {
        cout << c+b;
    }
    else
    {
        ll ans;
        ans = 2*b;
        //c -= b;
        ans += a;
        c-=a;
        c-=b;
        if(c > 0)
            ++ans;
        cout << ans;
    }
    return 0;
}

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

bool pal(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  string S;
  cin >> S;
  
  string T = S;
  T = regex_replace(T, regex("x"), "");
  
  if (!pal(T)) return cout << -1 << "\n", 0;

  int N = T.size() + 1;

  vector<int> V(N);

  for (int i = 0, it = 0; i < S.size(); i++) {
    if (S.at(i) == 'x') V.at(it)++;
    else it++;
  }

  int ans = 0;
  for (int i = 0; i < N / 2; i++) {
    int j = N - i - 1;
    ans += abs(V.at(i) - V.at(j));
  }
  cout << ans << "\n";
}

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

int main(){
 	char b;
  	cin>>b;
  		if(b=='A'){
          cout<<'T'<<endl;
  		  return 0;
        }
  		if(b=='T'){
          cout<<'A'<<endl;
  		  return 0;
        }
  		if(b=='C'){
          cout<<'G'<<endl;
  		  return 0;
        }
  		if(b=='G'){
          cout<<'C'<<endl;
		  return 0;
        }
}  

Measured memory_bytes: 256
def alllist(n,stre):
    if n == 0:
        return [[stre]]
    else:
        oldlist = alllist(n-1,stre)
        newlist = oldlist[:]
        for elements in oldlist:
            new1 = elements[:]
            temp1 = new1[0][:(len(stre) - n)]
            temp2 = new1[0][(len(stre) - n):]
            new1 = new1[1:]
            new1.insert(0,temp1)
            new1.insert(1,temp2)
            newlist.append(new1)
        return newlist

s=input()

lista=alllist(len(s)-1,s)
aaaaa=0

for elemens in lista:
    for i in elemens:
        listb=[]
        listb.append(int(i))
        aaaaa += sum(listb)

print(aaaaa)

Measured memory_bytes: 3064
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
DE = [0] * N
Q = [0]
while Q:
    i = Q.pop()
    for a in X[i][::-1]:
        if a != P[i]:
            P[a] = i
            DE[a] = DE[i] + 1
            X[a].remove(i)
            Q.append(a)

def lp(u, v):
    t = 0
    while u != v:
        if DE[u] > DE[v]:
            t += 1 << u-1
            u = P[u]
        elif DE[u] < DE[v]:
            t += 1 << v-1
            v = P[v]
        else:
            t += 1 << u-1
            t += 1 << v-1
            u = P[u]
            v = P[v]
    
    return t

Y = []
M = int(input())
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    Y.append(lp(a, b))

D = {1<<i: i for i in range(50)}
Z = [0] * (1<<M)
ans = 0
CC = [0] * N
BC = [0] * (1<<17)
for m in range(1, 1<<17):
    a = m & (-m)
    BC[m] = BC[m^a] + 1
for m in range(1<<M):
    a = m & (-m)
    if a == m:
        if a == 0:
            Z[m] = 0
        else:
            Z[m] = Y[D[a]]
    else:
        Z[m] = Z[m^a] | Y[D[a]]
    
    aa = Z[m]
    bc = BC[aa % (1<<17)]
    aa >>= 17
    bc += BC[aa % (1<<17)]
    aa >>= 17
    bc += BC[aa]
    CC[N - 1 - bc] += (1 if BC[m%1024] + BC[m>>10] & 1 == 0 else -1)

print(sum([2 ** i * CC[i] for i in range(N)]))

Measured memory_bytes: 50156
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;

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

    int n,m,ans=0;
    cin>>n>>m;

    for (int i=1;i<=sqrt(m);i++) {
        if (m%i == 0) {
            if (m/i >= n) ans=max(ans,i);
            if (i>=n) ans=max(ans,m/i);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,x;
    cin>>n>>x;
    vector<int> m(n);
    for(int i=0;i<n;i++)cin>>m[i];
    sort(m.begin(),m.end());
    for(int i=0;i<n;i++)x -= m[i];
    int res = n;
    res += x/m[0];
    cout<<res<<endl;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<vector<ll>> graph(n);
    for(int i = 0; i < n-1; i++) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    auto dfs = [&](auto self, ll now, ll pre = -1) -> ll{
        ll sum = 0;
        for(auto &to : graph[now]){
            if(to == pre)continue;
            sum ^= self(self, to, now);
        }
        return sum + 1;
    };

    bool ok = dfs(dfs, 0) != 1;
    cout << (ok ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 14780
use std::cmp::min;

fn main() {
    input! {
        n: usize,
        t: [i32; n],
        a: [i32; n],
    }
    let rev_a: Vec<i32> = a.iter().rev().map(|x| *x).collect();
    let mod_num = (1e9 as i64) + 7;
    let mut cofirm = vec![false; n as usize];
    let mut min_list = vec![1e9 as i64; n];
    min_list[0] = min(rev_a[n - 1], t[0]) as i64;
    min_list[n - 1] = min(rev_a[0], t[n - 1]) as i64;
    cofirm[0] = true;
    cofirm[n - 1] = true;
    // check for rift
    if t[0] > rev_a[n - 1] || rev_a[0] > t[n - 1] {
        println!("{}", 0);
        return;
    }
    for i in 1..n {
        if t[i] > t[i - 1] {
            if t[i] > rev_a[n - 1 - i] {
                println!("{}", 0);
                return;
            }
            cofirm[i] = true;
        }
        if rev_a[i] > rev_a[i - 1] {
            if rev_a[i] > t[n - 1 - i] {
                println!("{}", 0);
                return;
            }
            cofirm[n - 1 - i] = true;
        }
        min_list[i] = min(t[i], rev_a[n - 1 - i]) as i64;
    }

    let mut res: i64 = 1;
    for i in 0..n {
        if !cofirm[i] {
            res *= min_list[i];
            res %= mod_num;
        }
    }

    println!("{}", res);
}

#[macro_export(local_inner_maccros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


Measured memory_bytes: 5992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC140
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(Math.Pow(N,3));
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include <unordered_map>
#include <math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
int main(void) {
    int n;
    cin >> n;
    unordered_map<int, ll> length_and_count;
    for (int i = 0; i < n; ++i) {
        int length;
        cin >> length;
        length_and_count[length]++;
    }
    vll can_be_rectangle_length;
    for (const auto kv: length_and_count) {
        if (kv.second >= 2) {
            can_be_rectangle_length.push_back(kv.first);
        }
    }
    if (can_be_rectangle_length.size() == 0) {
        cout << 0 << endl;
    } else if (can_be_rectangle_length.size() == 1) {
        if (length_and_count[can_be_rectangle_length[0]] >= 4) {
            cout << can_be_rectangle_length[0] * can_be_rectangle_length[0] << endl;
        } else {
            cout << 0 << endl;
        }
    } else {
        sort(can_be_rectangle_length.begin(), can_be_rectangle_length.end(), greater<ll>());
        ll top_and_bottom = can_be_rectangle_length[0];
        ll left_and_right = length_and_count[top_and_bottom] >= 4 ? top_and_bottom : can_be_rectangle_length[1];
        cout << top_and_bottom * left_and_right << endl;
    }
}

Measured memory_bytes: 4388
/* vo01.cpp */
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int hills[10];

	for (int i = 0; i < 10; ++i)
		cin >> hills[i];

	sort(hills, hills + 10, greater<int>());

	for (int i = 0; i < 3; ++i)
		cout << hills[i] << '\n';

	return 0;
}

Measured memory_bytes: 1176
import collections
n=int(input())
a=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
b=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
c=sorted(list(collections.Counter(map(int,input().split())).items()), key=lambda x: x[0])
la=len(a)
lb=len(b)
lc=len(c)
bc=[0]*lb
j=0
tmp=sum(i[1] for i in c)
for i,x in enumerate(b):
  while j<lc and x[0]>=c[j][0]:
    tmp-=c[j][1]
    j+=1
  bc[i]=tmp

abc=[0]*la
j=0
tmp=sum(i[1]*j for i,j in zip(b,bc))
for i,x in enumerate(a):
  while j<lb and x[0]>=b[j][0]:
    tmp-=b[j][1]*bc[j]
    j+=1
  abc[i]=tmp
ans=sum(i[1]*j for i,j in zip(a,abc))
#print(a,b,c,bc,abc,sep="\n")
print(ans)


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

#define BIT(x) (1 << (x))

struct State {
	int cur;
	int light;
	vector<pair<int, int> > log;
	State(){}
};

const int MOVE = 1;
const int OFF = 2;
const int ON = 3;

int n, m;
vector<int> g[15];
vector<int> sw[15];
bool vis[15][1 << 15];

State initial;

void solve()
{
	memset(vis, 0, sizeof(vis));
	
	int ca = 3;
	vector<pair<int, int> > res;
	
	queue<State> q;
	if (initial.light & BIT(0)) q.push(initial);
	
	while (q.size()){
		State st = q.front();
		q.pop();
			
		if (vis[st.cur][st.light]) continue;
		vis[st.cur][st.light] = true;
		
		if (st.cur == n - 1){
			if (st.light == BIT(n - 1)){
				ca = 1;
				res = st.log;
				break;
			}
			else ca = 2;
		}
		
		for (int i = 0; i < g[st.cur].size(); i++){
			State nx = st;
			nx.cur = g[st.cur][i];
			if (st.light & BIT(g[st.cur][i])){
				nx.log.push_back(make_pair(MOVE, nx.cur));
				q.push(nx);
			}
		}
		
		for (int i = 0; i < sw[st.cur].size(); i++){
			if (st.cur == sw[st.cur][i]) continue;
			State nx = st;
			nx.light ^= BIT(sw[st.cur][i]);
			if (nx.light & BIT(sw[st.cur][i])){
				nx.log.push_back(make_pair(ON, sw[st.cur][i]));
			}
			else {
				nx.log.push_back(make_pair(OFF, sw[st.cur][i]));
			}
			q.push(nx);
		}
	}
	
	if (ca == 1){
		printf("You can go home in %d steps.\n", res.size());
		for (int i = 0; i < res.size(); i++){
			if (res[i].first == MOVE){
				printf("Move to room %d.\n", res[i].second + 1);
			}
			else if (res[i].first == OFF){
				printf("Switch off room %d.\n", res[i].second + 1);
			}
			else if (res[i].first == ON){
				printf("Switch on room %d.\n", res[i].second + 1);
			}
		}
	}
	else if (ca == 2){
		puts("You can not switch off all lights.");
	}
	else if (ca == 3){
		puts("Help me!");
	}
}

int main()
{
	while (scanf("%d %d", &n, &m), n){
		for (int i = 0; i < 15; i++){
			g[i].clear();
			sw[i].clear();
		}
		
		for (int i = 0; i < m; i++){
			int s, t;
			scanf("%d %d", &s, &t);
			g[--s].push_back(--t);
			g[t].push_back(s);
		}
		
		int light = 0;
		for (int i = 0; i < n; i++){
			int a;
			scanf("%d", &a);
			if (a) light |= BIT(i);
		}
		
		for (int i = 0; i < n; i++){
			int k;
			scanf("%d", &k);
			for (int j = 0; j < k; j++){
				int r;
				scanf("%d", &r);
				sw[i].push_back(--r);
			}
			sort(sw[i].begin(), sw[i].end());
		}
		
		initial.cur = 0;
		initial.light = light;
		initial.log.clear();
		
		solve();
	}
}

Measured memory_bytes: 11644
#include "iostream"
using namespace std;
int main() {
	long long N;
	cin >> N;
	long long rev, san, futa, hito;
	san = N / 100;
	futa = (N - san * 100) / 10;
	hito = N - (san * 100) - (futa * 10);
	rev = (100 * hito) + (10 * futa) + san;
	if (N == rev) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC 081 C - Not so Diverse
//
//  Created by Ryo Kakitsuka on 2019/03/15.
//  Copyright © 2019 Ryo Kakitsuka. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    // 入力
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> B(N,0);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    // バケット法
    for (int i=0; i<N; i++) {
        B[A[i]-1]++;
    }
    int var_A=0; // Aのなかに数字は何種類あるか
    for (int i=0; i<N; i++) {
        if (B[i] > 0) {
            var_A++;
        }
    }
    // sort
    sort(B.begin(), B.end());
    
    
    int ans = 0;
    for (int c=0; var_A>K;c++) {
        if (B[c] > 0) {
            ans += B[c];
            var_A--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
    int main()
    {
        int a[100000]={0},i;
        int n,t;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            scanf("%d",&t);
            a[t]=i;
        }
        
        for(i=1;i<=n;i++)
        printf("%d ",a[i]);
        
        
    }

Measured memory_bytes: 1152
#include<iostream>
#include<string>

using namespace std;

int main() {
	int n = 0;
	string s;

	cin >> s;

	for (int i = 0; i < 4; i++) {
		if (s[i] == '+') {
			n++;
		}
		else if (s[i] == '-') {
			n--;
		}
	}

	cout << n << endl;

	return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL A,B,C,D;
  cin >> A >> B >> C >> D;
  
  LL E = Lcm(C,D);
  
  LL ac = (A-1)/C, ad = (A-1)/D, bc = B/C, bd = B/D, ae = (A-1)/E, be = B/E;
  
  LL an = A-1 - ac - ad + ae, bn = B - bc - bd + be;
  
  cout << bn - an << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	double d;
	cin>>d;
	double a=sqrt(2.0)*d;
	rep1(i,10){
		double x=i;
		if(x>d) break;
		double y=sqrt(d*d-x*x);
		chmax(a,x+max(y,1.0));
	}
	printf("%.12f\n",a);
}

Measured memory_bytes: 1228
import sys
S = input()
if len(S) % 2 == 1:
  print('No')
  sys.exit()


for i in range(0, len(S)//2):
  if S[i*2] != 'h' or S[i*2+1] != 'i':
    print ('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 3060
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e9
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll m=n%MOD;
    ll d;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
            d=i;
    }
    ll a=d;
    ll c=n/a;
    cout<<a+c-2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	bool lose = true;
	for (auto x : A) {
		if (x % 2) lose = false;
	}
	if (!lose) {
		cout << "first" << endl;
	} else {
		cout << "second" << endl;
	}
}


Measured memory_bytes: 640
s=list(map(int,input().split()))
i=0
j=0
a=0
b=0
c=0
d=0
for i in range(1,s[0]+1):
  for j in range(1,s[1]+1):
    a=j%10
    b=(j-a)/10
    c=a*b
    if a>=2 and b>=2 and c==i:
      d=d+1
print(d)

Measured memory_bytes: 3060
#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 n, m;
    cin >> n >> m;
    vector<int> food(m);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int x;
            cin >> x;
            x--;
            food[x]++;
        }
    }
    int ans = 0;
    rep(i, m) if (food[i] == n) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;
class Main
{
	public static void main(String[] args)
	{
		Scanner s = new Scanner(System.in);
		int[][] arr = new int[3][3];
		for(int i=0;i<3;i++)
		{
			for(int j =0 ;j<3;j++)
			{
				arr[i][j] = s.nextInt();
			}
		}

		int flag =0 ;
		for(int i =0 ;i<2;i++)
		{
			if((arr[i][0] - arr[i][1]) != (arr[i+1][0] - arr[i+1][1]))
				flag = 1;
			if((arr[i][1] - arr[i][2]) != (arr[i+1][1] - arr[i+1][2]))
				flag = 1;
		}

		for(int i =0 ;i<2;i++)
		{
			if((arr[0][i] - arr[1][i]) != (arr[0][i+1] - arr[1][i+1]))
				flag = 1;
			if((arr[1][i] - arr[2][i]) != (arr[1][i+1] - arr[2][i+1]))
				flag = 1;
		}
		if(flag != 0)
			System.out.println("No");
		else
			System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){
  ll n,a[100000],s=0;
  cin>>n;
  for(ll i=0;i<n;i++)cin>>a[i],s+=a[i];
  if(s%(n*(n+1)/2))cout<<"NO"<<endl;
  else{
    s/=n*(n+1)/2;
    ll ans=1,b[100000]={};
    for(ll i=0;i<n;i++){
      if(-a[(i+1)%n]+a[i]+s>=0)
      b[(i+1)%n]=(-a[(i+1)%n]+a[i]+s)/n;
    }
    ll ss=0;
    for(ll i=0;i<n;i++)ss+=b[i];
    if(ss!=s)ans=0;
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1792
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*; 
import java.util.*;
import java.util.regex.*;

/*
			  br = new BufferedReader(new FileReader("input.txt"));
			  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
			  br = new BufferedReader(new InputStreamReader(System.in));
			  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++) {
			int n = readInt();
			int[] dp = new int[256];
			Arrays.fill(dp, 1 << 25);
			while(n-- > 0) {
				String s = readToken();
				int[] curr = new int[256];
				for(int i = 0; i < s.length(); i++) {
					curr[s.charAt(i)]++;
				}
				for(int i = 0; i < dp.length; i++) {
					dp[i] = Math.min(dp[i], curr[i]);
				}
			}
			for(int i = 0; i < 256; i++) {
				while(dp[i]-- > 0) {
					pw.print((char)i);
				}
			}
			pw.println();
		}
		exitImmediately();
	}

	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException {
		return Long.parseLong(readToken());
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(readToken());
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(readToken());
	}

	private static String readLine() throws IOException  {
		String s = br.readLine();
		if(s == null) {
			exitImmediately();
		}
		st = null;
		return s;
	}

	private static String readToken() throws IOException  {
		while(st == null || !st.hasMoreTokens())  {
			st = new StringTokenizer(readLine().trim());
		}
		return st.nextToken();
	}
}

Measured memory_bytes: 21332
#C
import math
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
A.sort()
if N%2 == 0:
    n = N//2
    flag = 0
    for i in range(N):
        I = i//2 * 2 + 1
        if A[i] != I:
            flag = 1
            break
    if flag == 1:
        print(0)
    else:
        print(2**n%mod)
    
else:
    n = N//2
    flag = 0
    for i in range(N):
        if i == 0:
            if A[0] != 0:
                flag = 1
                break
        else:
            I = (i+1)//2 * 2
            if A[i] != I:
                flag = 1
                break
    if flag == 1:
        print(0)
    else:
        print(2**n%mod)



Measured memory_bytes: 13812
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    S=input()
    if S[-1] != "s":
        print(S+"s")
    else:
        print(S+"es")
    




if __name__ == "__main__":
    main()

Measured memory_bytes: 61744
import sys
from itertools import islice
from collections import deque
read = map(int, sys.stdin.read().split())

N = next(read)
A = [deque()] + [deque(islice(read, N - 1)) for _ in range(N)]
days = 1
available_players = deque(range(1, N + 1))
next_opponent = [0] * (N + 1)
played = set()

while available_players:
    player = available_players.popleft()
    if not A[player]:
        continue

    opponent = A[player].popleft()
    if next_opponent[opponent] == player:
        available_players.append(player)
        available_players.append(opponent)
        next_opponent[player] = 0
        next_opponent[opponent] = 0
        if player in played:
            days += 1
            played.clear()
        played.add(player)
        played.add(opponent)
    else:
        next_opponent[player] = opponent

if next_opponent.count(0) != N + 1:
    print(-1)
else:
    print(days)

Measured memory_bytes: 98672
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int s[105];
int dp[100005];
void Solve() {
    read(N);
    dp[0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
        read(s[i]);
        for(int j = 100000 ; j >= 1 ; --j) {
            if(j >= s[i]) dp[j] = dp[j] | dp[j - s[i]];
        }
    }
    for(int j = 100000 ; j >= 0 ; --j) {
        if(j && j % 10 == 0) continue;
        if(dp[j]) {out(j);enter;return;}
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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


int main() {

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < 1000; ++i) {
        string t;
        int x = i;
        rep(j,3) {
            t += '0' + x % 10;
            x /= 10;
        }
        int ti = 0;
        rep(j,n) {
            if (s[j] == t[ti]) {
                ++ti;
                if (ti == 3) {
                    break;
                }
            }
        }
        if (ti == 3) {
            ++ans;
        }
    }
    cout << ans << endl;
	return 0;
}

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

int main()
{
    string o, e;
    cin >> o >> e;
    for(int i=0; i<e.length(); i++)
    {
        cout << o[i] << e[i];
    } if(o.size()!=e.size()) cout << o.back() << endl;
}

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	ll n; cin >> n;
	ll ans = 0;
	rep(i, 1, n+1){
		for(ll j=i;j<=n;j+=i){
			ans+=j;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3568
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let mut l = util::gets::<usize>();

    l.sort();

    let ans = (0..n).map(|i| l[2 * i]).sum::<usize>();
    println!("{}", ans);
}


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

using namespace std;

int main()
{

 int k,a,b,p=0;
 cin>>k;
 cin>>a>>b;

 for(int i=a;i<=b;i++)
 {
     if(i%k==0){cout<<"OK";return 0;}
     else {continue;}

 }
 cout<<"NG";
    return 0;
}


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

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

    int n;
    cin >> n;
    vector<pair<int, int>> a(n + 1);
    rep(i, 0, n) {
        cin >> a[i + 1].first;
        a[i + 1].second = i + 1;
    }
    sort(a.begin(), a.end());
    rep(i, 1, n + 1) cout << a[i].second << ' ';
    cout << endl;

    return 0;
}

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

using namespace std;

int main()
{
  int n, m; cin >> n >> m;
  int sum = 0;
  for(int i = 0; i < m; i++)
  {
    int x; cin >> x;
    sum += x;
  }
  cout << max(n-sum, -1) << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
      	int B=sc.nextInt();
      	int C=sc.nextInt();
      	int count=0;
      	boolean eatFlag=true;
      
      	while(eatFlag){
         	if(C>0){
            	C-=1;
              	count++;
              	if(A>0){
                	A-=1;
                } else {
                	if(B>0){
                    	B-=1;
                       	count++;
                    }else{
                    	eatFlag=false;
                    }
                }
            }else{
            	if(B>0){
                	count+=B;
                }
              	eatFlag=false;
            } 
        }
      	System.out.println(count);
    }
}

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

using namespace std;

const int N = 55;
long long dp[N][N][N * N];

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

  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k < N * N; k++) {
        dp[i + 1][j][k] = dp[i][j][k];
        if (j > 0 && k >= a[i]) {
          dp[i + 1][j][k] += dp[i][j - 1][k - a[i]];
        }
      }
    }
  }

  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[n][i][i * A];
  }
  cout << ans << '\n';
  return 0;
}

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

#include <fstream>
using namespace std;

#define INF 99999999

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N, T;
  cin >> N >> T;
  int ans = INF;
  for(int i = 0; i < N; i++){
    int c, t;
    cin >> c >> t;
    if(t <= T && c < ans){
      ans = c;
    }
  }
  if(ans == INF) cout << "TLE" <<endl;
  else cout << ans <<endl;
}


Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
def solve():
    N,K = map(int, input().split())
    *A, = map(int, input().split())
    L = [0 for i in range(2001)]
    invertion = 0
    for a in A:
        invertion += sum(L[a+1:])
        L[a]+=1
    res = (K*invertion + sum(sum(L[a+1:])*(K*(K-1)//2) for a in A))%(10**9+7)

    return str(res)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<set>
using namespace std;

int main()
{
  int n,m;
  for(;;)
  {
  cin >> n >>m;
  set<int> s;
  pair<int,int> a[m];
  if(n==0&&m==0) break;
  int x,y;
  for(int i=0;i<m;i++){
    cin >> x >> y;
    a[i]=make_pair(x,y);
  }
  vector<int> v;
  s.insert(1);
  for(int i=0;i<m;i++)
    if(a[i].first==1){
      v.push_back(a[i].second);
      s.insert(a[i].second);
    }
  for(int j=0;j<(int)v.size();j++){
    for(int i=0;i<m;i++){
      if(a[i].first==v[j])
        s.insert(a[i].second);
      else if(a[i].second==v[j])
        s.insert(a[i].first);
    }
  }
  cout << s.size()-1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3172