akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.lang.Math;

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

        int dotNum = sc.nextInt();
        int distance = sc.nextInt();
        int[][] point = new int[dotNum][2]; 
        for(int i = 0; i < dotNum; i++){
            point[i][0] = sc.nextInt();
            point[i][1] = sc.nextInt();
        }

        int count = 0;
        for(int i = 0; i < dotNum; i++){
            if(isLessThanDistance(point[i][0], point[i][1],distance)){
                count++;
            }
        }
        System.out.println(count);
    }

    public static boolean isLessThanDistance(int x, int y,int distance){
        return distance >= Math.sqrt((double)x*x + (double)y*y) ? true : false;
    }
}

Measured memory_bytes: 65336
#include<cstdio>
#include<cctype>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;

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

int unit[20];
int need[20];

int nextInt() {int r = 0, ch; while( isspace(ch = getchar())); do {r = r * 10 + ch - '0';}while( isdigit( ch = getchar() ) ); return r;}

bool visited[1 << 20];

struct State {
  int one, mask, have;
  bool operator<(const State& t) const {
    if( one != t.one ) return one > t.one;
    return have < t.have;
  }
};

int solve(int N, int U) {
  memset(visited, 0, sizeof(visited));
  priority_queue<State> up;
  State s;
  s.one = 0;
  s.mask = 0;
  s.have = 0;
  visited[s.mask] = 1;
  up.push(s);
  while( !up.empty() ) {
    s = up.top(); up.pop();

    if( s.have >= U ) return s.one;

    for(int i = 0; i < N; i++)
      if ( visited[s.mask | (1 << i)] == 0 && (s.mask | need[i]) == s.mask )
        {
          State next;
          next.mask = s.mask | (1 << i);
          next.one = s.one + 1;
          next.have = s.have + unit[i];
          visited[next.mask] = 1;
          up.push(next);
        }
  }
  return -1;
}

int main() {
  for(;;) {
    int N, U;
    N = nextInt();
    U = nextInt();
    if( N == 0 && U == 0 ) break;
    REP(i, N) need[i] = 0;

    int all = 0;
    REP(i, N) {
      unit[i] = nextInt();
      all += unit[i];
      int K = nextInt();
      REP(k, K) {
        int x = nextInt();
        need[i] |= (1 << x);
      }
    }
    if( all == U ) {
      printf("%d\n", N);
      continue;
    }
    int best = solve(N, U);
    printf("%d\n", best);
  }
}

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

int main(){
  int N;
  cin >> N;
  int count = 0;
  for(int i = 1;i <= N;i++){
    string s = to_string(i);
    if(s.size() % 2 != 0)count++;
  }

  cout << count << endl;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	if (b - a <= 0)cout << "delicious" << endl;
	else if (b - a <= x)cout << "safe" << endl;
	else cout << "dangerous" << endl;

	return 0;

}

Measured memory_bytes: 256
N = input()

if len(N) == 1:
    print(N)
elif len(N) == 2:
    print(9)
elif len(N) == 3:
    print(9 + int(N) - 99)
elif len(N) == 4:
    print(909)
elif len(N) == 5:
    print(909 + int(N) - 9999)
elif len(N) == 6:
    print(90909)

Measured memory_bytes: 3060
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  ll X;
  cin >> X;
  ll N = (X + 10) / 11 - 1;
  X %= 11;
  if (X == 0) X = 11;
  if (X <= 6) {
    cout << 2 * N + 1 << endl;
  } else {
    cout << 2 * N + 2 << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=1'000'000'007;
const double EPS=1e-14;
const bool DEBUG=true;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
void answer(){
    string s;
    cin>>s;
    if(s[s.size()-1] == 's'){
        cout<<s+"es"<<endl;
    }else{
        cout<<s+"s"<<endl;
    }

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    answer();

    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Vt = 0;
		int Ct = 0;
		int[] Vtar = new int[N];
		int[] Ctar = new int[N];
		for (int i = 0; i < N; i++) {
			int V = sc.nextInt();
			

			Vtar[i] = V;
		
		
		

		}
		for (int i = 0; i < N; i++) {
			
			int C = sc.nextInt();

		
			Ctar[i] = C;
		
		

		}
		
		for (int i = 0; i < Ctar.length; i++) {
			if(Vtar[i] > Ctar[i]) {
				Vt += Vtar[i];
				Ct += Ctar[i];
			}
		
			
		}

		System.out.println(Vt - Ct);
	}

}

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

int main() {
  int n;cin>>n;
  int an[n];rep(i,n)an[i]=0;
  int a;
  rep(i,n-1) {
    cin>>a;
    an[a-1]++;
  }
  rep(i,n) cout<<an[i]<<endl;
}


