akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

ll a,b,n;

void solve(){
    cin >> a >> b >> n;
    cout << a*min(b-1,n)/b << endl;
}

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

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;

namespace Cookies
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();

            long takahashiCookies = long.Parse(input[0]);
            long aokiCookies = long.Parse(input[1]);
            long requiredActions = long.Parse(input[2]);

            takahashiCookies = takahashiCookies - requiredActions;
            if(takahashiCookies < 0)
            {
                aokiCookies = aokiCookies + takahashiCookies;
                takahashiCookies = 0;
            }
            
            if(aokiCookies < 0)
            {
                aokiCookies = 0;
            }            
            Console.WriteLine(takahashiCookies + " " + aokiCookies);
        }
    }
}

Measured memory_bytes: 13140
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);

int main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n,m,i,x,k,fl=0;
	cin>>n>>m;
	if(n%2==0){
		fl=1;
		n--;
	}
	if(n%4==1){
		x=1;
		k=n/4;
		fd(i,k,1){
			if(m==0){
				break;
			}
			m--;
			cout<<i<<" "<<i+x<<endl;
			x+=2;
		}
		x=2;
		fd(i,3*k,2*k+1){
			if(m==0){
				break;
			}
			m--;
			cout<<i<<" "<<i+x<<endl;
			x+=2;
		}
	}
	else{
		x=1;
		k=n/4;
		fd(i,k,1){
			if(m==0){
				break;
			}
			m--;
			cout<<i<<" "<<i+x<<endl;
			x+=2;
		}
		if(m!=0){
			m--;
			cout<<2*k+1<<" "<<4*k+3+fl<<endl;
		}

		x=2;
		fd(i,2*k+1+k,2*k+2){
			if(m==0){
				break;
			}
			m--;
			cout<<i<<" "<<i+x<<endl;
			x+=2;
		}
		
	}
	return 0;
} 


Measured memory_bytes: 3612
import math
def prime(n):
    if (n==2):
        return True
    if(n<2 or n%2==0):
        return False
    i=3
    while(i<=math.sqrt(n)):
        if (n%i==0):
            return False
        i=i+2
    return True

N=int(input())
count=0
for i in range(N):
    n=int(input())
    if(prime(n)):
        count+=1
print(count)

Measured memory_bytes: 7800
""" AtCoder """

S = input()

ans = 0
ans_max = 0
l = ['A', 'C', 'G', 'T']
check = 1

for i in S:
    if i in l:
        ans += 1
    else:
        ans_max = max(ans_max, ans)
        ans = 0
        check = 0

ans_max = max(ans_max, ans)

if check == 1:
    ans_max = len(S)

