akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
from heapq import heapify, heappush, heappop


def solve(N: int, A: "List[int]", B: "List[int]"):

    lh = []
    for i, b in enumerate(B):
        heappush(lh, (-b, i))

    count = 0
    while lh:
        b, i = heappop(lh)
        a, b, c = A[i], B[i], B[i-1]+B[(i+1) % N]
        if b > a and b > c:
            d, m = divmod(b-a, c)
            if d <= 0:
                break
            count += d
            B[i] = a+m
            if m > 0:
                heappush(lh, (-B[i], i))

    if A != B:
        count = -1

    print(count)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B)


if __name__ == '__main__':
    main()


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

int main(){
  int N,buf;
  cin >> N;

  vector<int> raw(N);
  unordered_map<int, int64_t> data;
  for(int i=0; i<N; i++){
    cin >> buf;
    raw.at(i)= buf;
    if(data.count(buf)) data.at(buf)++;
    else             data[buf]= 1;
  }

  int64_t tot= 0;
  for(auto elem:data){
    tot+= elem.second*(elem.second- 1)/2;
  }

  for(int i=0; i<N; i++){
    int64_t Ndel= data.at(raw.at(i));
    int64_t del= (Ndel-1)*(Ndel-2)/2- Ndel*(Ndel-1)/2;

    cout << tot+ del << endl;
  }
}