Measured memory_bytes: 4380
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;

  cout << (n * (n-1) / 2) + (m * (m-1) / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
int main()
{
    int n,ans=0,m;
    cin>>n;
    vector<int> a(n+1);
    rep(i,n) cin>>a[i];
    rep(i,n)
    {
        if(i!=1) m=min(m,a[i]);
        else m=a[i];
        if(m>=a[i]) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  if (a + b > c + d) cout << "Left" << endl;
  else if (a + b == c + d) cout << "Balanced" << endl;
  else cout << "Right" << endl;


  
  return 0;
}

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

int main(){
    int d;
    cin >> d;
    if(d <= 25)cout << "Christmas";
    if(d <= 24)cout << " Eve";
    if(d <= 23)cout << " Eve";
    if(d == 22)cout << " Eve";
    cout << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
 
 
using namespace std;
 
int n,vis[101][101];
struct point{int x,y;};
point grid[101][101];
 
int dfs(int x,int y,int fg){
 
    vis[y][x]=fg;
    point nx=grid[y][x];
    int res=vis[nx.y][nx.x];
     
    if(vis[nx.y][nx.x]==0)res=dfs(nx.x,nx.y,fg);
    vis[y][x]=res;
     
    return res;
}
 
int main(void){
 
    point p;
     
    while(cin >> n,n){
        fill(vis[0],vis[101],0);
         
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cin >> p.x >> p.y;
                grid[i][j]=p;
            }
        }
         
        int cnt=1;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(!vis[i][j]){
                    if(dfs(j,i,cnt)==cnt)cnt++;  
                }
            }
        }
 
        cout << cnt-1 << endl;
    }
 
return 0;
}

Measured memory_bytes: 1284
function Main(input) {
    var n = input.split("\n")[0];
    var stringNums = input.split("\n")[1].split(" ");
    var nums = [];
    var alice = 0;
    var bob = 0;

    for(var i = 0; i < n; i++ ) {
        nums.push(Number(stringNums[i]));
    }
    
    nums.sort(
        function(a,b){
          return b - a
        }
      );
      

    for (var i = 0; i < n ; i++) {
        if (i % 2 === 0 ){
            alice = alice + nums[i];
        } else {
            bob = bob + nums[i]
        }
    }
    console.log(alice - bob);
  
    }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7500
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h=0,w=0;
        
        loop1:
        while(true){
            h=sc.nextInt();
            w=sc.nextInt();
            
            if(h==0 && w==0)break;
            
            int p = h*h + w*w;
            
            for(int i=h+1;i*i<p;i++){
                for(int j=i+1;j*j<=p-i*i;j++){
                    if(i*i+j*j==p){
                        System.out.println(i+" "+j);
                        continue loop1;
                    }
                }
            }
            
            for(;;){
                p++;
                
                for(int j=(int)Math.sqrt(p);j>0;j--){
                    for(int i=j-1;i>0;i--){
                        if(i*i+j*j==p){
                            System.out.println(i+" "+j);
                            continue loop1;
                        }
                    }
                }
            }
            
        }
    }
}

Measured memory_bytes: 20720
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

pii operator-(pii l, pii r){ return pii(l.first - r.first, l.second - r.second); }
ll operator/(pii l, pii r){ return (ll)l.first * r.second - (ll)l.second * r.first; }
ll operator*(pii l, pii r){ return (ll)l.first * r.first + (ll)l.second * r.second; }

const int MX = 305;
char D[MX];
int T[MX][MX][MX];
int N, K;

int main()
{
	scanf("%s%d", D+1, &K);
	N = strlen(D+1);
	for(int i = 1; i <= N; i++) T[i][i][0] = 1;
	for(int i = 1; i < N; i++){
		for(int x = 1; x+i <= N; x++){
			int y = x+i;
			for(int k = 0; k <= K; k++){
				T[x][y][k] = max(T[x+1][y][k], T[x][y-1][k]);
				if( k ) T[x][y][k] = max(T[x+1][y-1][k-1] + 2, T[x][y][k]);
				if( D[x] == D[y] ) T[x][y][k] = max(T[x+1][y-1][k] + 2, T[x][y][k]);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= K; i++) ans = max(ans, T[1][N][i]);
	printf("%d\n", ans);
}


Measured memory_bytes: 110464
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k,s;
	cin >> k >> s;
	int soma = 0;
	for(int i = 0;i<=k;i++){
		for(int j = 0;j<=k;j++){
			if(s-i-j >=0 and s -i - j<=k)
				soma ++;
		}
	}
	
	cout<<soma<<endl;

	
}

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

int a[201000],n,x,k,ans;

int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) {
		scanf("%d",&x);
		a[x]++;
	}
	sort(a+1,a+n+1);
	for (int i=n-k;a[i];i--) ans+=a[i];
	printf("%d\n",ans);
}


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