print(ans_max)


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, x; cin >> N >> x;
    vl A(N); REP(i, N) cin >> A[i];
    ll ans = 0;
    REP(i, N-1){
        if(A[i]+A[i+1] > x){
            ll rem = (A[i]+A[i+1])-x;
            ans += rem;
            A[i+1] = max(A[i+1]-rem, 0ll);
        }
    }
    cout<< ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main() {
  int x,y,z;
  int temp;
  
  scanf("%d %d %d", &x, &y, &z);
  
  temp = x;
  x = y;
  y = temp;
  
  temp = x;
  x = z;
  z = temp;
  
  printf("%d %d %d",x, y, z);
  
  return 0;
}
  

Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
    // int N;
    // cin >> N;
    // vector<int> d(N);
    // cin >> d;
    // int ret = 0;
    // for(int i = 0;i < N-1;++i){
    //     for(int j = i + 1;j < N; ++j){
    //         ret += d[i]*d[j];
    //     }
    // }
    // cout << ret << endl;
    //O(N) can be achieved, if suffix sum is stored for every point of the array; 
    //further, using the associative property of multiplication to simplify the problem;

    //using MATHS property (a + b + c ... )^2 = a^2 + b^2 +c^2 ...  + 2.a.b + 2.a.c. + 2.b.c ...

    int N;
    cin>>N;
    int r = 0,r2 = 0;
    while(N--){
        int a;
        cin >> a;
        r += a,r2 += a*a;
    }
    cout << (r*r - r2)/2 << endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    aa = np.zeros(n*(n+1)//2,dtype=int)
    ni = 0
    for i in range(n):
        sa = 0
        for j in range(i,n):
            sa += a[j]
            aa[ni] = sa
            ni += 1

    ans = 0
    for i in range(40):
        if np.count_nonzero((ans+2**(39-i))&aa==(ans+2**(39-i))) >= k:
            ans += 2**(39-i)

    print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 20780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <functional>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	int strong = -1;
	for (int i = 0; i < N; ++i)
	{
		string s;
		cin >> s;
		if (count(s.begin(), s.end(), 'x') == 0)
		{
			strong = i + 1;
		}
	}
	srand((unsigned)time(NULL));
	for (int i = 0; i < 1000; ++i)
	{
		cout << (~strong ? strong : rand() % N + 1) << endl;
		fflush(stdout);
		int hoge;
		cin >> hoge;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 3380
// AOJ 0184: Tsuruga Castle
// 2017.8.2 bal4u@uu
// 2017.11.12

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char buf[10];
int cnt[10];
int tr['9'+1]['9'+1]['9'+1];

int main()
{
	int n;
	int n1, n2, n3;
	
	// age >= 100
	n1 = '1'; for (n2 = '0'; n2 <= '9'; n2++) for (n3 = '0'; n3 <= '9'; n3++)
		tr[n1][n2][n3] = 6;

	// age < 10
	n3 = 0; for (n1 = '0'; n1 <= '9'; n1++) for (n2 = 0; n2 < ' '; n2++) tr[n1][n2][n3] = 0;

	// 10 <= age < 100
	for (n1 = 1; n1 <= 9; n1++) for (n2 = '0'; n2 <= '9'; n2++) {
		for (n3 = 0; n3 < ' '; n3++) tr[n1+'0'][n2][n3] = (n1 <= 6) ? n1 : 6; 
	}
	
	// let's go
	while (fgets(buf, 10, stdin) && *buf != '0') {
		memset(cnt, 0, sizeof(cnt));

		n = atoi(buf);
		while (n--) {
			buf[2] = 0, fgets(buf, 10, stdin);
			cnt[tr[*buf][*(buf+1)][*(buf+2)]]++;
		}

		for (n = 0; n < 7; n++) printf("%d\n", cnt[n]);
	}
	return 0;
}

Measured memory_bytes: 1932
#include<bits/stdc++.h>
#define lli long long
#define rep0(i,j) for(int i=0; i<j; i++)
#define rep1(i,j) for(int i=1; i<=j; i++)
#define all(a) a.begin(), a.end()
using namespace std;

void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}

lli gcd(lli a, lli b){
    if(a < b)return gcd(b, a);
    lli temp;
    while((temp = a%b)){
        a=b;
        b=temp;
    }
    return b;
}

int main(){
    int n;
    cin >> n;
    vector<lli> vec(n);
    int num=1;
    rep0(i,n){
        cin >> vec[i];
        if(num==vec[i])num++;
    }
    if(num == 1) cout << -1;
    else cout << n - num + 1;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char a[100001];
	cin>>a;
	for(int i=0;i<strlen(a);i++){
		if(i%2==0){
			cout<<a[i];
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int a = sc.nextInt();
			System.out.println(CountPrime(a));
		}
	}
	static int CountPrime(int a){
		int n = 0;
		if(a<=1){
			return n;
		} else {
			int[] nums = new int[a+1];
			for(int i=2; i<=a ; i++){
				if(nums[i]==0){
					n++;
					for(int j=2; j*i <= a; j++){
						nums[j*i]=1;
					}
				}
			}
		}
		return n;
	}
}

Measured memory_bytes: 53036
#include<iostream>
using namespace std;
int main(){
  int h[2],m[2],s[2];
  for(int i=0; i<3; i++){
    int time[3];
    cin >> h[0] >> m[0] >> s[0] >> h[1] >> m[1] >> s[1];
    int over=0;
    if(s[1]-s[0] < 0) time[0] = 60+s[1]-s[0], over=-1;
    else time[0] = s[1]-s[0];

    if(m[1]-m[0]+over < 0) time[1] = 60+m[1]-m[0]+over, over=-1;
    else time[1] = m[1]-m[0]+over, over=0;
    
    time[2] = h[1]-h[0]+over;

    cout << time[2] << " " << time[1] << " " << time[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int A = nextInt();
    int B = nextInt();
    int C = nextInt();
    int D = nextInt();

    int cnt = 0;

    while(A>0 && C>0){

      if(cnt%2==0){
        C -= B;
      }
      else{
        A -= D;
      }

      cnt++;
    }

    if(C<=0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }


  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35636
def main():
    rival = list(input())
    possiblePaCount = 0
    intOut = 0
    result = ""

    for i in range(len(rival)):
        if rival[i] == "g":
            if possiblePaCount > 0:
                intOut += 1
                possiblePaCount -= 1
                result += "p"
            else:
                possiblePaCount = 1
                result += "g"

        if rival[i] == "p":
            if possiblePaCount > 0:
                possiblePaCount -= 1
                result += "p"
            else:
                result += "g"
                possiblePaCount = 1
                intOut -= 1

    print(intOut)
    #print(result)
if __name__ == '__main__':
  main()


Measured memory_bytes: 4084
x1, y1, x2, y2 = map(int,input().split())
x3, y3, x4, y4 = 0, 0, 0, 0

dx = x2 - x1
dy = y2 - y1

print(x2-dy,y2+dx,x2-dy-dx,y2+dx-dy)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
  int N;
  int *p;
  int tmp, swap;
  int i;
  
  scanf("%d",  &N);
  p = new int[N+1];
  for (int i = 1; i < N+1; i++) {
    scanf("%d", &p[i]);
  }
  
  tmp = 0;
  i = 1;
  while (i < N+1) {
    //printf("%d, %d\n", i, p[i]);
    if (p[i] == i) {
      tmp++;
      i += 2;
    } else {
      i++;
    }
  }
  printf("%d\n", tmp);
  
  return 0;
}
      

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

void bubbleSort(int num[], int N);
void swap(int& x, int& y);
void showArray(int num[], int N);

int main()
{
	int n;
	cin >> n;
	int *num = new int[n];
	for(int i = 0; i < n; i++)
		cin >> num[i];
	bubbleSort(num, n);
	return 0;
}

void bubbleSort(int num[], int N)
{
	int irekae = 0;
	for(int i = 1; i < N; i++)
		for(int j = 0; j < N-i; j++)
			if(num[j] > num[j+1])
			{
				swap(num[j], num[j+1]);
				irekae++;
			}
	showArray(num, N);
	cout << irekae << endl;
}

void swap(int& x, int& y)
{
	int temp = x;
	x = y;
	y = temp;
}

void showArray(int num[], int N)
{
	cout << num[0];
	for(int i = 1; i < N; i++)
		cout << ' ' << num[i];
	cout << endl;
}

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

using namespace std;

string S;
const char c[5] = {'K', 'I', 'H', 'B', 'R'};


int main(void)
{
	cin >> S;
	int cnt = 0;
	
	int state = 0;
	for(int i = 0; i < S.size(); i++){
		switch(state){
		case 0:
			if(S[i] == 'A') state = 1;
			else if(S[i] == 'K') state = 2;
			else goto no;
			break;
		case 1:
			if(S[i] == 'K') state = 2;
			else goto no;
			break;
		case 2:
			if(S[i] == 'I') state = 3;
			else goto no;
			break;
		case 3:
			if(S[i] == 'H') state = 4;
			else goto no;
			break;
		case 4:
			if(S[i] == 'A') state = 5;
			else if(S[i] == 'B') state = 6;
			else goto no;
			break;
		case 5:
			if(S[i] == 'B') state = 6;
			else goto no;
			break;
		case 6:
			if(S[i] == 'A') state = 7;
			else if(S[i] == 'R') state = 8;
			else goto no;
			break;
		case 7:
			if(S[i] == 'R') state = 8;
			else goto no;
			break;
		case 8:
			if(S[i] == 'A') state = 9;
			else goto no;
			break;
		case 9:
			goto no;
			break;
		}
	}
	
	if(state != 8 & state != 9) goto no;
	cout << "YES" << endl;
	return 0;
	no:;
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    d = 0
    for j in range(m):
        d += a[i][j]*b[j]
    d += c
    if d > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int MOD = 1E9 + 7;
int power(int a, int n)
{
    int ret = 1;
    int now = a;
    while(n)
    {
        if (n&1)ret = (ret * now)%MOD;
        now = (now * now)%MOD;
        n >>= 1;
    }
    return ret%MOD;
}
int inv(int a)
{
    return power(a, MOD - 2);
}

int comp[1'111'111];
int memo[1'111'111];
vector<int> prm;
bitset<1'111'111> ina;
void solve()
{
    int n; cin>>n;
    vector<int> a(n);
    forn(i, n) cin>>a[i];
    forn(i, n) ina[a[i]] = 1;
    prm.reserve(333'333);
    for(int i = 2; i < 1'111'111;++i)
    {
        if (comp[i]) continue;
        prm.pb(i);
        for (int k = i, c = 1; k < 1'111'111; k *= i, ++c)
        {
            for (int j = k; j < 1'111'111; j += k)
            {
                comp[j] = 1;
                if (ina[j])
                {
                    memo[sz(prm) - 1] = max(memo[sz(prm) - 1], c);
                }
            }
        }
    }
    int lcm = 1;
    forn(i, sz(prm))
    {
        forn(_, memo[i])
        {
            lcm = (lcm * prm[i])%MOD;
        }
    }
    //debug(lcm);
    int ans = 0;
    forn(i, n)
    {
        int ad = lcm * inv(a[i])%MOD;
        ans = (ans + ad)%MOD;
    }
    cout << ans << '\n';
}


signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 13376
package main

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

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var S string
	var sum, t int
	fmt.Scan(&S)
	for i := 0; i < len(S); i++ {
		if S[i] == 'B' {
			t++
		}
		if S[i] == 'W' {
			sum += t
		}
	}

	fmt.Fprintln(wtr, sum)
	_ = wtr.Flush()
}


Measured memory_bytes: 3280
import java.util.Scanner;

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

		for(int i=0; i<=50000; i++) {
			prime[i]=false;
		}

		prime[2]=true;
		prime[3]=true;
		for(int i=5; i<=50000; i++) {
			for(int j=2; j*j<=i; j++) {
				if(i%j==0) {
					break;
				}
				if(i%j!=0 && (j+1)*(j+1)>i) {
					prime[i]=true;
				}
			}
		}
		int kotae=0;
		while(true) {
			kotae=sc.nextInt();

			if(kotae==0) {
				System.exit(0);
			}

			if(kotae%2==1) {
				if(prime[kotae-2]) {
					System.out.println(1);
				}
				else {
					System.out.println(0);
				}
			}
			else {
				int dec=0;
				int kosu=0;
				if(prime[kotae/2]) {
					dec=1;
				}
				for(int i=1; i<kotae; i+=2) {
					if(prime[kotae-i] && prime[i]) {
						kosu++;
					}
				}
				System.out.println(kosu/2+dec);
			}
		}
	}
/*
	public static boolean isPrime(int a) {
		if(a<4) {
			if(a==2 || a==3) {
				return true;
			}
			else {
				return false;
			}
		}
		else {
			for(int j=2; j*j<=a; j++) {
				if(a%j==0) {
					return false;
				}
				if(a%j!=0 && (j+1)*(j+1)>a) {
					return true;
				}
		}
		return true;
		}
	}*/
}


Measured memory_bytes: 41164
package main

import "fmt"

func main() {
	var v float64
	for {
		i, _ := fmt.Scan(&v)
		if i == 0 {
			break
		}
		t := v / 9.8
		y := 4.9 * t * t

		N := 0
		for {
			N++
			if height := 5*N - 5; float64(height) > y {
				fmt.Println(N)
				break
			}
		}
	}
}



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

long long xorFromZero(long long n)
{
    if (n == 0)
    {
        return 0;
    }
    if (n % 2 == 1)
    {
        if (((n + 1) / 2) % 2 == 0)
        {
            return 0;
        }
        else
        {
            return 1;
        }
    }
    else
    {
        if (((n / 2) % 2) == 0)
        {
            return n;
        }
        else
        {
            return n + 1;
        }
    }
}

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

    if (a == 0)
    {
        a = xorFromZero(a);
    }
    else
    {
        a = xorFromZero(a - 1);
    }

    b = xorFromZero(b);
    auto c = a ^ b;

    cout << c << endl;
}

Measured memory_bytes: 256
n,l = map(int,input().split())

Ringo = [0]*n

for i in range(1,n+1):
    Ringo[i-1] = l+i-1

aji = sum(Ringo)
minv = 100000000000
ans = 0
for i in range(n):
    temp_aji = 0
    if i == 0:
        for j in range(1,n):
            temp_aji += Ringo[j]
    elif i == n-1:
        for j in range(n-1):
            temp_aji += Ringo[j]
    else:
        for j in range(0,i):
            temp_aji += Ringo[j]
        for j in range(i+1,n):
            temp_aji += Ringo[j]
    if abs(aji -temp_aji)  < minv:
        minv = abs(aji - temp_aji)
        ans = temp_aji
    

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int mincost(int ar[],int n){
	int dp[n+1]={0};
	if(n==0){
		return 0;
	}
	if(n==1){
		dp[1]=0;
	}

	for(int i=2;i<=n;i++){
			int op1=INT_MAX,op2=INT_MAX;
	
		op1 = dp[i-1]+abs(ar[i]-ar[i-1] );

		op2 =i==2?INT_MAX:dp[i-2]+abs(ar[i]-ar[i-2]);
	

	dp[i]=min(op1,op2);
	
	}
return dp[n];
}
int main(){
	int n;
	cin>>n;
	int ar[n];
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	cout<<mincost(ar,n)<<endl;
	return 0;
}

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

int count(int n, int x){
	int f = 0;
	for(int i = 1; i <= n-2; i++){
		for(int j = i+1; j <= n-1; j++){
			for(int k = j+1; k <= n; k++){
				if(i + j + k == x)f++;
			}
		}
	}
	return f;
}

int main() {
	int n, x;
	while(1){
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		cout << count(n, x) << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			String str;
			try
			{
				str = sc.nextLine();
			}
			catch (Exception e)
			{
				break;
			}
			int result = 0;
			for (int i = 0; i < str.length(); i++)
			{
				int n = charToNum(str.charAt(i));
				int next;
				try
				{
					next = charToNum(str.charAt(i + 1));
				}
				catch (StringIndexOutOfBoundsException e)
				{
					next = 0;
				}
				if (next <= n)
				{
					result += n;
				}
				else
				{
					result += next - n;
					i++;
				}
			}
			System.out.println(result);
		}
	}
	private static int charToNum(char c)
	{
		switch (c)
		{
		case 'I':
			return 1;
		case 'V':
			return 5;
		case 'X':
			return 10;
		case 'L':
			return 50;
		case 'C':
			return 100;
		case 'D':
			return 500;
		case 'M':
			return 1000;
		}
		return 0;
	}
}

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

