akhauriyash/Code-Regression huggingface dataset:
/*
 *  author : Atul Anand   
 *  created on : Sat Mar 28 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        long yen = in.nextLong();
        long ans = (yen/500) * 1000 + ((yen % 500)/5) * 5 ; 
        println(ans);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 22612
N = int(input())
moromoro = [list(map(int,input().split())) for _ in range(N)]
moromoro.sort()

t,x,y = 0,0,0
for i in range(N):
    time = moromoro[i][0] - t
    dx = abs(moromoro[i][1] - x)
    dy = abs(moromoro[i][2] - y)
    if  dx + dy > time:
        print('No')
        exit()
    if (time - dx - dy) % 2 == 1:
        print('No')
        exit()
    t = moromoro[i][0]
    x = moromoro[i][1]
    y = moromoro[i][2]
print('Yes')




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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<long long> a(n, 0);

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

	long long b=a[0];
	for (int i = 1; i < n; i++) {
		b = (b^a[i]);
	}

	if ((b^a[0])==a[0]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 1024
N, T = map(int, input().split())
D = [0 for i in range(N)]
maxA = 0
for i in range(N):
    A, B = map(int, input().split())
    D[i] = [A,B]
G = sorted(D)
maxT = T + G[N-1][0]
dp = [[0 for j in range(maxT)] for i in range(N)]
gans = G[0][1]
dp[0][G[0][0]] = G[0][1]
for i in range(1,N):
    for j in range(maxT):
        nowans = dp[i-1][j]
        if j >= G[i][0] and j <= T-1+G[i][0]:
            nowans = max(nowans, dp[i-1][j-G[i][0]] + G[i][1])
        dp[i][j] = nowans
        gans = max(gans, nowans)
#print(dp)
print(gans)

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

int main(void){
  int n; cin >> n;
  int k; cin >> k;
  vector<int> h(n);
  for(int i =0; i < n; i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  long long int ans = 0;
  for(int i = 0; i < n-k; i++){
    ans += h.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int n = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();
	//int x = 0;
        int c = 0;
 
	for(int i=n;i>=1;i--){
	    int sum = 0;
	    int m = i;
	    while(m>0){
		sum = sum + (m%10);
		m = m/10;	
	    }
	    if(sum>=a && sum<=b){
		c = c + i;
	    }
	}
	System.out.println(c);
    }
}


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x - a) > abs(x - b)){
    cout << "B" << endl;
  }else{
    cout << "A" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=(1<<14)+5,mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
namespace fft{
	int w[N],R[N];
	void init(int n){
		int d=0;
		while ((1<<d)<n)
			d++;
		assert((1<<d)==n);
		For(i,0,n-1)
			R[i]=(R[i>>1]>>1)|((i&1)<<(d-1));
		w[0]=1,w[1]=Pow(3,(mod-1)/n);
		For(i,2,n-1)
			w[i]=(LL)w[i-1]*w[1]%mod;
	}
	void FFT(int *a,int n,int flag){
		For(i,0,n-1)
			if (i<R[i])
				swap(a[i],a[R[i]]);
		for (int d=1,t=n>>1;d<n;d<<=1,t>>=1)
			for (int i=0;i<n;i+=d<<1)
				for (int j=0;j<d;j++){
					int tmp=(LL)w[t*j]*a[i+j+d]%mod;
					a[i+j+d]=Del(a[i+j]-tmp);
					Add(a[i+j],tmp);
				}
		if (flag<0){
			int inv=Pow(n,mod-2);
			For(i,0,n-1)
				a[i]=(LL)a[i]*inv%mod;
			reverse(a+1,a+n);
		}
	}
}
using fft::FFT;
int n,m,len;
void Mul(int *A,int *B,int *C){
	static int a[N],b[N];
	For(i,0,len-1)
		a[i]=A[i],b[i]=B[i];
	fft::init(len);
	FFT(a,len,1),FFT(b,len,1);
	For(i,0,len-1)
		a[i]=(LL)a[i]*b[i]%mod;
	FFT(a,len,-1);
	For(i,0,len-1)
		C[i]=a[i];
}
int a[N],b[N],c[N];
int Fac[N],Inv[N];
void prework(){
	int n=N-1;
	for (int i=Fac[0]=1;i<=n;i++)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
}
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
int main(){
	prework();
	n=read(),m=read();
	len=1;
	while (len<=n)
		len<<=1;
	len<<=1;
	//y[a+b] += x[a]*C(a+b+2,a)
	//y[a+b]/(a+b+2)! += x[a]/a! * (1/(b+2)!)
	a[0]=1;
	For(i,1,n)
		b[i]=Inv[i+2];
//	outarr(b,0,n);
	fft::init(len);
	FFT(b,len,1);
	while (m--){
		For(i,0,n)
			c[i]=a[i];
		FFT(a,len,1);
		For(i,0,len-1)
			a[i]=(LL)a[i]*b[i]%mod;
		FFT(a,len,-1);
		For(i,0,len-1)
			if (i>n)
				a[i]=0;
			else {
				a[i]=(LL)a[i]*(i+1)%mod*(i+2)%mod;
				Add(a[i],(LL)c[i]*(i*(i+1)/2+1)%mod);
			}
//		For(i,0,n)
//			printf("%lld ",(LL)a[i]*Fac[i]%mod);puts("");
	}
	int ans=0;
	For(i,0,n)
		Add(ans,(LL)a[i]*Fac[i]%mod*C(n,i)%mod);
	cout<<ans<<endl;
	return 0;
}

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

signed main(void)
{
	int n;
	cin >> n;
	bool b[n + 1];

	rep(i, n + 1) b[i] = false;
	for (int i = 2; i <= n; i*=2)
	{
		b[i] = true;
	}
	for (int i = n; i > 0; i--)
	{
		if (b[i])
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << n << endl;
	return 0;
}


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

int main() {
  int n;
  scanf("%d", &n);
  if(n / 100 == 7 || n / 10 % 10 == 7 || n % 10 == 7)
    printf("Yes\n");
  else
    printf("No\n");
}

Measured memory_bytes: 3656
#include <iostream>

int main(void){
    int inputIntA = 0;
    int inputIntB = 0;
    
    /* input */
    std::cin >> inputIntA >> inputIntB;
    
    /* output */
    if(inputIntA < inputIntB)
    {
        std::cout << "a < b" << std::endl;
    }
    else if(inputIntA > inputIntB)
    {
        std::cout << "a > b" << std::endl;
    }
    else
    {
        /* a = b case */
        std::cout << "a == b" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    int B[111];
    for(int i=1;i<N;i++) cin >> B[i];
    B[0] = MOD;
    B[N] = MOD;
    
    int ans = 0;
    for(int i=0;i<N;i++){
        ans += min(B[i],B[i+1]);
    }
    
    cout << ans << endl;
    
    return 0;
}


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