int main() {
  string s;
  cin >> s;
  vector<char> c(0);
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '0'){
      c.push_back('0');
    }else if(s.at(i) == '1'){
      c.push_back('1');
    }else if(c.size() >= 1){
      c.pop_back();
    }
  }
  for(int i = 0; i < c.size(); i++){
    cout << c.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
void main() {
    int n = readln.chomp.to!int;
    int k = readln.chomp.to!int;
    int m = k.log2.ceil.to!int;
    int ans = n - m > 0 ? 2 ^^ m + (n - m) * k : 2 ^^ n;
    ans.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
# include<stdio.h>

int main(){


int a1,a2,a3,x,y,z;

//x = 0;
//y = 0;
//z = 0;
scanf("%d %d %d",&a1,&a2,&a3);

if (a1>a2){
 x = a2;
 a2 = a1;
 a1 = x;
}

if (a2>a3){
  y = a3;
  a3 = a2;
  a2 = y;
}

if (a1>a2){
  z = a2;
  a2 = a1;
  a1 = z;
}

printf("%d %d %d\n",a1,a2,a3);

return(0);


}

Measured memory_bytes: 596
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>

using namespace std;

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

    string D;
    cin>>D;


    if(A>=3200){
        cout<<D<<endl;
    }
    else if(3200>A){
        cout<<"red"<<endl;
    }

}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(NULL);
    long h,n;
    cin>>h>>n;
    long s=0,x;
    for(long i=0;i<n;i++)
    {
        cin>>x;
        s+=x;
    }
    if(s>=h)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))


    a.append(0)
    a.insert(0, 0)
    costs = []
    for i in range(n + 1):
        costs.append(abs(a[i + 1] - a[i]))

    s = sum(costs)
    for i in range(n):
        print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))

main()

Measured memory_bytes: 13916
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := wordScanner(100)
	l := scanIntSlice(s, 6)
	fmt.Println(4 + ceilDiv(l[0], min(l[1:])))
}

func ceilDiv(x, y int) int {
	if x%y > 0 {
		return x/y + 1
	}
	return x / y
}

func min(l []int) int {
	r := l[0]
	for _, n := range l[1:] {
		if n < r {
			r = n
		}
	}
	return r
}

func wordScanner(n int) *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	b := make([]byte, n)
	s.Buffer(b, n)
	return s
}

func scanIntSlice(s *bufio.Scanner, n int) []int {
	vals := make([]int, n)
	for i := range vals {
		s.Scan()
		m, _ := strconv.Atoi(s.Text())
		vals[i] = m
	}
	return vals
}


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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
  int n;
  cin>>n;
  int f=1;
  for(int i=0;i<n;i++)
  {
      int x;
      cin>>x;
      if(x%2==0)
      {
          if(x%3==0||x%5==0)
           continue;
           else
            f=0;
           
      }
  }
  if(f)
   cout<<"APPROVED\n";
   else
    cout<<"DENIED\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
        
  	long all = 0;
    for(long i=1; i<=N; i++){
	if(i%3 !=0 && i%5 !=0){
      all+=i;
    }
    }
      System.out.println(all);
  }
}

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    n--;
    int A;
    cin >> A;
    vector<int> a(n);
    vector<vector<double>> b(3, vector<double>(n));
    REP(i, n) cin >> a[i] >> b[0][i] >> b[1][i] >> b[2][i];
    REP(i, n) b[0][i] /= 100, b[1][i] /= 100, b[2][i] /= 100;

    vector<double> dp(1 << n, -1);
    dp[0] = 1;
    function<double(int)> dfs = [&](int S) {
        if (dp[S] != -1) return dp[S];
        double ret = 0;
        bool ok = true;
        REP(i, n) {
            if ((S >> i & 1) && a[i] > A) ok = false;
        }
        REP(c, 3) {
            double acc = 0.0;
            double draw = 1.0;
            for (int T = S;; T = (T - 1) & S) {
                if (T == S) continue;
                double win = 1.0, lose = 1.0;
                REP(i, n) {
                    if ((S >> i & 1) == 0) continue;
                    win *= ((T >> i & 1) ? b[c][i] : b[(c + 2) % 3][i]);
                    lose *= ((T >> i & 1) ? b[(c) % 3][i] : b[(c + 1) % 3][i]);
                }
                acc += dfs(T) * win;
                draw -= win + lose;
                // acc += exp(dfs(T) + win);
                // draw -= exp(win) + exp(lose);
                if (T == 0) break;
            }
            if (ok) acc += draw;
            ret = max(ret, acc);
        }
        return dp[S] = ret;
    };
    int all = (1 << n) - 1;
    dfs(all);
    // REP(i, 1 << n) cout << i << " " << dp[i] << endl;
    cout << setprecision(20) << dp[all] << endl;
}