#define REP(i,a,b) for(int i = (a) ; i < (int)(b) ; ++i )
#define _REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )
#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)
//iterator: for(int u:x),x is container
#define x(p) (p).first
#define y(p) (p).second
#define mp(x,y) make_pair((x), (y))
#define ll long long
#define inf 0x3f3f3f3f
const long double eps = 1e-15;
#define mem(x,v) memset((x), (v), sizeof (x))
#define _ri1(x) scanf("%d", &(x))
#define _ri2(x,y) scanf("%d%d", &(x), &(y))
#define _ri3(x,y,z) scanf("%d%d%d", &(x), &(y), &(z))
#define _ri4(a,b,c,d) scanf("%d%d%d%d", &(a), &(b), &(c), &(d))
#define _pi1(a) printf("%d\n", (a))
#define _pi2(a,b) printf("%d%d\n", (a), (b))

#ifdef kinesis
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int a,b,c;

bool cmp(int a,int b,int c)
{
    return (c - a - b <= 0 ) ? 0 : 4LL * a * b < 1LL * (c - a - b) * (c - a - b);
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //#endif // ONLINE_JUDGE
    while(_ri3(a,b,c)==3){
        if(cmp(a,b,c)) puts("Yes");
        else puts("No");
    }

    return 0;
}


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