long long dp[100000][3];
int main() {
        int n;
        scanf("%d", &n);
        int a[n][3];
        for (int i = 0; i < n; i++)
                for (int j = 0; j < 3; j++) scanf("%d", &a[i][j]), dp[i][j] = -1e9;

        for (int i = 0; i < 3; i++) dp[0][i] = a[0][i];

        for (int i = 1; i < n; i++) {
                for (int to = 0; to < 3; to++) {
                        for (int from = 0; from < 3; from++) {
                                if (from ^ to) dp[i][to] = max(dp[i][to], dp[i - 1][from] + a[i][to]);
                        }
                }
        }

        printf("%lld", max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}));
}

Measured memory_bytes: 7232
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<cmath>
#include<sstream>
#include<queue>
#include<stack>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long ll;

int main()
{
 	int n;
 	cin >> n;
 	int num=0;
 	for(int i=1;i<=n;i++){
 		num=num*10+7;
 		num=num%n;
 		if(num%n==0){
 			cout << i << endl;
 			return 0;
		 }
	}
	cout << -1 << endl;
 	return 0;
}

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 0;
	for(int a = 1; a <= n-1; ++a){
		for(int b = 1; a*b <= n-1; ++b){
			if(n - a*b > 0) ++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

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

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

void test_case() {
  int n;
  cin >> n;
  vector<double> V(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> V[i];
  }
  sort(V.begin() + 1, V.end());
  for (int i = 2; i <= n; ++i) {
    V[i] = (V[i] + V[i - 1]) / 2;
  }
  cout << fixed << setprecision(10) << V.back() << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


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

void Main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  int cnt = 0;
  rep(i,N) {
    cin >> a[i];
    while (a[i] %2 == 0) {
      cnt++;
      a[i] /= 2;
    }
  }
  cout << cnt << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

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

c = sorted([ai - bi for ai, bi in zip(a, b)])
if sum(c) < 0:
    print(-1)
    exit()

ans, cnt = 0, 0
for i in c:
    if i >= 0:
        break
    ans += 1
    cnt += i
for i in c[::-1]:
    if cnt >= 0:
        print(ans)
        break
    ans += 1
    cnt += i


Measured memory_bytes: 24064
from collections import deque

H,W = list(map(int, input().split()))
maze = [input() for _ in range(H)]

def bfs(maze,visited,gx,gy):
    stack = deque([[0,0]])
    if maze[0][0] == '#':
        visited[0][0] = 1 
    else:
        visited[0][0] = 0 
    while stack:
        y,x = stack.pop()
        count = visited[y][x]
        
        for j,k in ([1,0],[0,1]):
            new_y,new_x = y+j,x+k
            if  new_x >= gx or  new_y >= gy:
                continue
            elif maze[new_y][new_x] == "#" and maze[y][x] == '.' and visited[new_y][new_x] > count+1:
                visited[new_y][new_x] = count+1
                stack.appendleft([new_y, new_x])
            elif maze[new_y][new_x] == "#" and maze[y][x] == '.' and visited[new_y][new_x] <= count+1:
                continue
            elif visited[new_y][new_x] > count:
                visited[new_y][new_x] = count
                stack.appendleft([new_y, new_x])
    return visited[gy-1][gx-1]

inf = float('inf')
visited = [[inf]*W for _ in range(H)]
print(bfs(maze,visited,W,H))


Measured memory_bytes: 3572
n=int(input())
s=input()

N=[str(i).zfill(3) for i in range(1000)]

cnt=0
for n in N:
  n0=s.find(n[0])
  if n0==-1:
    continue
  n1=s.find(n[1],n0+1)
  if n1==-1:
    continue
  n2=s.find(n[2],n1+1)
  if n2!=-1:
    cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
typedef pair <int,int> P;
#define val first
#define num second

int main() {
  while(1) {
    int n;
    cin>>n;
    if(n==0) break;
    vector <P> mp;
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      if(i==0) mp.push_back(P(a,1));
      else if(i%2==0) {
	if(mp.back().val == a) mp[mp.size()-1].num++;
	else mp.push_back(P(a,1));
      }
      else if(i%2==1){
	if(mp.back().val == a)mp[mp.size()-1].num++;
	else if(mp.size()==1) mp[0].val  = a,mp[0].num++;
	else mp[mp.size()-2].num += mp[mp.size()-1].num+1,mp.pop_back(); 
      }
    }

    int ans = 0;
    for(int i=0;i<mp.size();i++) 
      if(mp[i].val == 0) ans += mp[i].num;
    cout << ans <<endl;
  }
  return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n, k;
  cin >> n >> k;
  vi x;
  REP(i, n) { x.PB(read()); }
  int ans = 1e18;
  REP(l, n - k + 1) {
    int r = l + k - 1;
    if ((l > 0 && x[l - 1] > 0) || (r < n - 1 && x[r + 1] < 0)) continue;
    if (x[l] < 0 && x[r] > 0)
      chmin(ans, abs(x[l]) + abs(x[r]) + min(abs(x[l]), abs(x[r])));
    else
      chmin(ans, max(abs(x[r]), abs(x[l])));
  }
  print(ans);
}


Measured memory_bytes: 1400
import sys
from collections import defaultdict

sys.setrecursionlimit(2000000)

V, E = map(int, input().split())

Edges = defaultdict(set)

for i in range(E):
    s, t = map(int, input().split())
    Edges[s].add(t)
    Edges[t].add(s) 
    
preord = [None] * V 
parent = [None] * V 
lowlink = [None] * V
isVisited = [False] * V
counter = 0

def DFS(cur, prev):
    global counter
    preord[cur] = lowlink[cur] = counter
    isVisited[cur] = True
    counter += 1
    
    for edge in Edges[cur]: 
        if not isVisited[edge]: 
            parent[edge] = cur
            DFS(edge, cur)
            lowlink[cur] = min(lowlink[cur], lowlink[edge])
        elif edge != prev: 
                lowlink[cur] = min(lowlink[cur], preord[edge])
        
DFS(0,-1) 

art_point = [False] * V
r = 0

for _ in filter(lambda x: x == 0, parent):
    r += 1
    if r > 1:
        art_point[0] = True
        break

for i in range(1, V):
    p = parent[i]
    if p and preord[p] <= lowlink[i]:
        art_point[p] = True
 
for i, e in enumerate(art_point):
    if e: print(i)

Measured memory_bytes: 26076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int D, N, T[210], A[210], B[210], C[210];
    cin >> D >> N;
    for (int i = 0; i < D; ++i) cin >> T[i];
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i] >> C[i];
 
    int dp[D + 1][N];
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < N; ++i) {
        if (A[i] <= T[0] && T[0] <= B[i]) dp[0][i] = 0;
    }
 
    for (int i = 0; i < D - 1; ++i) {
        for (int j = 0; j < N; ++j) {
            if (dp[i][j] != -1) {
                for (int k = 0; k < N; ++k) {
                    if (A[k] <= T[i + 1] && T[i + 1] <= B[k]) {
                        dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abs(C[k] - C[j]));
                    }
                }
            }
        }
    }
 
    int ans = 0;
    for (int i = 0; i < N; ++i) ans = max(ans, dp[D - 1][i]);
    cout << ans << endl;
     
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int A, P;
    cin >> A >> P;
    int ans = A * 3 + P;
    ans /= 2;
    printf("%lld\n", ans);

    return 0;
}


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