Measured memory_bytes: 3332
//ALDS1_2D
#include <iostream>
#include <vector>

using namespace std;

int insertionSort(vector<int>& data,int g){
 int cnt=0;
 const int n=data.size();
 for(int i=g;i<n;i++){
  int v=data.at(i);
  int j=i-g;
  while(j>=0 && data.at(j)>v){
   data.at(j+g)=data.at(j);
   j=j-g;
   cnt++;
  }
  data.at(j+g)=v;
 }
 return cnt;
}

void shellSort(vector<int>& data){
 const int n=data.size();
 vector<int> G;
 G.push_back(1);
 for(int i=0;n>3*G.at(i)+1;i++){
  G.push_back(3*G.at(i)+1);
 }

 int cnt=0;
 int m=G.size();
 for(int i=m-1;i>=0;i--){
  cnt+=insertionSort(data,G.at(i));
 }

 cout<<m<<endl;
 for(int i=m-1;i>=0;i--){
  cout<<G.at(i);
  if(i!=0) cout<<" ";
  else cout<<endl;
 }
 cout<<cnt<<endl;
}

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

 vector<int> data(n,0);
 for(int i=0;i<n;i++){
  cin>>data.at(i);
 }

 shellSort(data);
 for(int i=0;i<n;i++) cout<<data.at(i)<<endl;
 
 return 0;
}

Measured memory_bytes: 4896
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

int MAX = 10000001; 
int factor[10000001]={}; 

void sieve() 
{ 
    factor[1] = 1; 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
    for (int i = 3; i * i < MAX; i++) { 
        if (factor[i] == i) { 
            for (int j = i * i; j < MAX; j += i) { 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
int f(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
    int dup = factor[n];  
    int c = 1; 
    int j = n / factor[n]; 
    while (j != 1) { 
        if (factor[j] == dup) 
            c += 1; 
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
        j = j / factor[j]; 
    } 
    ans = ans * (c + 1); 
  
    return ans; 
} 



void solve() {
	sieve(); 
	int sum=0;
	int n;
	cin>>n;
	for(int i = 1;i <=n;i++) 
        sum+=i*f(i);
    cout<<sum;
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 81728
#include <stdio.h>
#include <string.h>

void Replace(char* str, int a, int b, char* ope);
void Reverse(char* str, int a, int b);
void Print(char* str, int a, int b);
void InitStr(char* str, int len);

#define strMAX 1000	//文字列の最大数

int main(void)
{
	char str[strMAX];	//入力する文字列
	int q;				//命令の数
	int a;
	int b;
	char p[strMAX];		//置き換える文字列
	char ope[strMAX];	//命令を入れる文字列
	char input[strMAX];
	int i;

	//配列を初期化する
	InitStr(str, strMAX);
	InitStr(p, strMAX);
	InitStr(ope, strMAX);

	InitStr(input, strMAX);

	//文字列を入力する
	scanf("%s", str);

	//命令数を入力する
	scanf("%d", &q);

	while (q > 0)
	{
		//命令を入力する
		scanf("%s%d%d", ope, &a, &b);

		if (strcmp(ope, "replace") == 0)
		{
			scanf("%s", p);
			Replace(str, a, b, p);
		}
		else if (strcmp(ope, "reverse") == 0)
		{
			Reverse(str, a, b);
		}
		else if (strcmp(ope, "print") == 0)
		{
			Print(str, a, b);
		}
		else
		{
			//処理なし
		}

		//配列を初期化する
		InitStr(ope, strMAX);

		q--;
	}

	return 0;
}

//文字列を置き換える
void Replace(char* str, int a, int b, char* ope)
{
	int i;
	int j = 0;

	for (i = a; i <= b; i++)
	{
		str[i] = ope[j++];
	}
}

//文字列を反転する
void Reverse(char* str, int a, int b)
{
	int i;
	int j;
	char dummy;
	for (i = a, j = b; i <= j; i++, j--)
	{
		dummy = str[i];
		str[i] = str[j];
		str[j] = dummy;
	}
}

//文字列を出力する
void Print(char* str, int a, int b)
{
	int i;
	int j;
	char print[strMAX];
	InitStr(print, strMAX);
	for (i = a, j = 0; i <= b; i++, j++)
	{
		print[j] = str[i];
	}
	printf("%s\n", print);
}

//文字列を初期化する
void InitStr(char* str, int len)
{
	int n;
	for (n = 0; n < len; n++)
	{
		str[n] = '\0';
	}
}



Measured memory_bytes: 2148
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
const LL MOD = 1000000007LL;
const int inf = 1e9;
const LL INF = 1e18;
const int MAX_V = 200;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];
void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}
bool dfs(int v) {
	used[v] = 1;
	for (int to : G[v]) {
		int w = match[to];
		if (w < 0 || !used[w] && dfs(w)) {
			match[v] = to;
			match[to] = v;
			return 1;
		}
	}
	return 0;
}
int bipartite_matching(int V) {
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < V; v++) {
		if (match[v] < 0) {
			memset(used, 0, sizeof(used));
			if (dfs(v)) res++;
		}
	}
	return res;
}
int main() {
	int N;
	cin >> N;
	int a[100], b[100];
	int c[100], d[100];
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < N; i++) cin >> c[i] >> d[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				add_edge(i, j + N);
			}
		}
	}
	cout << bipartite_matching(N) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int w=0,a=0,b=0,ans=0;
	cin>>w>>a>>b;
	if(b>a+w)
	  ans=b-(a+w);
	else if(a>b+w)
	  ans=a-(b+w);
	else 
	  ans=0;
	cout<<ans;      
}

