akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //FILTER PRIMES
 
	public static void main(String[] args) { 
		FastScanner input = new FastScanner();
		PrintWriter w = new PrintWriter(System.out);
		long ans = 0;
		long N = input.nextLong();
		long[] cnts = new long[(int)(N+1)];
		for (long f = 1; f <= N; f++) {
			for (long s = f; s <= N; s+=f) {
				cnts[(int)s]++;
			}
		}
		for (int i = 1; i <= N; i++) {
			ans+=cnts[i]*i;
		}
		//CODE
		w.println(ans);
		w.flush();
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 105036
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

vector<int> to[200001];

int main() {
	int n, m, a, b;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	queue<int> que;
	que.push(1);
	for (int j = 0; j < 2; ++j) {
		for (int k = 0, size = que.size(); k < size; ++k) {
			int from = que.front();
			que.pop();
			for (int l = 0; l < to[from].size(); ++l) {
				if (j == 1 && to[from][l] == n) {
					cout << "POSSIBLE" << endl;
					return 0;
				}
				que.push(to[from][l]);
			}
		}
	}

	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 12400
#include <iostream>
#include <cstdio>
int main(){
	int a,b,c,d,r;
	double f;
    std::cin >> a >> b;
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
    printf("%d %d %5lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 1192
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
s = int(input())
A = [s]
for i in range(2, 1000001):
    A.append(f(A[-1]))
    if len(A) != len(set(A)):
        print(i)
        exit(0)

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

const double pi = 3.141592653589793238462643383279;
using namespace std;
using namespace __gnu_pbds;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
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 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())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

const ll INF = -(1LL<<60);

const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集

vector<vector<pair<int, int>>> g;

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

  int N, M; cin >> N >> M;

  vector<pair<int, int>> vp;
  REP(i,N) vp.push_back({i, -1});
  vector<int> P(M), Q(M), C(M);
  REP(i,M){
    cin >> P[i] >> Q[i] >> C[i];
    P[i]--;
    Q[i]--;
    vp.push_back({P[i], C[i]});
    vp.push_back({Q[i], C[i]});
  }
  sort(all(vp));
  vp.erase(unique(all(vp)), vp.end());

  int sz = vp.size();
  map<pair<int, int>, int> index;
  for(int i=0; i<vp.size(); i++) index[vp[i]] = i;

  g.resize(sz);
  for(int i=0; i<sz; i++){
    if(vp[i].second == -1) continue;
    int u = vp[i].first;
    int v = index[make_pair(u, -1)];
    g[i].push_back({v, 0});
    g[v].push_back({i, 1});
  }

  for(int i=0; i<M; i++){
    int s = index[{P[i], C[i]}], t = index[{Q[i], C[i]}];
    g[s].push_back({t, 0});
    g[t].push_back({s, 0});
  }
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
  int s = index[{0, -1}], t = index[{N-1, -1}];

  vector<int> dist(sz, INT_MAX);

  q.push(make_pair(0, s));

  dist[s] = 0;

  while(q.size()){

    int v, cost;
    auto p = q.top();
    q.pop();
    tie(cost, v) = p;
    
    if(dist[v] < cost) continue;

    for(auto e: g[v]){
      int u = e.first;
      int c = e.second;

      if(dist[u] > dist[v] + c){
        dist[u] = dist[v] + c;
        q.push(make_pair(dist[u], u));
      }
    }
  }

  if(dist[t] == INT_MAX) dist[t] = -1;
  cout << dist[t] << endl;
  return 0;
}

Measured memory_bytes: 75068
import math

N_inu, M_saru = map(int, input().split())

d = abs(N_inu - M_saru)

if (d > 1):
    ans = 0

else:
    if (d == 1):
        ans = math.factorial(N_inu) * math.factorial(M_saru)
    else:
        ans = 2 * math.factorial(N_inu) * math.factorial(M_saru)

ans = ans % (10 ** 9 + 7)

print(ans)

Measured memory_bytes: 10872
let rec lower_bound l r p =
  if r <= 1 + l
  then r
  else let m = (l + r) / 2 in
       if p m
       then lower_bound l m p
       else lower_bound m r p

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let wds = Array.init n @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun w d -> w, d in
  Printf.printf "%d\n" @@ lower_bound 0 (1 lsl 61) @@ fun x ->
    ( <= ) k @@ Array.fold_right (fun (w, d) -> ( + ) @@
      if x < w then 0
      else 1 + (x - w) / d) wds 0


Measured memory_bytes: 6656
N = int(input())
count = 0
flag = 0
for i in range(1, N+1):
    if i % 2 == 0:
        continue
    for j in range(1, i+1):
        if i % j == 0:
            count += 1
    if count == 8:
        flag += 1
    count = 0
print(flag)

Measured memory_bytes: 3060
#include<stdio.h>

#define N 101

int main(){
  int n;
  int p[N];
  int m[N][N];
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);}

  for(int i=1;i<=n;i++)
    m[i][i]=0;

  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      /*2<<21*/
      m[i][j]=2097152;
      for(int k=i;k<=j-1;k++){
	/*さいしょう比較*/
	if(m[i][j]<m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
	
	  m[i][j]=m[i][j];
	else
	  m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
  printf("%d\n",m[1][n]);
  
  return 0;


  }



  



Measured memory_bytes: 2728
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

LL sq(LL x) {
  return x * x;
}

int main() {
  int n,d;
  S2(n,d);
  int ans = 0;
  while(n--) {
    int x,y;
    S2(x,y);
    if(sq(x) + sq(y) <= sq(d)) ans++;
  }
  P(ans);
  return 0;
}


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

int h,w,a,b,s[1010][1010];

int main(){
    cin>>h>>w>>a>>b;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i<b)cout<<!(j<a);
            else cout<<(j<a);
        }
        cout<<endl;
    }
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