Measured memory_bytes: 8392
#include <bits/stdc++.h>
    using namespace std;
    
    typedef pair<long , long> pair_t;

    bool comp(const pair_t &a , const pair_t &b){
      return a.first > b.first;
    }

    int main(){
      int n , m;
      cin >> n >> m;
      vector<long> an;
      long a;
      for(int i = 0; i < n ; i++){
          cin >> a;
          an.push_back(a);
      }
      sort(an.begin() , an.end(), std::greater<long>());
      long b, c;
      vector<pair_t> vp;
      for(int i = 0; i < m ; i++){
          cin >> b >> c;
          pair_t p;
          p.first = c;
          p.second = b;
          vp.push_back(p);
      }
      sort(vp.begin(),vp.end() , comp );
      long long ans = 0;
      for(int i = 0; i < vp.size() ; i++){
          if(an[an.size()-1] > vp[i].first ){
              break;
          }
          for(int j = 0 ; j < vp[i].second && an.size() > 0 ; j++){
              if(an[an.size()-1] < vp[i].first){
                 ans += vp[i].first;
                 //an[j] =  vp[i].first;
                 an.pop_back();
              }else{
                  break;
              }
          }
          //sort(an.begin() , an.end());
      }
      
      for(int i = 0 ; i < an.size() ; i++){
          ans += an[i];
      }
      
      cout << ans << endl;
      return 0;
    }

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
const int maxn=3e5+10;
map<char,char>vis;
int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  vis['A']='T';
  vis['C']='G';
  vis['G']='C';
  vis['T']='A';
  char ch;
  cin>>ch;
  cout<<vis[ch]<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static final int INF = 2000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0){
				break;
			}

			TreeMap<Integer, LinkedList<Point>> map = new TreeMap<Integer, LinkedList<Point>>();
			
			Point start = null, goal = null;
			int max = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					String s = sc.next();
					if(s.equals("S")){
						start = new Point(0, i, j);
						LinkedList<Point> temp = new LinkedList<Point>();
						temp.add(start);
						map.put(0, temp);
					}else if(s.equals("G")){
						goal = new Point(INF, i, j);
					}else if(s.matches("[0-9]+")){
						int num = Integer.parseInt(s);
						max = max < num ? num : max;
						if(map.containsKey(num)){
							map.get(num).add(new Point(INF, i, j));
						}else{
							LinkedList<Point> temp = new LinkedList<Point>();
							temp.add(new Point(INF, i, j));
							map.put(num, temp);
						}
					}
				}
			}
			LinkedList<Point> temp = new LinkedList<Point>();
			temp.add(goal);
			map.put(max + 1, temp);
			System.out.println(fm(map));
		}
		sc.close();
	}
	static int fm(TreeMap<Integer, LinkedList<Point>> map){
		int m = 1;
		LinkedList<Point> from = map.get(0);
		LinkedList<Point> to = null;
		while(true){
			if(!map.containsKey(m)){
				break;
			}
			to = map.get(m);
//			System.out.print(m+":");
			for(Point p : to){
				for(Point s : from){
					int temp = Math.abs(p.x - s.x) + Math.abs(p.y - s.y);
					p.c = p.c > temp + s.c ? temp + s.c : p.c;
				}
//				System.out.print("[" + p.c + "]");
			}
//			System.out.println();
			from = to;
			m++;
		}		
		return map.get(m - 1).get(0).c;
	}
}
class Point{
	int c;
	int x;
	int y;
	Point(int c, int y, int x){
		this.c = c;
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 72436
class Node
  attr_reader :id, :siblings
  attr_accessor :state
 
  def initialize(id)
    @id = id
    @siblings = []
    @distances = {}
    @state = :white
  end
 
  def add(sibling, distance)
    @siblings << sibling
    @distances[sibling.id] = distance
  end
 
  def distance_from(other)
    @distances[other.id]
  end
end
 
if $PROGRAM_NAME == __FILE__
  n = gets.to_i
 
  nodes = []
 
  n.times do
    id, _, *rest = gets.chomp.split.map(&:to_i)
 
    nodes[id] ||= Node.new(id)
    node = nodes[id]
 
    rest.each_slice(2) do |sibling_id, distance|
      nodes[sibling_id] ||= Node.new(sibling_id)
      sibling = nodes[sibling_id]
      node.add(sibling, distance)
    end
  end
 
  distances = Array.new(n, Float::INFINITY)
 
  distances[0] = 0
  nodes[0].state = :gray
 
  loop do
    current = nil
    min = Float::INFINITY
 
    nodes.each do |node|
      next if node.state == :black
 
      distance = distances[node.id]
 
      if distance < min
        min = distance
        current = node
      end
    end
 
    break unless current
 
    current.state = :black
 
    current_distance = distances[current.id]
 
    current.siblings.each do |sibling|
      next if sibling.state == :black
 
      distance = current_distance + current.distance_from(sibling)
 
      if distance < distances[sibling.id]
        distances[sibling.id] = distance
        sibling.state = :gray
      end
    end
  end
 
  puts distances.map.with_index {|distance, id| [id, distance].join(' ') }.join("\n")
end

Measured memory_bytes: 9140
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define inf 10000000000000
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
using namespace std;
signed main()
{
    fast;
    
    ll n,m,le,i,j,k;
    cin>>n>>m>>le;
    ll dj[n+5][n+5] , ha[n+5][n+5];
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=n;j++)
    	{
    		if(i==j) dj[i][j] = 0,ha[i][j] = 0;
    		else dj[i][j] = inf,ha[i][j] = inf;
    	}
    }
    for(i=0;i<m;i++)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	dj[a][b] = c;
    	dj[b][a] = c;
    }
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=n;j++)
    	{
    		for(k=1;k<=n;k++)
    		{
    			if(dj[j][i] + dj[i][k] < dj[j][k])
    			{
    				dj[j][k] = dj[j][i] + dj[i][k];
    			}
    		}
    	}
    }
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=n;j++)
    	{
    		if(i==j) continue;
    		if(dj[i][j]<=le) ha[i][j] = 1;
    	}
    }
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=n;j++)
    	{
    		for(k=1;k<=n;k++)
    		{
    			if(ha[j][i] + ha[i][k] < ha[j][k])
    			{
    				ha[j][k] = ha[j][i] + ha[i][k];
    			}
    		}
    	}
    }
    ll q;
    cin>>q;
    while(q--)
    {
    	ll so , de;
    	cin>>so>>de;
    	if(ha[so][de]==inf) cout<<"-1"<<"\n";
    	else cout<<ha[so][de]-1<<"\n";
    }
}

Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            int[] borders = RIntAr();
            int[] questions = RIntAr();

            int a = questions.Count(x => x <= borders[0]);
            int b = questions.Count(x => borders[0] < x  && x <= borders[1]);
            int c = questions.Count(x => x > borders[1]);

            Console.WriteLine(Math.Min(a,Math.Min(b,c)));
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 13268
n=1000001   
i=1
p=[]
po=[]
nn=1
while nn<n:
    p.append(nn)
    if nn%2==1:
        po.append(nn)
    i+=1
    nn= i*(i+1)*(i+2)//6
np=len(p)
npo=len(po)

pp=[]
def dpf(nn,pp,nnp):
    dpm=[i for i in range(nn+1)]
    for ppi in pp[1:nnp]:
        if ppi>nn:
            break
        for j in range(ppi,nn+1):
            dpij=1+dpm[j-ppi]
            if j>=ppi and dpm[j]>dpij:
                dpm[j]=dpij
#        print("i",i,"dpm:",dpm)
    return dpm

nlist=[]
while True:
    n=int(input())
    if n==0:
        break
    else:
        nlist.append(n)

nmax=max(nlist)
dpm1=dpf(nmax,p,np)
dpm2=dpf(nmax,po,npo)