void solve(long long N, std::vector<long long> l, std::vector<long long> r){
    int ans = 0;
  for(int i = 0; i < N; i++)
    {
        ans += r.at(i) - l.at(i) + 1;
    }
    
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define ld long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
#define MOD 1000000007
#define INF 1000000000000000007LL


const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    ld a, b; cin>>a>>b;
    ld x = a*b;
    int ans = floor(x);
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        int n = in.nextInt();
        int[] a = in.nextIntArray(n);
        int p = 1;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > p) {
                ans += (a[i] - 1) / p;
                a[i] = 1;
            }
            if (a[i] == p) {
                p++;
            }
        }
        out.println(ans);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

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

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

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 35852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;



int main()
{
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	for(int i =0;i<m;i++)
	{
		cin >> a[i];
	}
	vector<int> dp(n+1);
	dp[0] = 1;
	for(int i=0;i<m;i++)
	{
		dp[a[i]]=-1;
	}
	if(!a.empty())if(a[0]!=1)dp[1]=1;
	if(a.empty()) dp[1] = 1;
	for(int i =2;i<=n;i++)
	{
		if(dp[i]==-1)continue;
		if(dp[i-1]>=0)dp[i] += dp[i-1];
		dp[i]%= MOD;
		if(dp[i-2]>=0)dp[i] += dp[i-2];
		dp[i]%= MOD;
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

  cout << 0 << endl;
  string s;
  cin >> s;

  if (s == "Vacant") {
    return 0;
  }

  int64_t f = (s == "Female" ? 0 : 1);
  int64_t b = 1, e = n;
  while (b < e) {
    auto mid = (b + e) / 2;
    cout << mid << endl;
    cin >> s;

    if (s == "Vacant") {
      return 0;
    }

    int64_t tmp = (s == "Female" ? 0 : 1);

    if ((f + mid) % 2 == tmp) {
      b = mid + 1;
    } else {
      e = mid;
    }
  }

  cout << b << endl;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;
#define MAXN 10010
vector<ii> vs;
const int INF = 1e9;
int dist[MAXN];

int djk(int s, int n){
	for(int i=0; i<=n; ++i) dist[i] = INF;	
	dist[s] = 0; 
       	set<ii> pq;
	pq.insert(ii(0, s));
	while(not pq.empty()){
		int u = pq.begin()->ss;
		pq.erase(pq.begin());
		for(auto x:vs){
			auto a = x.ff, wt = x.ss;
			int w = max(0, u-a);
			if(dist[w]>dist[u]+wt){
				pq.erase(ii(dist[w], w));
				dist[w] = dist[u]+wt;
				pq.insert(ii(dist[w], w));
			}
		}
	}	
	return dist[0];
}
int32_t main(){
	int h, n;
	scanf("%d %d", &h, &n);
	for(int i=0; i<n; ++i){
		int a, wt;
		scanf("%d %d", &a, &wt);
		vs.push_back(ii(a, wt));
	}
	int ans = djk(h, h);
	cout << ans << endl;
}


Measured memory_bytes: 512
N = int(input())
vacation = []
for i in range(N):
    vacation.append(list(map(int, input().split())))

activities = 3
schedules = [[None for _ in range(activities)] for _ in range(N)]
schedules[0] = vacation[0]

for i in range(1, N):
    for j in range(activities):
        schedules[i][j] = max(schedules[i - 1][(j + 1) % 3], schedules[i - 1][(j + 2) % 3]) + vacation[i][j]

print(max(schedules[N - 1]))

Measured memory_bytes: 78040
#include <iostream>

int main() {
  // 入力
  int a, b;
  std::string op;
  std::cin >> a >> op >> b;

  // 式の値
  int ans;
  if (op == "+") {
    ans = a + b;
  } else {
    ans = a - b;
  }

  // 出力
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll n, c;
	cin >> n >> c;
	ll s, t, x;

	// cnt[i][j] : 時刻 i でチャンネル j が放送されているかどうか
	vvll cnt(100002, vll(c, 0));
	REP(i, n){
		cin >> s >> t >> x;
		x--;
		cnt[s - 1][x]++;
		cnt[t][x]--;
	}
	REP(i, 100001){
		REP(j, c){
			cnt[i + 1][j] += cnt[i][j];
		}
	}

	ll res = 0, tmp;
	REP(i, 100002){
		tmp = 0;
		REP(j, c){
			if(cnt[i][j]) tmp++;
		}
		res = max(res, tmp);
 	}
	cout << res << endl;
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back



bool isLeep(int n){
    return ( (n%4==0 && n%100!=0) || n%400==0 );
}


ll ymdToNum(int y,int m,int d){
    
    int month[]={0,0,31,59,90,120,151,181,212,243,273,304,334};
    
    ll ret=0;
    ret+=(ll)365*(y-1);
    ret+=(ll)((y-1)/4) - (ll)((y-1)/100) + (ll)((y-1)/400);
    
    ret+=month[m];
    if( isLeep(y) && m>=3 )ret++;
    
    ret+=d-1;
    
    return ret;
}

ll bkatwkiToNum(int b,int ka,int t,int w,int ki){
    ll ret=0;
    ret+=b;
    ret*=20;
    
    ret+=ka;
    ret*=20;
    
    ret+=t;
    ret*=18;
    
    ret+=w;
    ret*=20;
    
    ret+=ki;
    
    return ret;
}


int main(){
    string s;
    while(cin>>s){
        if( s=="#" )break;
        
        string buf="";
        vector<string> tmp;
        rep(i,s.size()){
            if( s[i]!='.' )buf+=s[i];
            else{
                tmp.pb(buf);
                buf="";
            }
        }
        tmp.pb(buf);


        //b.ka.t.w.ki
        if( tmp.size()==5 ){ //maya
            int b  = stoi(tmp[0]);
            int ka = stoi(tmp[1]);
            int t  = stoi(tmp[2]);
            int w  = stoi(tmp[3]);
            int ki = stoi(tmp[4]);
            
            ll num = bkatwkiToNum(b,ka,t,w,ki);
            
            num += ymdToNum(2012,12,21);
            
            int y,m,d;
            int t1=0;
            for(int i=1;;i++){
                t1+=365;
                if( isLeep(i) )t1++;
                
                if(t1>num){
                    y=i;
                    break;
                }
            }
            
            num -= 365*(y-1)+((y-1)/4 - (y-1)/100 + (y-1)/400);
            
            int month[]={0,31,59,90,120,151,181,212,243,273,304,334,365};
            for(int i=1;i<13;i++){
                int ep=0;
                if( isLeep(y)&&i>=2 )ep++;
                
                if( month[i]+ep>num ){
                    m=i;
                    break;
                }
            }
            num -= month[m-1];
            if( isLeep(y)&&m>=3 )num--;
            
            d=num+1;
            
            cout<<y<<"."<<m<<"."<<d<<endl;
            
            
        }else if( tmp.size()==3 ){   //sei
            int y = stoi(tmp[0]);
            int m = stoi(tmp[1]);
            int d = stoi(tmp[2]);
            
            ll num = ymdToNum(y,m,d) - ymdToNum(2012,12,21);
            num%=1872000;
            int b,ka,t,w,ki;
            
            b = num/144000;
            num-=b*144000;
            
            ka = num/7200;
            num-=ka*7200;
            
            t = num/360;
            num-=t*360;
            
            w = num/20;
            num-=w*20;
            
            ki=num;
            
            
            cout<<b<<"."<<ka<<"."<<t<<"."<<w<<"."<<ki<<endl;
        }else return 0;
    }
}

Measured memory_bytes: 1208
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
 
#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)
 
//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}
 
//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}
 
 
//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}
 
 
//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}
 
 
int main() {
	int n;
	cin >> n;
	vi a(n);
	repz(i, n)cin >> a[i];
 
	sort(a.begin(), a.end());
	cout << abs(a[n - 1] - a[0]) << endl;
 
 
	system("pause");
	return 0;
}
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>

Measured memory_bytes: 504
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}

const int maax = 3050;
ll dp[maax][maax];
ll tab[maax];
int n;

ll solve(int i, int j)
{
	if (j - i == 0)
		return tab[i];
	if (j - i == 1)
		return (abs(tab[i]-tab[j]));
	if (dp[i][j] != -1)
		return dp[i][j];
	ll tmp = 0;
	tmp = tab[i] - solve(i+1,j);
	tmp = max(tmp, tab[j]-solve(i,j-1));
	return (dp[i][j] = tmp);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	memset(dp,-1,sizeof(dp));
	REP(i,0,n)
		cin >> tab[i];
	ll res = solve(0,n-1);
	cout << res;
}


Measured memory_bytes: 73216
// ワーシャルフロイド
package main

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func fill(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}

func warshallFloyd(n int, d [][]int) {
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j])
			}
		}
	}
}