#define EPS (1e-7)
#define INF (1<<25)
#define PI (acos(-1))

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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;

int main() {
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;

  cout << string(dy, 'U');
  cout << string(dx, 'R');

  cout << string(dy, 'D');
  cout << string(dx, 'L');

  cout << 'L' << string(dy+1, 'U');
  cout << string(dx+1, 'R') << 'D';

  cout << 'R' << string(dy+1, 'D');
  cout << string(dx+1, 'L') << 'U';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    int A, B, C, K;
    cin >> A >> B >> C;
    cin >> K;

    int cnt = 0;
    while(A >= B) {
        B *= 2;
        ++cnt;
    }
    while(B >= C) {
        C *= 2;
        ++cnt;
    }

    if (cnt <= K)
        cout << "Yes" << endl;
     else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
def main():
    import bisect
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    A,B = [0],[0]
    for i in range(n):
        A.append(A[i]+a[i])
    for i in range(m):
        B.append(B[i]+b[i])
    ans = 0
    for i in range(n+1):
        left = k-A[i]
        if left>=0:
            nm = i+bisect.bisect_right(B,left)-1
            if ans<nm:
                ans = nm
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 47556
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func max(x, y float64) float64 {
	if x > y {
		return x
	}
	return y
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, k := readInt(), readInt()
	cs := make([]float64, n+1)
	for i := 1; i <= n; i++ {
		p := readInt()
		cs[i] = (float64(p)+1)/2 + cs[i-1]
	}
	ans := 0.0
	for i := k; i <= n; i++ {
		ans = max(ans, cs[i]-cs[i-k])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3072
#define _USE_MATH_DEFINES  // M_PI等のフラグ

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <list>

#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

void solve(){
    int N, A;
    cin >> N >> A;

    int rest;
    rest = N%500;

    if (rest <= A) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Measured memory_bytes: 3616
H = int(input())
ans = 0
num = 1
A = [1]
for i in range(100):
  if H / 2 < 1:
    ans += 1
    break
  else:
    H = H / 2
    ans += 1
for j in range(ans-1):
  A.append(num*2)
  num = num*2
print(sum(A))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
   scanf("%d",&n);
    vector<int>dp(3);
    while(n--)
    {
        vector<int>new_dp(3,0);
        vector<int>c(3);
        for(int i=0;i<3;i++)
        scanf("%d",&c[i]);
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            if(i!=j)
            {
            new_dp[j]=max(new_dp[j],dp[i]+c[j]);    
            }
        }
        dp=new_dp;
        
      
    }
      printf("%d\n",max({dp[0],dp[1],dp[2]}));
    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;cin>>n;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  priority_queue<int> pq1;
  priority_queue<int> pq2;
  vector<int> ans(0);
  rep(i,n)
  {
    pq1.push(a[i]);
    pq2.push(a[n-1-i]);
    //cout<<pq1.top()<<' '<<pq2.top()<<endl;
    while(pq1.size()>0&&pq1.top()==pq2.top())
    {
      pq1.pop();
      pq2.pop();
    }
    if(pq1.size()==0)
    {
      ans.emplace_back(i+1);
    }
  }
  rep(i,ans.size())
  {
    if(i!=0)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
}


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

using namespace std;
using ll = long long;


int main()
{
    int x, y;
    cin >> x >> y;
    if(x == 2 || y == 2){
        cout << "No" << endl;
    }else if(x == 4 || x == 6 || x == 9 || x == 11){
        if(y == 4 || y == 6 || y == 9 || y == 11){
            cout << "Yes" << endl;
        }else {
            cout << "No" << endl;
        }
    }else{
        if(y == 4 || y == 6 || y == 9 || y == 11){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

   String[] string =  br.readLine().split(" ");

   int x = Integer.parseInt( string[0] );
   int y = Integer.parseInt( string[1] );

   int tmp;

   if(x < y){

	   tmp = x;
	   x = y;
	   y = tmp;

   }

   int r = x % y;
   while(r!=0){
     x = y;
     y = r;
	 r = x % y;
   }

   System.out.println(y);

 }
}

Measured memory_bytes: 24316
##templete
lst = []
5.times do |i|
  lst[i] = gets.chomp.to_i
end

k = gets.chomp.to_i

for i in 0..3 do
  for j in i+1..4 do
    if lst[j] - lst[i] > k
      puts ":("
      exit 0
    end
  end
end

puts "Yay!"


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

int main() {
	int a, b, k;
	cin>>a>>b>>k;
	int ans=min(a, b)+1;
	while(k) {
		ans--;
		if (a%ans == 0 && b%ans == 0)
			k--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  string s;
  in(s);
  n = s.size();
  bool h = true;
  rep(i, n){
    if(s[i] != s[n - i - 1])
      h = false;
  }
  rep(i, n / 2){
    if(s[i] != s[n / 2 - i - 1])
      h = false;
    if(s[n - i - 1] != s[n / 2 + i + 1])
      h = false;
  }
  if(h)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
import random
T = int(input())
A = [list(map(int,input().split())) for _ in range(T)]
C = ["E","W","S","N"]
for j in range(T-1):
    for k in range(j+1,T):
        N = A[k]
        for _ in range(100):
            i = random.choice(C)
            if i == "E":
                N[0],N[2],N[3],N[5] = N[3],N[0],N[5],N[2]
            elif i == "W":
                N[3],N[0],N[5],N[2] = N[0],N[2],N[3],N[5]
            elif i == "S":
                N[0],N[1],N[4],N[5] = N[4],N[0],N[5],N[1]
            else:
                N[4],N[0],N[5],N[1] = N[0],N[1],N[4],N[5]
    
            if A[j] == N:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 8180
fn main() {
    let mut x: i64 = readln();
    let a: i64 = readln();
    let b: i64 = readln();
    x -= a;
    x %= b;
    println!("{}", x);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

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

	const int INF = 0xfffffff;

	for(int n, m; cin >> n >> m, n;) {
		vector<int> c(m);
		for(int i = 0; i < m; ++i)
			cin >> c[i];

		vector<int> dp(256, INF);
		dp[128] = 0;
		for(int i = 0; i < n; ++i) {
			int x;
			cin >> x;

			vector<int> tmp(256, INF);
			for(int j = 0; j < 256; ++j) {
				for(int k = 0; k < m; ++k) {
					const int next = max(0, min(255, j + c[k]));
					const int diff = x - next;
					chmin(tmp[next], dp[j] + diff * diff);
				}
			}

			dp.swap(tmp);
		}

		cout << *min_element(dp.begin(), dp.end()) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int solve() {
	var(int, n, m);
	rrep(i, m / n, 1) {
		if (m % i == 0)
			return i;
	}
	return 1;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define W_max int(1e5)+10
#define N_max 100+10
#define ll long long int
using namespace std;

ll max(ll a, ll b){
	return (a>b) ? a : b;
}	

int main(){
	ll N, W, w[N_max], v[N_max], knapsack[2][W_max];
	ll current, last;

	//input
	cin >> N >> W;
	for(int i=0;i<N;i++){
		cin >> w[i] >> v[i];
	}
	//alg
	for(int i=0;i<W;i++){ knapsack[0][i] = 0;}
	for(int i=0;i<2	;i++){ knapsack[i][0] = 0;}

	for(int i=1;i<N+1;i++){ 
		current = i%2;
		last = (i-1)%2;
		for(int j=1;j<W+1;j++){
			//put last element in the knapsack
			knapsack[current][j] = knapsack[last][j];
			if(j>=w[i-1]){
				knapsack[current][j] = max(knapsack[last][j],knapsack[last][j-w[i-1]]+v[i-1]);
			}
		}
	}

	cout << knapsack[N%2][W] << '\n';

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define hell 1000000007
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";
const lli sz = 1e7+5;
lli sev[sz];
void seive()
{
  for(lli i=1;i<sz;i++)
  {
    if(i%2==0) sev[i]=2;
    else sev[i]=i; 
  }
  for(lli i=3;i*i<sz;i++)
  {
    if(sev[i]==i)
    {
      for(lli j=i*i;j<sz;j+=i)
      {
        if(sev[j]==j) sev[j]=i;
      }
    }
  }
}


int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);


lli n;cin>>n;
seive();
lli an = 0;
for(lli i=1;i<=n;i++)
{
  map<lli, lli>mp;
  lli m = i;
    while(m>1)
    {
      mp[sev[m]]+=1;
      m/=sev[m];
    }
    lli ans = 1;
  for(auto it = mp.begin();it!=mp.end();it++)
  {
     ans*=((*it).second+1);
  }  
  ans*=i;
  an+=ans;

}

cout<<an;




return 0;
}

Measured memory_bytes: 81764
#include<iostream>

using namespace std;
int main(void){
    int w,h,x,y;
    cin >> w;
    cin >> h;
    cin >> x;
    cin >> y;
    cout << ((double)w*(double)h)/2 << " " << (x*2==w && y*2==h) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		String S = sc.next();
		Pattern p = Pattern.compile("^A[a-z]{1,}C[a-z]{1,}$");
		Matcher m = p.matcher(S);
		if(m.find()){
			System.out.println("AC");
		}else{
			System.out.println("WA");
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23380
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	string s;
	cin >> s;
	long long int ans = 0;
	long long int wnum = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'W'){
			ans += i - wnum;
			wnum++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll solve(ll h,ll w){
	ll ans=1;
	ans+=po(2,gcd(h,w));
	mad(ans,po(2,w)-2);
	mad(ans,po(2,h)-2);
	return ans;
}
int main(){
	ll h,w,t;
	cin>>h>>w>>t;
	ll ans=po(solve(w/gcd(w,t),h/gcd(h,t)),gcd(w,t)*gcd(h,t));
	if(ans<0)ans+=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var nk = Reads();
            var n = nk[0];
            var k = nk[1];
            double ans = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i < k)
                {
                    long m = i;
                    long c = 0;
                    while (m < k)
                    {
                        m *= 2;
                        c++;
                    }
                    ans+=Math.Pow(0.5, c) / n;
                }
                else ans += 1.0 / n;
                
            }

            WriteLine(ans);












          
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 20152
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

vector<ll> sosu;
void generate_sosu(ll max){
    reps(index, 2, max+1){
        bool divided=false;
        rep(j, sosu.size()){
            if(sosu[j]*sosu[j]>index) break;
            if(index%sosu[j]==0){
                divided=true;
                break;
            }
        }
        if(divided==false) sosu.push_back(index);
    }
}

ll N, ans=1;
int visited[10000002];
void dfs(ll atai, ll fukasa, ll yusen, ll kosu){
    reps(i, yusen, sosu.size()){
        if(atai*sosu[i]>N) break;
        if(i==yusen){
            ans+=atai*sosu[i]*fukasa*(kosu+1)/kosu;
            visited[atai*sosu[i]]=1;
            dfs(atai*sosu[i], fukasa*(kosu+1)/kosu, yusen, kosu+1);
        }
        else{
            ans+=atai*sosu[i]*fukasa*2;
            visited[atai*sosu[i]]=1;
            dfs(atai*sosu[i], fukasa*2, i, 2);
        }
    }
}

int main(void){
    MEMSET(visited, 0);
    generate_sosu(1000000);
    //cout<<"#"<<endl;
    cin>>N;
    visited[1]=1;
    dfs(1, 1, 0, 1);
    rep1(i, N){
        if(visited[i]==1) continue;
        //cout<<i<<sp;
        ll th=i;
        ll de[4];
        MEMSET(de, 0);
        de[0]=1;
        while(th%2==0) de[0]++, th/=2;
        de[1]=1;
        while(th%3==0) de[1]++, th/=3;
        de[2]=1;
        while(th%5==0) de[2]++, th/=5;
        de[3]=1;
        while(th%7==0) de[3]++, th/=7;
        ans+=i*2*de[0]*de[1]*de[2]*de[3];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 43176
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct node
{
string name;
int x;
int score;
}p[102];
bool cmp(node a,node b)
{
if(a.name==b.name)
{
return a.score>b.score;
}
else
{
return a.name<b.name;
}
}
int main(int argc, char** argv) 
{   
    int n;
	while(cin>>n)
	{ 
	for(int i=0;i<n;i++)
	 {
	 cin>>p[i].name;
	 scanf("%d",&p[i].score);
	 p[i].x=i+1;
	}
	sort(p,p+n,cmp);
	for(int i=0;i<n;i++)
	printf("%d\n",p[i].x);
	 } 
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

b = input()
ans = {'A': 'T',
       'T': 'A',
       'C': 'G',
       'G': 'C'}
print(ans[b])


Measured memory_bytes: 3436
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {
	int h, w, k;
	cin >> h >> w >> k;

	char c[6][6];

	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> c[i][j];
		}
	}
	int ans = 0;
	for (int is = 0;is < 1 << h;is++) {
		for (int js = 0;js < 1 << w;js++) {
			int cnt = 0;
			for (int i = 0;i < h;i++) {
				for (int j = 0;j < w;j++) {
					if (is >> i & 1)continue;
					if (js >> j & 1)continue;
					if (c[i][j] == '#')cnt++;
				}
			}
			if (cnt == k) {
				ans++;
			}
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3648
import math
a,b,h,m = map(int, input().split())

a_theta = math.radians(30*h) + math.radians(m/60*30)
b_theta = math.radians(6*m)

a_x = a*math.cos(a_theta)
a_y = a*math.sin(a_theta)
b_x = b*math.cos(b_theta)
b_y = b*math.sin(b_theta)

d = math.sqrt((a_x - b_x)**2 + (a_y -b_y)**2)
print(d)

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

using namespace std;

typedef long long LL;

const int N = 110;

LL r, d, x;

int main()
{
    cin >> r >> d >> x;
    for(int i = 1; i <= 10; i++)
    {
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define debug(x) cerr << #x " = " << (x) << '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

bool isprime(long long int n)
{
    if(n ==1 )
        return false;
    if(n == 2)
        return true;
    for(long long int i =2;i<=n/i;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int t;
    t = 1;
    while(t--)
    {
        lli n,a,b;
        cin>>n>>a>>b;
        if(a>b || ( a!= b && n<2))
            cout<<0;
        else if( a== b)
            cout<<1;
        else 
        {
            cout<<(n-1)*b+a - (b+(n-1)*a) +1;
        }

    }    


    
    return 0;    
}
 

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#define PI 3.141592653589793238
using namespace std;
int main()
{
  double a,b;
  int c;
  cin>>a>>b>>c;
  double s;
  s=a*b*sin(c*PI/180)/2;
  cout<<fixed<<s<<endl;
  cout<<a+b+sqrt(a*a+b*b-2*a*b*cos(c*PI/180))<<endl;
  cout<<2*s/a<<endl;
}

Measured memory_bytes: 3472