for i in nlist:
    print(dpm1[i],dpm2[i])
        



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

int main() {
    int N;
    cin>>N;
    int ans=0;
    vector<int> s(N,0);
    int mini=100;
    for (int i=0;i<N;i++){
        cin>>s[i];
        ans+=s[i];
        if (s[i]%10!=0){
            mini=min(mini,s[i]);
        }
    }
    if (ans%10==0){
        ans-=mini;
        if (mini==100)ans=0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int main(void){
    int n;
    static int a[N],b[N],c[N];
    static int memo[N][3] = {};
    int i;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
    }
    
    memo[0][0] = a[0];
    memo[0][1] = b[0];
    memo[0][2] = c[0];
    
    for(i = 1; i < n; i++){
        memo[i][0] = memo[i-1][1] + a[i];
        if(memo[i][0] < memo[i-1][2] + a[i]){
            memo[i][0] = memo[i-1][2] + a[i];
        }
        
        memo[i][1] = memo[i-1][0] + b[i];
        if(memo[i][1] < memo[i-1][2] + b[i]){
            memo[i][1] = memo[i-1][2] + b[i];
        }
        
        memo[i][2] = memo[i-1][0] + c[i];
        if(memo[i][2] < memo[i-1][1] + c[i]){
            memo[i][2] = memo[i-1][1] + c[i];
        }
    }
    
    if(memo[n-1][0] > memo[n-1][1] && memo[n-1][0] > memo[n-1][2]){
        printf("%d\n", memo[n-1][0]);
    }else if(memo[n-1][1] > memo[n-1][2]){
        printf("%d\n", memo[n-1][1]);
    }else{
        printf("%d\n", memo[n-1][2]);
    }
    
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int k;
		int A;
		int B;
		  Scanner scan = new Scanner(System.in);
		  
		 // Read the next integer from the screen 
		 	k= scan.nextInt(); 
		 	
	        
	        // Read the next integer from the screen 
	        A = scan.nextInt(); 
	        
	       
	        
	        // Read the next integer from the screen 
	        B= scan.nextInt();
	        check(k,A,B);
	        }
	public static void check(int k,int A,int B)
	{
		int l=0;
		for(int i=A;i<=B;i++)
		{
			if(i%k==0)
			{
			l=1	;
			}
		}
		
		if(l==1)
		{
			System.out.print("OK");
		}
		else 
		{
			System.out.print("NG");	
		}	
	}
}


Measured memory_bytes: 27040
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

vector<pair<lint, int>> Pfact(lint num) {
	vector<pair<lint, int>> res;
	for (lint i = 2; i * i <= num; i++) {
		int cnt = 0;
		while (num % i == 0) {
			cnt++;
			num /= i;
		}
		if (cnt) res.emplace_back(i, cnt);
	}
	if (num != 1) res.emplace_back(make_pair(num, 1));
	return res;
}

class Combi {
private:
	vector<lint> fac, inv, finv;

	void init(int N) {
		fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;

		for (int i = 2; i < N; 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;
		}
	}

public:
	Combi(int N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }

	int Cmod(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;
	}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	auto pfM = Pfact(M);
	