func main() {
	H := readInt()
	W := readInt()

	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	n := H * W
	d := make([][]int, n)
	for i := 0; i < n; i++ {
		d[i] = make([]int, n)
		fill(d[i], math.MaxInt32)
		d[i][i] = 0
	}

	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if S[y][x] == '#' {
				continue
			}
			if y-1 >= 0 && S[y-1][x] != '#' {
				d[y*W+x][(y-1)*W+x] = 1
			}
			if y+1 < H && S[y+1][x] != '#' {
				d[y*W+x][(y+1)*W+x] = 1
			}
			if x-1 >= 0 && S[y][x-1] != '#' {
				d[y*W+x][y*W+x-1] = 1
			}
			if x+1 < W && S[y][x+1] != '#' {
				d[y*W+x][y*W+x+1] = 1
			}
		}
	}

	warshallFloyd(n, d)

	result := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if d[i][j] < math.MaxInt32 && d[i][j] > result {
				result = d[i][j]
			}
		}
	}

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;

int main(){
  int n;
  ll ans=0;
  cin>>n;
  vector<vector<int>> vec(9,vector<int>(9));
  for(int i=1;i<=n;i++){
    string s=to_string(i);
    int a=s[0]-'0';
    int b=i%10;
    if(a==0||b==0)continue;
    a--;b--;
    vec[a][b]++;
  }
  rep(i,9){
    rep(j,9){
      ans+=vec[i][j]*vec[j][i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  double w, h, x, y;
  cin>>w>>h>>x>>y;
  double ans = (double)(w*h)/(double)2;
  if(x==w/2. and y==h/2.)
    std::cout << setprecision(15) << ans <<" "<<'1'<< std::endl;
  else
    std::cout << setprecision(15) << ans << " " << '0' << std::endl;
  return 0;
}



Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = list(input())
ans = 0
for i in range(n):
    c1 = Counter(s[:i])
    c2 = Counter(s[i:])
    count = 0
    for k in c1.keys():
        if k in c2.keys():
            count += 1
    ans = max(ans, count)
print(ans)


Measured memory_bytes: 3316
#include <stdio.h>

int main(){
  int i,j,l,m,n;
  long a;

  while(scanf("%d",&n)!=EOF){
    a=0;
    if(n>2000) n=4000-n;
    if(n>1000) m=1000; else m=n;
    for(i=0;i<=m;i++){
      for(j=0;j<=m;j++){
        l=n-i-j;
        if(l<0) break; else if(l<=2000) a+=1+(l<1000?l:(2000-l));
      }
    }
    printf("%ld\n",a);
  }
  return 0;
}

Measured memory_bytes: 596