Measured memory_bytes: 256
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
int arr[202];
int main()
{
    int n,i,j,k,x,y,ans,curr,temp;
    scanf("%d %d",&n,&k);
    int sum = 0;
    int mini = 1e18;
    int idx = 0;
    for(i=1;i<=n;i++)
    {
        arr[i] = k + i - 1;
        sum += arr[i];
        if(mini > abs(arr[i]))
        {
            mini = abs(arr[i]);
            idx = i;
        }
    }
    printf("%d\n",sum-arr[idx]);
    return 0;
}


Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<bits/stdc++.h>
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
#define ll long long int
const ll mod = 1000000007;
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  ll n = s.length();
  ll dp[n][13];
  memset(dp,0,sizeof(dp));
  if(s[0] == '?')
    for (int i = 0; i < 10; ++i)
    {
      dp[0][i] = 1;
    }
  else
    dp[0][s[0]-'0'] = 1;
  for (int i = 1; i < n ; ++i)
  {
    ll t = s[i]-'0';
    if(s[i] == '?')
    {
      for (int j = 0; j < 10; ++j)
      {
        t = j;
        for (int k = 0; k < 13; ++k)
        {
          dp[i][(k*10+t)%13] += dp[i-1][k];
          dp[i][(k*10+t)%13] %= mod;
        }
      }
    }
    else
    {
      for (int j = 0; j < 13; ++j)
      {
        dp[i][(j*10+t)%13] += dp[i-1][j];
        dp[i][(j*10+t)%13] %= mod;
      }
    }
  }
  cout << dp[n-1][5] << endl;
  return 0;
}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  if(S.at(0) == '7' || S.at(1) == '7' || S.at(2) == '7')cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    int mi = 1145141919;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a;
        mi = min(mi, a);
    }

    if (n % 2 == 1) {
        bool ret = sum % 2 == 0;
        cout << (ret ? "Second" : "First") << endl;
    } else {
        bool ret = sum % 2 == 0 && mi % 2 == 0;
        cout << (ret ? "Second" : "First") << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include<stdio.h>
int main(void)
{
    int i,flg,a,b,s;
	while(1){
	if(a==0) break;
	flg=0;
	s=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
	scanf("%d",&b);
	if(1<b){
	flg=1;
	}
	if(1<=b){
	s++;
	}
	}
	if(a==0){
	return 0;
	}
	if(flg==1){
	printf("%d\n",s+1);
	}
	else{
	printf("NA\n");
	}
	}
	return 0;
	}

Measured memory_bytes: 1040
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int step,direct;
	int angle=90;
	double x=0;
	double y=0;
	while(scanf("%d,%d",&step,&direct)){
		if(!(step||direct)) break;
		x += step * cos(2*M_PI*angle/360);
		y += step * sin(2*M_PI*angle/360);
		angle -= direct;
	}
	
	cout << (int)x << endl;
	cout << (int)y << endl;
	
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
void change(string &s, char x, char b) {
	rep(i, 0, s.size()) {
		if (s[i] == x) {
			s[i] = b;
		}
	}
}
vector<vector<int>>AND({ { 0,0,0 }, { 0,1,1 }, { 0,1,2 } }), OR({ {0,1,2},{1,1,2},{2,2,2} });
vector<int>NOT({ 2,1,0 });
vector<char>vc{ 'P', 'Q', 'R' };

int eval(string &s, int &k) {
	dump(s.substr(k));
	dump(k);
	if (isdigit(s[k])) {
		return s[k] - '0';
	}
	else if (s[k] == '-') {
		return NOT[eval(s, ++k)];
	}
	else if (s[k] == '(') {
		k++;
		int a = eval(s, k);
		dump(a);
		k++;
		char op = s[k];
		dump(op);
		k++;
		int b = eval(s, k);
		k++;
		dump(b);
		if (op == '*') return AND[a][b];
		else if (op == '+')return OR[a][b];
	}
}