	Combi C(100030); // 30 > log2(10^9)
	lint ans = 1;
	for (const auto &elem : pfM) {

		ans *= C.Cmod(N - 1 + elem.second, N - 1);
		ans %= MOD;

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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 (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

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

int main(){
    int h, w; cin >> h >> w;
    int sx, sy; cin >> sx >> sy; sx--; sy--;
    int gx, gy; cin >> gx >> gy; gx--; gy--;
    vector<vector<char>> data(h,vector<char>(w));
    rep(i,h) rep(j,w) cin >> data[i][j];

    vector<vector<int>> dist(h,vector<int>(w,1<<30));
    dist[sx][sy] = 0;
    deque<pair<int,int>> que;
    que.push_back(make_pair(sx,sy));

    while(!que.empty()){
        auto p = que.front();
        que.pop_front();
        int xx = p.first, yy = p.second;

        rep(i,4){
            int x = xx + dx[i], y = yy + dy[i];
            if(0 <= x && x < h && 0 <= y && y < w && data[x][y] == '.' && dist[x][y] > dist[xx][yy]){
                dist[x][y] = dist[xx][yy];
                que.push_front(make_pair(x,y));
            }
        }

        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                int x = xx + i, y = yy + j;
                if(0 <= x && x < h && 0 <= y && y < w && data[x][y] == '.' && dist[x][y] > dist[xx][yy] + 1){
                    dist[x][y] = dist[xx][yy] + 1;
                    que.push_back(make_pair(x,y));
                }
            }
        }
    }

    cout << (dist[gx][gy] == 1<<30 ? -1 : dist[gx][gy]) << endl;
    return 0;
}

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

using namespace std;

const int N = 600010;

int min_end[N];
int if_add[N];
int a[N], b[N];
pair <int, int> e[N];

int main() {
  int n, k;
  scanf("%d",&n);
  k = 2;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &e[i].first, &e[i].second);
    e[i].second++;
  }
  sort(e, e + n);
  for (int i = 0; i < n; i++) {
    a[i] = e[i].first;
    b[i] = e[i].second;
  }
  min_end[n - 1] = b[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    min_end[i] = min(min_end[i + 1], b[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    if_add[i] = max(min_end[i + 1], b[i]) - a[i];
  }
  sort(if_add, if_add + n - 1);
  reverse(if_add, if_add + n - 1);
  long long ans = min_end[0] - a[n - 1];
  for (int i = 0; i < k - 1; i++) {
    ans += if_add[i];
  }
  {
    vector <int> lengths;
    for (int i = 0; i < n; i++) {
      lengths.push_back(b[i] - a[i]);
    }
    sort(lengths.rbegin(), lengths.rend());
    long long other = 0;
    for (int i = 0; i < k - 1; i++) {
      other += lengths[i];
    }
    ans = max(ans, other);
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 9852
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b;
    scanf("%d%d", &a, &b);

    printf("%d\n", MAX(0,a-b*2));


    return 0;
}



Measured memory_bytes: 128
n=int(input())
c=list(map(int,input().split()))
q=int(input())
su=0
d=[]
for i in range(1000003):
	d.append(0)
for i in range(len(c)):
	d[c[i]]=d[c[i]]+1
	su=su+c[i]
for j in range(q):
	r,s=map(int,input().split())
	su=su-d[r]*r+d[r]*s
	d[s]=d[s]+d[r]
	d[r]=0
	print(su)



Measured memory_bytes: 24372
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int d_right = d[N / 2];
    int d_left = d[N / 2 - 1];
    int ans = d_right - d_left;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
ps = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    if ps[i] < ps[i+1] and ps[i+1] <= ps[i+2]:
        cnt+=1
    elif ps[i+2] < ps[i+1] and ps[i+1] <= ps[i]:
        cnt+=1
    else:
        continue
print(cnt)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
const int maxx = 2e5 + 7;
const int Mod = 1e9 + 7;
typedef long long ll;
ll n;
int a, b;
ll fac[maxx], inv[maxx];

ll qwe(ll x, int y) {
	ll res = 1ll;
	while(y) {
		if(y & 1) res = res * x % Mod; 
		x = x * x % Mod;
		y >>= 1; 
	}
	return res;
}

ll Com(ll n, ll m) {
	ll res = 1ll;
	for(ll i = n; i >= n - m + 1; i--) res = res * i % Mod;
	return res * inv[m] % Mod;
}

int main() {
	fac[0] = inv[0] = 1; 
	for(int i = 1; i <= maxx; i++) fac[i] = fac[i - 1] * i % Mod;
	inv[maxx] = qwe(fac[maxx], Mod - 2);
	for(int i = maxx - 1; i >= 1; i--) inv[i] = inv[i + 1] * (i + 1) % Mod;
	scanf("%lld %d %d", &n, &a, &b);
	ll ans = qwe(2, n) - 1;
	ans = (ans - Com(n, a) + Mod) % Mod;
	ans = (ans - Com(n, b) + Mod) % Mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
void print_c(int a[100][100], int b[100], int n, int m)
{
    int c[100] = {0};

    for (int i = 0; i < n; i++) //配列ｃに値を代入
    {
        for (int j = 0; j < m; j++)
        {
            c[i] += a[i][j] * b[j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        printf("%d\n", c[i]);
    }
}
int main(void)
{
    int a[100][100];
    int b[100];
    int n, m;

    scanf("%d %d", &n, &m); //n.mに値を代入
    for (int i = 0; i < n; i++)
    { //配列aに値を順に代入
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    for (int i = 0; i < m; i++)
    { //配列bに値を代入
        scanf("%d", &b[i]);
    }

    print_c(a, b, n, m);

    return 0;
}



Measured memory_bytes: 2748
N = int(input())
a = list(map(int, input().split()))

c = [0] * 9
for i in range(N):
    if a[i] >= 3200:
        c[8] += 1
    else:
        for j in range(8):
            if 400*j <= a[i] and a[i] <= 400 * (j + 1) -1:
                c[j] = 1

min1 = max(1, sum(c[:8]))
max1 = sum(c)

print(min1, max1)

Measured memory_bytes: 9144
#include<stdio.h>
int main(){
  int X, Y, Z;
  int s, t;
  scanf("%d %d %d",&X, &Y, &Z);

  t = X;
  s = Y;
  X = Z;
  Y = t;
  Z = s;
  printf("%d %d %d",X, Y, Z);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

ll GCD(ll a,ll b){
    return b?GCD(b,a%b):a;
}
ll LCM(ll a,ll b){
    if(a==0)return b;
    if(b==0)return a;
    return a/GCD(a,b)*b;
}

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

    int n,m;
    cin>>n>>m;
    int a[n];
    int fl=0,l=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        fl=LCM(fl,a[i]/2);
        l=LCM(l,a[i]);
    }
    if(fl>m){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if((fl-a[i]/2)%a[i]!=0){
            cout<<0<<endl;
            return 0;
        }
    }
    int ans=1;
    m-=fl;
    ans+=m/l;
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

int main()

{
    ll ans=0;
    int n;
    cin>>n;
    ll h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=1;i<n;i++){
        if(h[i]<h[i-1]){
            ans+=(h[i-1]-h[i]);
            h[i]=h[i-1];
        }
    }
    cout<<ans;
    return 0;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  int A = 0, B = 0, a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  reverse(a, a + N);
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      A += a[i];
    } else {
      B += a[i];
    }
  }

  cout << A - B << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstdio>
#include<map>
#include<set>
#include<queue>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;


ll n;
ll a[3] = {3,5,7};
ll ans = 0;
string tmp;
ll len;

void dfs(ll now,ll num){
    //now桁目

    //cout << now << " " << num << endl;
    string t = to_string(num);
    bool three = false,five = false,seven = false;
    if(num > n || t.length() > len){
        //大きいならreturn
        return;
    }

    //nより小さい場合、357があるか調べる
    REP(i,t.length()){
        if(t[i] == '3'){
            three = true;
        }
        if(t[i] == '5'){
            five = true;
        }
        if(t[i] == '7'){
            seven = true;
        }
    }

    if(three && five && seven){
        //357全てある、この時必ずnum<=nは成り立っている
        ans++;
    }

    for(int i = 0;i < 3;i++){
        dfs(i+1,num*10+a[i]);
    }
    return;
}


int main(){

    cin >> n;
    tmp = to_string(n);
    len = tmp.length();
    dfs(0,0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class Dice():
    def __init__(self, numbers):
        self.top = numbers[0]
        self.s = numbers[1]
        self.e = numbers[2]
        self.w = numbers[3]
        self.n = numbers[4]
        self.bot = numbers[5]
    def rot(self, dir):
        top, s, e, w, n, bot = (self.top, self.s, self.e, self.w, self.n, self.bot)
        if dir == 'N':
            self.top = s
            self.s = bot
            self.e = e
            self.w = w
            self.n = top
            self.bot = n
        elif dir == 'S':
            self.top = n
            self.s = top
            self.e = e
            self.w = w
            self.n = bot
            self.bot = s
        elif dir == 'E':
            self.top = w
            self.s = s
            self.e = top
            self.w = bot
            self.n = n
            self.bot = e
        elif dir == 'W':
            self.top = e
            self.s = s
            self.e = bot
            self.w = top
            self.n = n
            self.bot = w
    def getTop(self):
        return self.top

li = list(map(int, input().split()))
D = Dice(li)
command = input()
for dir in command:
    D.rot(dir)
print(D.getTop())


Measured memory_bytes: 5608
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    S =sRaw()
    S = S+"."
    nR = 0
    maxNR = 0
    for s in S:
        if s=="R":
            nR+=1
        else:
            maxNR = max(maxNR,nR)
            nR =0
    print (maxNR)

main()


Measured memory_bytes: 67528
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	long long a;
	int i;

	scanf("%d",&i);
	for(a=1;i>1;a=a*i,i--);
	printf("%lld\n",a);
	for(i=0;i<=1000000000;i++);
	return 0;
}

Measured memory_bytes: 592
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    const char *Yes = "Yes";
    const char *No = "No";

    int A, B, C;
    if (scanf("%d%d%d", &A, &B, &C) < 3) return 0;

    printf("%s\n", A <= C && C <= B ? Yes : No);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod mod_pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return mod_pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = mod_pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * mod_pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * mod_pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};

#define FACT_MAX 1000000
mod fact[FACT_MAX], fact_inv[FACT_MAX];
void prep_fact(int N)
{
    fact[0] = 1;
    for (int n = 1; n <= N; ++n) {
        fact[n] = n * fact[n-1];
    }
}
void prep_fact_inv(int N)
{
    for (int n = 0; n <= N; ++n) {
        fact_inv[n] = mod_pow(fact[n], -1);
    }
}
void prep(int N)
{
    prep_fact(N);
    prep_fact_inv(N);
}
mod comb(int n, int k) {if (n < 0 || k < 0 || k > n) return 0; else return fact[n] * fact_inv[n-k] * fact_inv[k];}
mod multi_choose(int n, int k) {return comb(n + k - 1, k);}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    if ((X+Y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    int M = Y - (X+Y)/3;
    int N = X - (X+Y)/3;
    
    prep(M+N);
    cout << comb(M + N, M) << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int M;
	cin>>M;
	ce(48-M)
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# problem A

n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)

def prob_a(n, a):
    ans = 0    
    for i in range(0, 2*n, 2):
        ans += a[i+1]
    return(ans)
    
x = prob_a(n=n, a=a)
print(x)

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

int main() {
  int a, b;
  double c;
  cin >> a >> b;
  
  c = a * b;
  
  if (c / 2 - (a * b / 2) == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int a, b;
    cin >> a >> b;

    if ( a >= 13 ) {
        cout << b << endl;
    }
    else if ( a >= 6 ) {
        cout << b / 2 << endl;
    }
    else {
        cout << 0 << endl;
    }

    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<vector<ll>> connection(N);
  map<vector<ll>, ll> color;
  vector<vector<ll>> ab;
  for (ll i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    a -= 1;b -= 1;
    color[{min(a, b), max(a, b)}] = -1;
    connection.at(a).pb(b);
    connection.at(b).pb(a);
    ab.push_back({min(a, b), max(a, b)});
  }
  ll M = 0;
  for (ll i = 0; i < N; ++i) {
    M = max(M, (ll)connection.at(i).size());
  }
  queue<ll> q;
  q.push(0);
  while (!q.empty()) {
    ll now = q.front();
    q.pop();
    map<ll, bool> used;
    vector<ll> n_list;
    for (ll i = 0; i < connection.at(now).size(); ++i) {
      ll next = connection.at(now).at(i);
      ll col = color[{min(now, next), max(now, next)}];
      used[col] = true;
      if (col == -1) {
        q.push(next);
        n_list.pb(next);
      }
    }
    ll index = 0;
    for (ll i = 0; i < n_list.size(); ++i) {
      for (ll j = index; j < M; ++j) {
        index = j + 1;
        if (!used[j]) {
          color[{min(now, n_list.at(i)), max(now, n_list.at(i))}] = j;
          break;
        }
      }
    }
  }
  cout << M << "\n";
  for (ll i = 0; i < N - 1; ++i) {
    cout << color[{ab.at(i).at(0), ab.at(i).at(1)}] + 1 << "\n";
  }
}


Measured memory_bytes: 25784
from collections import Counter
from itertools import product
N = int(input())
S = ['AAAA','AAAG','AAAC','AAAT','AAGA','AAGG','AAGT','AACA','AACC','AACT','AATA','AATG','AATC','AATT','AGAA','AGAG','AGAT','AGGA','AGGG','AGGT','AGTA','AGTG','AGTT','ACAA','ACAG','ACAC','ACAT','ACCA','ACCG','ACCC','ACCT','ACTA','ACTG','ACTC','ACTT','ATAA','ATAG','ATAC','ATAT','ATGA','ATGG','ATGT','ATCA','ATCG','ATCC','ATCT','ATTA','ATTG','ATTC','ATTT','GAAA','GAAG','GAAC','GAAT','GAGA','GAGG','GAGT','GATA','GATG','GATC','GATT','GGAA','GGAG','GGAT','GGGA','GGGG','GGGC','GGGT','GGCA','GGCG','GGCC','GGCT','GGTA','GGTG','GGTC','GGTT','GCAA','GCAG','GCAC','GCAT','GCGA','GCGG','GCGC','GCGT','GCCA','GCCG','GCCC','GCCT','GCTA','GCTG','GCTC','GCTT','GTAA','GTAG','GTAC','GTAT','GTGA','GTGG','GTGC','GTGT','GTCA','GTCG','GTCC','GTCT','GTTA','GTTG','GTTC','GTTT','CAAA','CAAG','CAAC','CAAT','CAGA','CAGG','CAGT','CACA','CACC','CACT','CATA','CATG','CATC','CATT','CGAA','CGAG','CGAT','CGGA','CGGG','CGGC','CGGT','CGCA','CGCG','CGCC','CGCT','CGTA','CGTG','CGTC','CGTT','CCAA','CCAG','CCAC','CCAT','CCGA','CCGG','CCGC','CCGT','CCCA','CCCG','CCCC','CCCT','CCTA','CCTG','CCTC','CCTT','CTAA','CTAG','CTAC','CTAT','CTGA','CTGG','CTGC','CTGT','CTCA','CTCG','CTCC','CTCT','CTTA','CTTG','CTTC','CTTT','TAAA','TAAG','TAAC','TAAT','TAGA','TAGG','TAGT','TACA','TACC','TACT','TATA','TATG','TATC','TATT','TGAA','TGAG','TGAT','TGGA','TGGG','TGGC','TGGT','TGCA','TGCG','TGCC','TGCT','TGTA','TGTG','TGTC','TGTT','TCAA','TCAG','TCAC','TCAT','TCGA','TCGG','TCGC','TCGT','TCCA','TCCG','TCCC','TCCT','TCTA','TCTG','TCTC','TCTT','TTAA','TTAG','TTAC','TTAT','TTGA','TTGG','TTGC','TTGT','TTCA','TTCG','TTCC','TTCT','TTTA','TTTG','TTTC','TTTT']
S = set(S)
mod = 10**9+7
DP1 = Counter()
for a, b, c in product('AGCT', repeat = 3):
    DP1[a+b+c] = 1
DP1['AGC'] = 0
DP1['ACG'] = 0
DP1['GAC'] = 0
for _ in range(N-3):
    DP2 = Counter()
    for k, v in DP1.items():
        for x in 'AGCT':
            s = k + x
            if s in S:
                DP2[s[1:]] = (DP2[s[1:]] + v) % mod
    DP1 = DP2.copy()
print(sum(v for v in DP1.values()) % mod)


Measured memory_bytes: 42480
def main():
    N = int(input())
    total = 0.
    
    for _ in range(N):
      x, u = input().split()
      if u == 'JPY':
        total += int(x)
      else:
        total += float(x) * 380000.0

    print(total)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int X;
    cin >>X;
    for(;;){
        for(int i=X-1;1<=i;i--){
          if(X%i==0&&(!(i==1))){
              break;;
          }
          if(i==1){
              cout << X<<endl;
              return 0;;
          }
        }
        X++;
    }
}

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

struct Linear_Sieve{
int n;
vector<int> lp,primes;
//lp[i]...the least prime of i. primes...prime numbers
Linear_Sieve(int n = 1):n(n),lp(n+1){
    for(int i = 2;i < n+1;i++){
        if(lp[i] == 0) {
            primes.push_back(i);
            lp[i] = i;
        }
        for(int j = 0;j<primes.size() && primes[j] <= lp[i] && i*primes[j] < n+1; ++j) lp[i*primes[j]] = primes[j];
    }
}
bool isPrime(int x) {return lp[x] == x;}

vector<int> factorList(int x){
    //make list which contains prime factors of x. Ans it toralates multipled components.
    vector<int> res;
    while(x != 1){
        res.push_back(lp[x]);
        x /= lp[x];
    }
    return res;
}

vector<pair<int,int>> factor(int x){
        //make list of pairs which couple prime factor and multiplicity.
    vector<int> fl = factorList(x);
    if(fl.size() == 0) return{};
    vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
    for(int p : fl){
        if(res.back().first == p){
            res.back().second++;
        }else{
            res.emplace_back(p,1);
        }
    }
    return res;
}
};

int main(){
    // ll n;
    // ll ans = 0;
    // cin >> n;
    // vector<ll> a(n);
    // rep(i,n){
    //     // for (int j=i;j<=n;j += i+1)a[j]+=1;
    //     ll r = n/(i+1);
    //     ans += (i+1)*r*(1+r)/2;
    // }
    // rep(i,n)ans += (i+1)*a[i];
    // cout << ans << endl;

    int n;
    cin >> n;
    ll ans = 0;
    Linear_Sieve S(n+1);
    for(int i = 1;i<=n;i++){
        ll temp = 1;
        for(auto p :  S.factor(i)){
            temp *= p.second+1;
        }
        //cout << i << " " << temp << endl;
        ans += i*temp;
        
    }

    cout << ans << endl;
}

Measured memory_bytes: 46516
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        long N=sc.nextInt();
        long a=1;
        long b=10*10*10*10*10*10*10*10*10+7;
        for(long i=1;i<=N;i++){
            a=a*i%b;
            if(i==N){
                System.out.println(a);
            }
        }
        
        
     
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
	int a, b, c, d, e, f;
	int zyo[10];
	int z[10];
	int wei;
	
	for (b = 0; b < 10; b++) {
		zyo[b] = 1;
	}
	for (b = 1; b < 10; b++) {
		zyo[b] = zyo[b-1] * 2;
	}
	while (scanf("%d", &a) != EOF) {
		c = 0;
		e = 0;
		for (d = 9; d >= 0; d--) {
			if (c + zyo[d] <= a) {
				c += zyo[d];
				z[e] = zyo[d];
				e++;
			}
		}	
		for (d = e - 1; d >= 0; d--) {
			if (d != 0) {
				printf("%d ", z[d]);
			}
			else {
				printf("%d\n", z[d]);
			}
		}
	}
	
	return (0);
}

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

#define ll long long

int sumdig(string s)
{
	int sum=0;
	for(int i=0;i<s.size();i++)
	{
		sum+=(s[i]-'0');
	}
	return sum;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	int sn=sumdig(s);
	if(sn%9==0) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3720
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int n,m,i,a,b;
	cin>>n>>m;
	int d[n]={0};
	for(i=0;i<m;i++){
		cin>>a>>b;
		d[a-1]++;
		d[b-1]++;
	}
	for(i=0;i<n;i++)cout<<d[i]<<endl;
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,k;cin>>n>>k;
  vector<int> a(n);
  int i,j;
  ll ans=20000000000;
  rep(i,n)cin>>a[i];
  rep(i,1<<n)
  {
    ll cost=0;
    int colors=0;
    rep(j,n)
    {
      if(1<<j&i)colors++;
    }
    if(colors<k)continue;
    int maxh=0;
    rep(j,n)
    {
      if((1<<j&i)&&maxh>=a[j])
      {
        cost+=maxh+1-a[j];
        maxh++;
      }
      else
      {
        maxh=max(maxh,a[j]);
      }
    }
    ans=min(ans,cost);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
def main():
    k = int(input())
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a[k-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}


D abs(pll A,pll B){return sqrt((A.F-B.F)*(A.F-B.F)+(A.S-B.S)*(A.S-B.S));}


int main(){
    pll S,T;
    cin>>S>>T;
    ll n;
    cin>>n;
    vector<pair<pll,ll>> A(n);
    cin>>A;
    A.push_back({S,0});
    A.push_back({T,0});
    vector<D> dp(n+2,E);
    dp[n]=0;
    typedef pair<D,ll> P;
    priority_queue<P,vector<P>,greater<P>> Q;
    Q.push({0,n});
    while(!Q.empty()){
        P w=Q.top(); Q.pop();
        if(dp[w.S]!=w.F){continue;}
        for(ll i=0;i<n+2;i++){
            if(dp[i]>w.F+max(abs(A[i].F,A[w.S].F)-A[i].S-A[w.S].S,(D)0)){
                dp[i]=w.F+max(abs(A[i].F,A[w.S].F)-A[i].S-A[w.S].S,(D)0);
                Q.push({dp[i],i});
            }
        }
    }
    cout<<fixed<<setprecision(12)<<dp.back()<<endl;
    
    
    return 0;
}


Measured memory_bytes: 10348
import numpy as np
N, M, X = map(int, input().split())

CA = [list(map(int, input().split())) for _ in range(N)]
CA = np.array(CA)
C = [CA[i][0] for i in range(N)]

ans = sum(C)

Flag = False

for i in range(2 ** N):
    A_count = np.zeros(M)
    C_count = 0
    bin_str = format(i, 'b')
    if len(bin_str) < N:
        bin_str = '0' * (N - len(bin_str)) + bin_str
    for j, s in enumerate(bin_str):
        if s == '1':
            A_count = A_count + CA[j][1:]
            C_count += CA[j][0]
    flag = True
    for k in range(M):
        if A_count[k] < X:
            flag = False
            break
    if flag and C_count <= ans:
        ans = C_count
        Flag = True

if Flag == False:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 26980
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	cout<<x2+(y1-y2)<<" ";
	cout<<y2+(x2-x1)<<" ";
	cout<<x1+(y1-y2)<<" ";
	cout<<y1+(x2-x1)<<" ";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  auto f = [](int x) {
    int k = 0;
    while (x) k++, x /= 10;
    return k;
  };
  int ans = 0;
  reps(i, n) {
    if (f(i) % 2 == 1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
A_V = input().split()
A = int(A_V[0])
V = int(A_V[1])
B_W = input().split()
B = int(B_W[0])
W = int(B_W[1])
T = int(input())

if abs(B-A) <= (V-W)*T:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9184