P A[50], B[50];

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

    int N, M;
    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        std::cin >> fst(A[i]) >> snd(A[i]);
    }

    for(int i=0;i<M;++i){
        std::cin >> fst(B[i]) >> snd(B[i]);
    }

    for(int i=0;i<N;++i){
        int mn_idx = 0;

        for(int j=1;j<M;++j){
            int dx = abs(fst(A[i]) - fst(B[j])),
                dy = abs(snd(A[i]) - snd(B[j]));
            int dx2 = abs(fst(A[i]) - fst(B[mn_idx])), dy2 = abs(snd(A[i]) - snd(B[mn_idx]));
            // std::cout << dx << ", " << dy << ": " << dx2 << ", " << dy2 << std::endl;
            if(dx + dy < dx2 + dy2){
                mn_idx = j;
            }
        }

        std::cout << (mn_idx + 1) << std::endl;
    }
    
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi n, d, x, y, tmp, ans=0;
	cin>> n >> d;
	d=d*d;

	rep(i, n){
		cin>> x >> y;
		tmp=x*x+y*y;
		if(tmp<=d) ans++;
	}

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

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

using namespace std;

int main(){
    int l,r;
    int n,m;cin >> n >> m;
    int i;
    int max,min;
    for(i = 0 ;i<m ; i++){
        cin >> l>> r;
        if(i ==0 ){
            max = l;
            min = r;
        }
        if(i >0){
            if(max <= l){
                max = l;
            }
            if(r <= min){
                min = r;
            }
        }       
    }
    int ans;
    if(max <= min){
        ans = min-max+1;
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
for i in range(h):
    a[i].insert(0,'#')
    a[i].append('#')
wall = ['#' for _ in range(w+2)]
a.insert(0, wall)
a.append(wall)
for i in a:
    print(*i, sep='')

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

int main() {
    int n; cin >> n;
    map<int, int> g;
    map<int, int> k;
    rep(i, n){
        int v; cin >> v;
        if(i%2 == 0){
            g[v]++;
        } else {
            k[v]++;
        }
    }

    int gn;
    int kn; 
    int gcnt = 0;
    int gcnt2 = 0;
    int kcnt = 0;
    int kcnt2 = 0;

    for (auto p : g){
        auto key = p.first;
        auto value = p.second;
        if(gcnt < value){
            gcnt2 = gcnt;
            gcnt = value;
            gn = key;
        } else {
            gcnt2 = max(gcnt2, value);
        }
    }

    for (auto p : k){
        auto key = p.first;
        auto value = p.second;
        if(kcnt < value){
            kcnt2 = kcnt;
            kcnt = value;
            kn = key;
        } else {
            kcnt2 = max(kcnt2, value);
        }
    }
    
    if(gn != kn){
        cout << n-gcnt-kcnt << endl;
    } else {
        int ans = min(n-gcnt-kcnt2, n-gcnt2-kcnt);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 8232
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[220000];
int main(){
  ll n,j=0,l=0,z=0;
  ld k=0;
  cin>>n;
  rep(i,0,n){cin>>a[i];k+=a[i];}
  int i=0;
  while(j*2<k){
    j+=a[i];
    i++;
  }
  while(z<i-1){l+=a[z];z++;}
  ll ans=min(abs(k-2*j),abs(k-2*l));
  cout<<ans;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int n;
int solve(int stone)
{
    if(stone+1==n) return dp[stone]=abs(h[stone]-h[stone+1]);
    if(stone+2==n) return dp[stone]=abs(h[stone]-h[stone+2]);
    if(dp[stone]!=-1) return dp[stone];
    return dp[stone]=min(abs(h[stone]-h[stone+1])+solve(stone+1),abs(h[stone]-h[stone+2])+solve(stone+2));
}

int main()
{
    int i;
    scanf("%d",&n);

    for(i=1; i<=n; i++)
        scanf("%d",&h[i]);

    memset(dp,-1,sizeof(dp));
    printf("%d\n",solve(1));


    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int digit(ll n){
    int d=0;
    while(n!=0){
        n/=10;
        d++;
    }
    return d;
}

int main() {
    ll n; cin>>n;
    int ans = 100;
    for (ll i = 1; i < 100001; i++) {
        if(ceil(1.0*n/i)==floor(1.0*n/i)){
            ans=min(ans,max(digit(i), digit(n/i)));
        }
    }

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

Measured memory_bytes: 384
N = int(input())
H = list(map(int,input().split(' ')))
DP = [0]*N
DP[0] = 0
DP[1] = abs(H[1]-H[0])
for i in range(2,N):
  DP[i] = min(DP[i-2]+abs(H[i]-H[i-2]),DP[i-1]+abs(H[i]-H[i-1]))
print(DP[N-1])

Measured memory_bytes: 13980
#include <stdio.h>
#define N 100005
#define NIL -1

struct Node{
  int p, left, right;
};
struct Node T[N];
int n;

int getDepth(int p){
  if(T[p].p == NIL) return 0;
  else{
    return getDepth(T[p].p) + 1; 
  }
}

int getHeight(int p){
  int i, count, max = 0;
  for(i = 0; i < n; i++){
    if(T[i].p == p){
    count = getHeight(i) + 1;
    if(max < count) max = count;
    }
  }
  return max;
}

main(){
  int i, c1, c2;
  int id, tmp;
  int dep[N], hei[N], sib[N], deg[N];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].left = T[i].p = T[i].right = NIL;
    deg[i] = hei[i] = 0;
    sib[i] = deg[i] = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &id, &c1, &c2);

    if(c1 == NIL && c2 == NIL){
      deg[id] = 0;

    }else if (c1 != NIL && c2 == NIL){
      T[c1].p = id;
      T[id].left = c1;
      deg[id] = 1;

    }else if(c1 == NIL && c2 != NIL){
      deg[id] = 1;
      T[c2].p = id;
      T[id].right = c2;
    }else{
      deg[id] = 2;
      T[c1].p = id;
      T[c2].p = id;
      T[id].left = c1;
      T[id].right = c2;
      sib[c1] = c2;
      sib[c2] = c1;
    }    
  }
  for(i = 0; i < n; i++){
    dep[i] = getDepth(i);
    hei[i] = getHeight(i);
  }
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, T[i].p, sib[i], deg[i], dep[i], hei[i]);
    if(T[i].p == -1){
      printf("root\n");
    }else if(T[i].left == NIL && T[i].right == NIL){
      printf("leaf\n");
    }else{
      printf("internal node\n");
    }
  }
  return 0;
}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

class Program
{
    static long count = 0;

    static void Main(string[] args)
	{
        string s = Console.ReadLine();

        int count = 0;
        int maxCount = 0;

        for(var i = 0;i < 3;i++)
        {
            if (s[i] == 'R') { 
                count++;
            }
            else
            {
                count = 0;
            }

            if(maxCount < count)
            {
                maxCount = count;
            }
        }

        Console.WriteLine(maxCount);
    }
}

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

int main(){
  
int N;
  cin >> N;
long long sum = 0, tum = 0;
long long mi = 200000000000010;  
long long A[N];
  
  for(int i = 0;i < N;i++){
  cin >> A[i];
  sum += A[i];  
  }
  
  for(int i = 0;i < N;i++){
  tum += A[i];  
  if(i+ 1 < N) mi = min(mi, abs(sum - 2 * tum));  
  }
  
  cout << mi << endl;
  return 0;
  
}

Measured memory_bytes: 1792
#include "iostream"
using namespace std;

int main() {
	bool flag = true;
	int n, x, count = 0;

	while (flag == true) {
		cin >> n >> x;
		if (n == 0 && x == 0) flag = false;
		else {
			for (int a = 1; a <= n - 2; a++) {
				for (int b = a + 1; b <= n - 1;b++) {
					for (int c = b + 1; c <= n;c++) {
						if (a + b + c == x) count++;
					}
				}
			}
			cout << count << endl;
			count = 0;
		}
	}

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; i++)
        cin >> W[i];
    vector<int> W_sum(N);
    W_sum[0] = W[0];
    for (int i = 1; i < N; i++)
        W_sum[i] += W_sum[i-1] + W[i];
        
    int ans = 100*100;
    for (int i = 0; i < N-1; i++)
        ans = min(ans, abs(W_sum[i]-(W_sum[N-1]-W_sum[i])));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define pr pair
#define f first
#define sec second
using namespace std;


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

	vector<pr<int, char>> ar;

	int l = 0;
	char start = s[0];
	for (auto& i : s) {
		if (i == start)
			l++;
		else {
			ar.push_back({ l,start });
			l = 1;
			start = i;
		}
	}
	ar.push_back({ l,start });
	
	long sum = 0;
	int n = ar.size();
	start = ar[0].sec;
	for (int i = 0; i < n - 1; i++) {
		if (ar[i].sec == ar[i + 1].sec) {
			ar[i + 1].f += ar[i].f;
			continue;
		}
		sum += 2 * min(ar[i].f, ar[i + 1].f);
		int tmp = max(ar[i].f, ar[i + 1].f) - min(ar[i].f, ar[i + 1].f);
		if (tmp == 0)
		{
			i++;
			continue;
		}
		ar[i + 1].sec = max(ar[i].f, ar[i + 1].f) == ar[i].f ? ar[i].sec : ar[i + 1].sec;
		ar[i + 1].f = tmp;
	}

	cout << sum;


	return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	string S;
	cin>>S;
	if(S[2]==S[3]&&S[4]==S[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int, L: "List[int]"):
    L.sort()
    return sum(L[i] not in [L[j], L[k]] and L[j] != L[k] and L[i] + L[j] > L[k] for i in range(N) for j in range(i+1, N) for k in range(j+1, N))


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(N, L)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 76340
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		String s = in.next();
		System.out.println(solve(n, s));
		in.close();
	}

	private static int solve(int n, String s) {
		int w2 = 0;
		for (int i = 0; i < s.length(); i++)
			if (s.charAt(i) == '.')
				w2++;

		int b1 = 0;
		int ans;
		if (w2 > s.length() - w2)
			ans = s.length() - w2;
		else
			ans = w2;
		
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '.') {
				w2--;
			} else {
				b1++;
			}
			if (b1 + w2 < ans)
				ans = b1 + w2;
		}
		return ans;
	}
}