signed main() {
	string s;
	while (cin >> s, s != ".") {
		int cnt(0);
		for (char P = '0'; P <= '2'; P++) {
			for (char Q = '0'; Q <= '2'; Q++) {
				for (char R = '0'; R <= '2'; R++) {
					string ex(s);

					change(ex, 'P', P);
					change(ex, 'Q', Q);
					change(ex, 'R', R);

					int k(0);
					if (eval(ex, k) == 2)cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3020
#include <stdio.h>

int main(void){

char s[4];
int len = 0;

scanf("%s",s);

while(s[len]){
 len++;
}
if (len == 3)
{
char t = s[0];
s[0] = s[2];
s[2] = t;
}

printf("%s",s);

return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pb push_back
int main()
{
        ll a,b,sum=1,f=0;
        cin>>a;
        b=(a/2);
        int arr[a];
        for(int i=0;i<a;i++){
                cin>>arr[i];
        }
        sort(arr,arr+a);


    cout<<abs(arr[b-1]-arr[b])<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100000,vector<ll>(3,0));
int main(){
  ll a,b;
  cin >> a >> b;
  ll tmp = a+b;
  cout << max(a+b,max(a-b,a*b));
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int gcd(int m, int n) {
    if(n>m) {
        int tmp=m;
        m=n;
        n=tmp;
    }

    while(n>0) {
        int t = m%n;
        m = n;
        n = t;
    }
    return m;
}

int N;
int A[100001], L[100001], R[100001];

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

    L[0]=A[0];
    for(int i=1;i<N;i++) L[i]=gcd(L[i-1],A[i]);
    
    R[N-1]=A[N-1];
    for(int i=N-2;i>=0;i--) R[i]=gcd(R[i+1],A[i]);

    int res = max(L[N-2], R[1]);
    for(int i=1;i<N-1;i++) {
        res = max(res, gcd(L[i-1], R[i+1]));
    }
    cout<<res;
}


Measured memory_bytes: 1408
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    println!("{}", (n * (n - 1)) / 2);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,a,b,p[10005],i,j;
long long f[5005],s,ans=100000000000000ll;
int main()
{
	scanf("%d %d %d",&n,&a,&b);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&p[i]);
		f[i]=100000000000000ll;
	}
	for(i=1;i<=n;++i)
	{
		s=0;
		for(j=i-1;j>=0;--j)
		{
			if(p[i]>p[j])
				f[i]=min(f[i],f[j]+s);
			if(p[j]>p[i])
				s+=a;
			else
				s+=b;
		}
	}
	for(i=n;i>=0;--i)
	{
		s=0;
		for(j=i+1;j<=n;++j)
			s+=b;
		ans=min(ans,f[i]+s);
	}
	cout<<ans;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
using namespace std;
int main()
{
      double a;
      double b,c;
      cin>>a;
      b=pi*a*a;
      c=2*pi*a;
     cout<<fixed<<setprecision(6)<<b<<" "<<c<<endl;
      return 0;
}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int H, W, K;

LL time(int a, int b){
	vector<bool> used(W+1, false);
	used[a]=used[b]=used[W]=true;
	vector<int> sum(W+1, 0);
	sum[0]=1;
	REP(i, W){
		if(used[i] || used[i+1]){
			sum[i+1]+=sum[i];
		}else{
			sum[i+1]+=sum[i];
			sum[i+2]+=sum[i];
		}
	}
	return sum[W];
}

int main(){
	cin >> H >> W >> K;
	vector<LL> dp(W, 0);
	dp[0]=1;
	REP(i, H){
		vector<LL> dp2(W, 0);
		REP(j, W){
			for(int k=j-1;k<=j+1;++k){
				if(k<0||W==k)continue;
				dp2[k] += dp[j] * time(j, k);
				dp2[k] %= MOD;
			}
		}
		dp = dp2;
	}
	cout << dp[K-1] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  static long q = 0;
    public static void main(String[] args){

      Scanner sc = new Scanner(System.in);
      caseis(sc.nextLong(),sc.nextLong());
      System.out.print(q);
    }
    static void caseis(long i , long j){
      if(i == 1 || j == 1){
        q = 1;
      }else if(i >= j){
        calces(i , j);
      }else{
        calces(j , i);
      }
    }
    static void calces(long i , long j){
      q = i * ( j / 2 );
      if(j % 2 != 0){
        q += (i - i / 2);
        }
    }
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 998244353
#define SIZE 300005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
ll inv[SIZE],f[SIZE],finv[SIZE];
void make_table(){
	int i;
	f[0]=f[1]=1; finv[0]=finv[1]=1;
	inv[1]=1;
	FOR(i,2,SIZE){
		inv[i]=MOD-(MOD/i)*inv[MOD%i]%MOD;
		f[i]=(f[i-1]*(ll)i)%MOD;
		finv[i]=(finv[i-1]*inv[i])%MOD;
	}
	return;
}
ll comb(int n,int k){
	if(n<0||k<0||n<k) return 0;
	return (((f[n]*finv[k])%MOD)*finv[n-k])%MOD;
}

int main(void)
{
	int n,a,b,i;
	ll k,s,t,res=0;
	make_table();
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	FOR(i,0,n+1){
		s=k-(ll)a*i;
		if(s%b==0&&s/b<=n){
			t=comb(n,i)*comb(n,s/b)%MOD;
			res=(res+t)%MOD;
		}
	}
	printf("%lld\n",res);
	return 0;
}
    
    
    


Measured memory_bytes: 7168
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		String inStr;
		inStr = inp();
		String[] in;
		in = inStr.split(" ");

		int t = Integer.valueOf(in[0]);
		int h=t/3600;
		int m=(t%3600)/60;
		int s=t%60;
		
		System.out.println(h+":"+m+":"+s);

	}

	private static String inp() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}

}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 


//  int X[8]={-1, 0, 1, -1, 1, -1, 0, 1};
//  int Y[8]={1, 1, 1, 0, 0, -1, -1, -1};




int main(){
int H, W;
cin >> H >> W;
string s[500];
REP(i, H) cin >> s[i];

 int X[8]={-1, 0, 1, -1, 1, -1, 0, 1};
 int Y[8]={1, 1, 1, 0, 0, -1, -1, -1};

 REP(i, H)REP(j, W){
   if(s[i][j] == '#') continue;
   else{
     int count = 0;
     for(int d = 0; d < 8; d++){
       int ni = i + X[d];
       int nj = j + Y[d];
       if(ni < 0 || ni > H || nj < 0 || nj > W) continue;
       else if(s[ni][nj] == '#') count++;
     }
    s[i][j] = '0' + count;
   }
 }

REP(i, H) print(s[i]);

}

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


void solve(std::vector<long long> A){
  if (A[0]+A[1]+A[2] >= 22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
}

int main(){
  std::vector<long long> A(3);
  for(int i = 0 ; i < 3 ; i++){
    scanf("%lld",&A[i]);
  }
  solve(std::move(A));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a){
        if((x+=a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1){
        assert(n < mod);
        fact[0] = 1;
        for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;  
    }
    mint operator()(int n, int k){
        if(k < 0 || n < k) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int k; cin >> k;
    string s; cin >> s;
    int n = s.size();
    combination c(n+k);
    mint ans = 0;
    for(int i = 0; i <= k; i++){
        mint now = mint(26).pow(k-i);
        now *= mint(25).pow(i);
        now *= c(i+n-1, n-1);
        ans += now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 35624
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



typedef int Weight;

struct Edge {
	int from, to;
	Weight weight;
	Edge(int f, int t, int w) : from(f), to(t), weight(w) { }
};

bool operator < (const Edge& e, const Edge& f) {
	return e.weight != f.weight ? e.weight > f.weight : 
			e.from != f.from ? e.from < f.from : e.to < f.to;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;	// vector<int>
typedef vector<Array> Matrix;	//vector< vector<int> >

// prim
pair<Weight, Edges> prim(const Graph&g, int r = 0) {
	int n = g.size();
	Edges T;
	Weight total = 0;
	
	vector<bool> visited(n, false);
	priority_queue<Edge> q;
	q.push(Edge(-1, r, 0));
	
	while (!q.empty()) {
		Edge e = q.top(); q.pop();
		if (visited[e.to])continue;
		T.push_back(e);
		total += e.weight;
		visited[e.to] = true;
		FOR(f, g[e.to]) if (!visited[f->to]) q.push(*f);
	}
	
	return pair<Weight, Edges>(total, T);
}

int main() {
	int n, m;
	
	while (1) {
		cin >> n; if (n==0) break;
		cin >> m;
		
		Graph g(n);
		
		int a, b, w;
		for_(i, 0, m) {
			scanf("%d,%d,%d", &a, &b, &w);
			g[a].pb(Edge(a,b,w/100-1));
			g[b].pb(Edge(b,a,w/100-1));
		}
		
		pair<Weight, Edges> ret = prim(g, 0);
		cout << ret.first << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1532
"""負辺ありの有向グラフの最短経路問題、ベルマンフォード法"""
import sys
sys.setrecursionlimit(10**6)

n,m,p = map(int, input().split())

INF = 1001001001

to = [[] for _ in range(2505)]
rto = [[] for _ in range(2505)]
reachableFrom1 = [False for _ in range(2505)]
reachableToN = [False for _ in range(2505)]
ok = [False for _ in range(2505)]

def dfs(v):
    """1から到達できる頂点の列挙"""
    if reachableFrom1[v]: return
    reachableFrom1[v] = True
    for u in to[v]:
        dfs(u)

def rdfs(v):
    """Nに到達できる頂点の列挙"""
    if reachableToN[v]: return
    reachableToN[v] = True
    for u in rto[v]:
        rdfs(u)

edges = []
for i in range(m):
    a,b,c = map(int, input().split())
    a -= 1; b -= 1
    c -= p
    c = -c
    edges.append((a,b,c))
    to[a].append(b) # 到達可能性を判定するための変数
    rto[b].append(a) # nに辿り着けるかを判定するための変数
    
dfs(0)
rdfs(n-1)
for i in range(n):
    ok[i] = reachableFrom1[i] & reachableToN[i] # okになっている頂点だけを考える
# ベルマンフォード
def main():
    global edges, ok
    d = [INF for _ in range(n)]
    d[0] = 0
    upd = True
    step = 0 # 負閉路検出用。更新回数がnステップを超えたら負閉路あり
    while upd:
        upd = False
        for i in range(m):
            a,b,c = edges[i]
            if not ok[a]: continue
            if not ok[b]: continue
            newD = d[a]+c
            if newD < d[b]:
                upd = True
                d[b] = newD
        step += 1
        if step > n:
            print(-1)
            return
    ans = -d[n-1]
    ans = max(ans,0)
    print(ans)
    return
    
main()

Measured memory_bytes: 63320
#include <iostream>
#include <vector>

using namespace std;

class DisjointSet{
private:
  vector<int> rank,p;
public:
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }
  void makeSet(int x){
    //parent if root this means itself
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }
  //find representative
  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  int n,q;
  cin >> n >> q;
  DisjointSet ds=DisjointSet(n);
  for(int i=0;i<q;i++){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==0){
      ds.unite(x,y);
    }else{
      bool ans=ds.same(x,y);
      if(ans){
        cout << 1 << endl;
      }else cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 3176
X= int(input())

if X >= 400 and X <= 599:
  print(8)
elif X >= 600 and X <= 799:
  print(7)
elif X >= 800 and X <= 999:
  print(6)
elif X >= 1000 and X <= 1199:
  print(5)
elif X >= 1200 and X <= 1399:
  print(4)
elif X >= 1400 and X <= 1599:
  print(3)
elif X >= 1600 and X <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9188
lines = []
while line = gets
    lines << line.chomp.split(' ')
end

N = lines[0][0].to_i
M = lines[0][1].to_i

solved = []
penalty = []
for i in 1..N do
  solved[i-1] = false
  penalty[i-1] = 0
end

correct = 0
for i in 1..M do
  problem_id = lines[i][0].to_i
  if lines[i][1] == "AC" then
    if solved[problem_id -1] == false then
      correct += 1
      solved[problem_id -1] = true
    end
  else
    if solved[problem_id -1] == false then
      penalty[problem_id -1] += 1
    end
  end
end

penalty_t = 0
for i in 1..N do
  if solved[i-1] ==true then
    penalty_t += penalty[i-1]
  end
end

print correct.to_s + " " + penalty_t.to_s

Measured memory_bytes: 23472
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	int sum1=sum/n;
	int ans1=0;
	for(int i=0;i<n;i++)
	{
		ans1+=fabs(a[i]-sum1)*fabs(a[i]-sum1);
	}
	int sum2=sum/n+1;
	int ans2=0;
	for(int i=0;i<n;i++)
	{
		ans2+=fabs(a[i]-sum2)*fabs(a[i]-sum2);
	}
	if(ans1<ans2)
	  cout<<ans1;
	else
	  cout<<ans2;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [ int(input()) for i in range(N) ]

max_a = max(a)
sec_max_a = sorted(a)[-2]
ans = [max_a]*N
max_index = []
for i in range(N):
  if a[i] == max_a:
    max_index.append(i)
#print(max_index)

for i in max_index:
  ans[i] = sec_max_a
for i in ans:
  print(i)

Measured memory_bytes: 22012
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

# if (b - a) <= (v-w)*t:
#     print("YES")
# else:
#     print("NO")

# if b+1000000000+w*t > a+1000000000+v*t:
#     print("NO")
# else:
#     print("YES")


if a <b:
    dis = b - a
else:
    dis = a - b

dif = v-w

if w > v:
    print("NO")
elif dis <= dif*t:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9116