Measured memory_bytes: 28456
N = int(input())
a = list(map(lambda x: int(x) - 1,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
prev = -3
answer = 0
for v in a:
  answer += b[v]
  if prev + 1 == v:
    answer += c[prev]
  prev = v
print(answer)
  

Measured memory_bytes: 3060
#include<cstdio>
#define MOD 100000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int dp[101][101][4];//0-vv,1-v>,2->v,3->>

int sum(int w, int h){
	int res = 0;
	rep(i, 4)
		(res += dp[w][h][i]) %= MOD;
	return res;
}
int main(){
	rep(i, 101){//w
		rep(j, 101){//h
			if (!i){ dp[i][j][0] = 1; continue; }
			if (!j){ dp[i][j][3] = 1; continue; }
			dp[i][j][0] = (dp[i][j - 1][0] + dp[i][j - 1][2]) % MOD;
			dp[i][j][1] = dp[i - 1][j][0];
			dp[i][j][2] = dp[i][j - 1][3];
			dp[i][j][3] = (dp[i - 1][j][1] + dp[i - 1][j][3]) % MOD;
		}
	}
	int w, h;
	while (scanf("%d%d", &w, &h), w)
		printf("%d\n", sum(w - 1, h - 1));
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

int main(){
    int a;
    vector<int> buffer;
    while(cin >> a){
        if(a == 0){
            cout << buffer.back() << endl;
            buffer.pop_back();
        }
        else{
            buffer.push_back(a);
        }
    }
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s; cin >> s;
    bool a[4]={};
    rep(i,0,s.size()){
        if(s[i]=='N') a[0] = true;
        if(s[i]=='W') a[1] = true;
        if(s[i]=='S') a[2] = true;
        if(s[i]=='E') a[3] = true;
    }
    if(a[0] == a[2] && a[1] == a[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

struct Sweet{ int i, p, q, r; };

int main() {
    int n;
    while (cin >> n, n) {
        vector<Sweet> v;
        int i, p, q, r;
        for (int k=0; k<n; ++k) {
            cin >> i >> p >> q >> r;
            v.push_back((Sweet){ i, p, q, r });
        }
        int P, Q, R, C;
        cin >> P >> Q >> R >> C;
        bool NA = true;
        for (int k=0; k<(int)v.size(); ++k) {
            if (v[k].p <= P && v[k].q <= Q && v[k].r <= R &&
                v[k].p*4 + v[k].q*9 + v[k].r*4 <= C) {
                cout << v[k].i << endl;
                NA = false;
            }
        }
        if (NA) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <cstdio>
#define MAXN 500000
using namespace std;

int cnt, INF = 2000000000;
int A[500001];
int L[MAXN/2 + 2], R[MAXN/2 + 2];
void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	
	for (int i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1] = INF;
	R[n2] = INF;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}else {
			A[k] = R[j++];
		}
	}
}

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

int main(int argc, char *argv[]) {
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		scanf("%d", &A[i]);
	}
	mergeSort(A, 0, m);
	for (int i = 0; i < m; i++) {
		if (i) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 7120
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var temp = toIntArr(input[0].split(' '));
	var h = temp[0];
	var w = temp[1];
	var as = [];
	for(var i = 0; i < h; i++){
		as[i] = toIntArr(input[i+1].split(' ')).map(e=>e%2===0?0:1);
	}

	var n = 0;
	var ans = [];
	var flag = false;
	var m = 0;
	for(var i = 0; i < h; i++){
		if(i%2===0){
			for(var j = 0; j < w; j++){
				if(as[i][j]===1){
					if(flag){
						flag = false;
						m = n;
				}else{
						flag = true;
					}
				}
				if(flag){
						n++;
						if(j===w-1){
							ans.push([i+1,j+1,i+2,j+1]);
						}else{
							ans.push([i+1,j+1,i+1,j+2]);
						}
				}
			}
		}else{
			for(var j = w-1; j > -1; j--){
				if(as[i][j]===1){
					if(flag){
						flag = false;
						m = n;
					}else{
						flag = true;
					}
				}
				if(flag){
						n++;
						if(j===0){
							ans.push([i+1,j+1,i+2,j+1]);
						}else{
							ans.push([i+1,j+1,i+1,j]);
						}
				}
			}
		}
	}

	console.log(m);
	for(var i = 0; i < m; i++){
		console.log(ans[i][0],ans[i][1],ans[i][2],ans[i][3]);
	}
}

Measured memory_bytes: 57484
#include <cstdio>
#include<cstring>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef unsigned long long int ULL;
typedef long long LL;
char s[1000005];

int main(){
   int n,m;
   int ans=0;
   scanf("%d%d",&n,&m);
   if(n>m){
    ans+=n;
    n--;
   }
   else{
    ans+=m;
    m--;
   }
   if(n>m){
    ans+=n;
    n--;
   }
   else{
    ans+=m;
    m--;
   }
   printf("%d\n",ans);
  
}


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

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

    return false;
};

using namespace std;

int main(void)
{
    int N, W;
    cin >> N >> W;

    vector<long long> w(N);
    vector<long long> v(N);

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

    vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, -1));

    for (int w_i = 0; w_i <= W; w_i++)
    {
        dp[0][w_i] = 0;
    }

    for (int i = 0; i < N; i++)
    {
        for (int w_i = 0; w_i <= W; w_i++)
        {
            if (w_i >= w[i])
            {
                chmax(dp[i + 1][w_i], dp[i][w_i - w[i]] + v[i]);
            }

            chmax(dp[i + 1][w_i], dp[i][w_i]);
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){

int N;
cin>>N;
long long B[N];
B[N]=INF;
B[0]=0;
for(int i=1;i<N;i++){
    cin>>B[i];
}
long long ans=0;
for(int k=N;k>0;k--){
  ans+=min(B[k],B[k-1]);  
}
ans+=B[1];

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

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

bool isprime(int x)
{
    if (x == 2)
        return true;
    if (x < 2 || x % 2 == 0)
        return false;

    int i = 3;
    while (i <= sqrt(x)) {
        if (x % i == 0)
            return false;
        i += 2;
    }
    return true;
}

int main()
{
    int n, x, cnt = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (isprime(x))
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 300005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l,n,v;
	cin>>n>>v;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	ll a,b,mid,an=-1;
	a=1; b=1e18;
	while(b>=a){
		mid=(a+b)/2;
		ll c=0;
		for(i=1;i<=n;i++){
			// (ar[i]/mid)<=x
			c+=((ar[i]-1)/mid);
		}
		// cout<<c<<" "<<v<<" "<<mid<<endl;
		if(c<=v){
			an=mid;
			b=mid-1;
		}
		else a=mid+1;
	}
	cout<<an;
	return 0;	
}

Measured memory_bytes: 5116
N = int(input())
p = list(map(int, input().split()))

sum_p = 0
count = 1

for i in p:
  if i == count:
    count += 1
  else:
    sum_p += 1
    count += 1

if sum_p <= 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

const int MAX = 2000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, K;
    long long answer = 0;

    // input
    cin >> N >> K;

    // process
    COMinit();

    for (int i = 1; i <= K; i++) {
        answer = COM(K - 1, i - 1) * COM(N - K + 1, i) % 1000000007;

        cout << answer << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func isPrime(x int) bool {
	for i := 2; i <= int(math.Sqrt(float64(x))); i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	defer write.Flush()

	var x int
	fmt.Fscan(read, &x)

	for {
		if isPrime(x) {
			fmt.Fprintln(write, x)
			return
		}
		x++
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  long N; cin >> N;
  long a[300010];
  for (int i=0; i<3*N; i++){
    cin >> a[i];
  }
  long ans; ans=0;
  sort(a, a+(3*N),greater<int>());
  
  for (int i=0; i<=2*N; i++){
    if (i%2==1){
      ans = ans+a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

typedef long double ld;
typedef complex<ld> Point;

const ld eps = 1e-9, pi = acos(-1.0);

namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		if (lhs.real() < rhs.real() - eps) return true;
		if (lhs.real() > rhs.real() + eps) return false;
		return lhs.imag() < rhs.imag();
	}
}

Point input_point() {
	ld x, y;
	cin >> x >> y;
	return Point(x, y);
}

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

class Circle {
public:
	Point p;
	ld r;
	Circle() : p(Point(0, 0)), r(0) {}
	Circle(Point p, ld r) : p(p), r(r) {}
};

vector<Point> is_cc(Circle c1, Circle c2) {
	vector<Point> res;
	ld d = abs(c1.p - c2.p);
	ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
	ld dfr = c1.r * c1.r - rc * rc;
	if (abs(dfr) < eps) dfr = 0.0;
	else if (dfr < 0.0) return res; // no intersection
	ld rs = sqrt(dfr);
	Point diff = (c2.p - c1.p) / d;
	res.push_back(c1.p + diff * Point(rc, rs));
	if (dfr != 0.0) res.push_back(c1.p + diff * Point(rc, -rs));
	return res;
}

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

    int n;
    while(cin>>n,n){
        vector<Point> ps(n);
        for(int i=0;i<n;i++){
            ps[i] = input_point();
        }
        if(n==1){
            cout<<n<<endl;
            continue;
        }
        int res=1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                Circle c1=Circle(ps[i],1.0),c2=Circle(ps[j],1.0);
                vector<Point> vs=is_cc(c1,c2);
                int sz=vs.size();
                if(sz==0) continue;
                for(int k=0;k<sz;k++){
                    Point p=vs[k];
                    int tmp=0;
                    for(int idx=0;idx<n;idx++){
                        if(abs(ps[idx]-p)<=1+eps) tmp++;
                    }
                    res=max(res,tmp);
                }
            }
        }
        cout<<res<<endl;
    }
}


Measured memory_bytes: 3364
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b)-1);i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

#define __MAX 1000000001

int main(void){
	int n;
	cin >> n;
	vector<pair<int, int>> a(n+1);
	a[0] = mp(0, 0);
	rep(i, n){
		cin >> a[i+1].fir;
		a[i+1].sec = i+1;
	}
	
	sort(a.begin(), a.end());
	
	int m = __MAX;
	int p = n+1, q;
	lli ans[n];
	rep(i, n) ans[i] = 0;
	
	while(true){
		p--;
		if(p == 0) break;
		q = distance(a.begin(), lower_bound(a.begin(), a.end(), mp(a[p].fir, -__MAX)));
		m = min(m, a[q].sec);
		ans[m-1] += (lli(n-q+1))*(lli(a[q].fir - a[q-1].fir));
		p = q;
	}
	
	rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  string s;
  while (cin >> s) {
    if (s.size() < 26) {
      for (char c = 'a'; c <= 'z'; c++) {
        if (s.find(c) == string::npos) {
          printf("%s\n", (s + c).c_str());
          break;
        }
      }
    } else {
      string sold = s;
      if (!next_permutation(s.begin(), s.end())) {
        printf("-1\n");
      } else {
        while (true) {
          string t = s.substr(0, s.size() - 1);
          if (t > sold) {
            s = t;
          } else {
            break;
          }
        }
        printf("%s\n", s.c_str());
      }
    }
  }

  return 0;
}


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

int p[105000];

int main(){
    int n;
    p[0] = p[1] = 1;
    for(int i = 2;i * i <= 105000;i++){
	if(p[i])continue;
	for(int j = i * i;j <= 105000;j += i){
	    p[j] = 1;
	}
    }
    while(cin >> n, n){
	int res = 0;
	for(int i = 0;i <= n / 2;i++){
	    if(p[i] == 0  && p[n - i] == 0)res++;
	}
	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1568
import sys
import math
def input(): return sys.stdin.readline().rstrip()

def main():
    n, d = map(int, input().split())
    x = [tuple(map(int, input().split())) for _ in range(n)]

    ans = 0
    for ix, i in enumerate(x):
        for j in x[ix+1:]:
            if math.sqrt(sum([(i[k]-j[k]) ** 2 for k in range(d)])).is_integer():
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define mem(arr, i) fill(arr, arr + sizeof(arr), i)
#define MEM(arr, i) memset(arr, i, sizeof(arr))
#define Push push_back
#define Pair make_pair
#define ALL(x) x.begin(), x.end()
#define X first
#define Y second
#define ACCEL \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
	cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv(maxN+5, 1);

void ADD(lli &x, lli y) {
	x += y;
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = (x % mod + mod) % mod;
}

lli mypow(lli b, lli e) {
	if (b == 0) return 0;
	lli ans = 1;
	while (e) {
		if (e & 1) MUL(ans, b);
		MUL(b, b);
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow(n, mod - 2);
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

/// coding area ///

const lli maxn = 1E5;

void solve() {
	lli n;
	cin >> n;
	cout << n * (n - 1) / 2 << '\n';
}

int main() {
//	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<cmath>
#include<queue>
#include<algorithm>

using namespace std;
using ll=long long;
using db=double;

typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<bool> vbl;

int inf=(1LL<<31)-1;
int MOD=1000000007;

#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=a;i<=b;i++)
#define f_j(a,b) for(int j=a;j<=b;j++)
#define vvii(c,a,b) vector<vector<ii>> c(a,vector<ii>(b,0))
#define vvll(c,a,b) vector<vector<ll>> c(a,vector<ll>(b,0))
#define vvstr(c,a,b) vector<vector<string> c(a,vector<string>(b,0))
#define vvbol(c,a,b) vector<vector<bool>> c(a,vector<bool>(b,true))

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

    int n;
    cin >> n;
    vll num(n,0);
    fi(0,n)
    {
        cin >> num.at(i);
    }
    ll ans=1;
    fi(0,n)
    {
        ans=ans/__gcd(ans,num.at(i))*num.at(i);
    }
    cout << ans << endl;

    return(0);
}

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		int t = sc.nextInt();
		double area = (2 * Math.PI * (double)t);
		System.out.println(area);
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 33088
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
long long s[N],p[N],f[N];
int n,A,B;
int main(){
    //freopen("1.out","w",stdout);
    //freopen("1.in","r",stdin);
    memset(f,23,sizeof(f));
    scanf("%d%d%d",&n,&A,&B),f[0]=0;
    for(int i=1,x;i<=n;i++){
        scanf("%d",&x);
        for(int j=0;j<=n;j++)
            if(j)   p[j]=min(p[j-1],f[j]);
            else    p[j]=f[j];
        for(int j=0;j<=x;j++)   f[j]+=A;
        for(int j=x+1;j<=n;j++) f[j]+=B;
        f[x]=min(f[x],p[x]);
    }
    long long ans=f[n+1];
    for(int i=0;i<=n;i++)   ans=min(ans,f[i]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 384
import math

def Sieve_of_Eratosthenes(N):
    if N<2:
        prime = [False for i in range(N+1)]
        return prime
 
    prime = [True for i in range(N+1)]
    prime[0] = False
    prime[1] = False
 
    for i in range(2, int(N**0.5)+1):
        if prime[i]:
            for j in range(i*2, N+1, i):
                prime[j] = False
 
    return prime


def gcd(a,b):
    if b>a:
        a,b=b,a
    while b:
        a,b=b, a%b
    return a

a,b=map(int,input().split())
n=gcd(a,b)
prime=Sieve_of_Eratosthenes(int(math.sqrt(n))+2)
ans=1
x=n
for p in range(len(prime)):
    if prime[p]:        
        if x==1:
            break
        if x%p==0:
            ans+=1
            while x%p==0:
                x=x//p

if x!=1: ans+=1
print(ans)

Measured memory_bytes: 11032
import java.util.Scanner;
import java.util.TreeSet;
import java.util.HashMap;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        final String s = scan.next();
        final char[] sArray = s.toCharArray();
        final String t = scan.next();
        final char[] tArray = t.toCharArray();
        scan.close();
        int prev = 0;       // 前文字の位置
        long result = s.length();
        HashMap<Character,TreeSet<Integer>> index = new HashMap<Character,TreeSet<Integer>>();
        TreeSet<Integer> tmp = null;
        // s内の各英文字がどの位置に出現しているかを記録
        for(int i = 0; i < s.length(); i++){
            if(!index.containsKey(sArray[i])){
                tmp = new TreeSet<Integer>();
            }else{
                tmp = index.get(sArray[i]);
            }
            tmp.add(i + 1);
            index.put(sArray[i], tmp);
        }

        for(int i = 0; i < t.length(); i++){
            if(!index.containsKey(tArray[i])){
                System.out.println("-1");
                return;
            }
            tmp = index.get(tArray[i]);
            // 前回位置より大きい値の中で最小を取り出す
            if(tmp.higher(prev) == null){
                // 値が存在しない場合
                result += s.length();
                prev = tmp.first();
            }else{
                // 値が存在する場合
                prev = tmp.higher(prev);
            }
        }
        result = result - (s.length() - prev);
        System.out.println(result);
        scan.close();
    }
}

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CY cout<<"YES\n"
#define CN cout<<"NO\n"
#define MOD 1000000007
using namespace std;
using ll = long long;
vector<ll> dp(100005,-1);

void solve()
{
    int a[5];
    rep(i,5)cin>>a[i];
    rep(i,5) if(a[i]==0) { cout<<i+1;return;}
}
int main() {
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    ll t;t=1;
  //  cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3832
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
 
using namespace std;

typedef long long ll;

const int MOD = 998244353; 
const int MAXN = 1e6 + 239;

int add(int a, int b) {
    ll res = (ll)a + b;
    return res % MOD;
}

int sub(int a, int b) {
    ll res = (ll)a - b;
    return (res % MOD + MOD) % MOD;
}


int mul(int a, int b) {
    ll res = (ll)a * b;
    return res % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mul(res, a);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

int dvv(int a, int b) {
    return mul(a, binpow(b, MOD - 2));
}

int cnt[MAXN];
int ml[MAXN];
int sn[MAXN];

int pr[MAXN];
int meb[MAXN];

vector<int> divs[MAXN];

void init() {
    for (int i = 1; i < MAXN; i++) {
        divs[i].push_back(i);
        for (int j = 2 * i; j < MAXN; j += i) {
            divs[j].push_back(i);
        }
    }
    fill(ml, ml + MAXN, 0);
    fill(cnt, cnt + MAXN, 0);
    fill(pr, pr + MAXN, 1);
    meb[1] = 1;
    for (int i = 2; i < MAXN; i++) {
        if (pr[i]) {
            for (int j = i; j < MAXN; j += i) {
                pr[j] = 0;
                meb[j] ^= 1;
            }
        }
    }
    for (int i = 2; i < MAXN; i++) {
        if (meb[i]) {
            meb[i] = -1;
        } else {
            meb[i] = 1;
        }
    }
    for (int i = 2; i * i < MAXN; i++) {
        for (int j = i * i; j < MAXN; j += i * i) {
            meb[j] = 0;
        } 
    }
}

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

    init();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        for (auto t : divs[x]) {
            ml[t] = add(ml[t], mul(sn[t], x));
            sn[t] = add(sn[t], x);
        }
    }
    for (int i = 1; i < MAXN; i++) {
        for (int j = i; j < MAXN; j += i) {
            int t = j / i;
            if (meb[t] == 1 && ml[j] > 0) {
                cnt[i] = add(cnt[i], ml[j]);
            } else if (meb[t] == -1 && ml[j] > 0) {
                cnt[i] = sub(cnt[i], ml[j]);
            }
        }
    }
    int res = 0;
    for (int i = 1; i < MAXN; i++) {
        res = add(res, dvv(cnt[i], i));
    }
    cout << res << endl;
}  

Measured memory_bytes: 134400
def zan(n):
	return 0 if n%10==0 else 10-n%10

def marume(n):
	return n if n%10==0 else n//10*10+10
def resolve():
	a=[int(input()) for i in range(5)]
	l=list(map(zan,a))
	mx=max(l)
	print(sum(list(map(marume,a)))-mx)
	
resolve()

Measured memory_bytes: 38256
n,m=input().strip().split(" ")
n,m=[int(n),int(m)]
f=[0 for _ in range(n+1)]
f1=[0 for _ in range(n+1)]
for i in range(m):
    a,b=input().strip().split(" ")
    a,b=[int(a),str(b)]
    if b=="AC":
        f[a]=1
    elif b=="WA":
        if f[a]==0:
            f1[a]+=1
su=0
for i in range(n+1):
    if f[i]==1:
        su+=f1[i]
print(sum(f),su)


Measured memory_bytes: 4760