akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CLower {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> H(N);
        REP(i, N) cin >> H[i];
        reverse(H.begin(), H.end());

        int res = 0;
        int cur = 0;
        FOR(i, 1, N - 1) {
            if (H[i] >= H[i - 1]) {
                cur++;
            } else {
                cur = 0;
            }
            res = max(res, cur);
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CLower solver;
    solver.solve(in, out);
    return 0;
}


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

int main(){
  int a, b, ans;
  cin >> a >> b;
  ans=max(a+b, a-b);
  ans=max(ans, a*b);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int MAX_DATA = 1000;
		int data_count = 0;
		String input = "";
		int output[] = new int[MAX_DATA];
		boolean judge = true;

		out: for (int i = 0; i < MAX_DATA; i++) {
			input = sc.nextLine();
			if (input.equals("0")) {
				break out;
			}
			if (input.length() > 1000 || input.length() == 0) {
				judge = false;
			}
			for (int j = 0; j < input.length(); j++) {
				output[i] += Integer.parseInt("" + input.charAt(j));

			}
			data_count++;
		}

		if (judge == true) {
			for (int k = 0; k < data_count; k++) {
				System.out.println(output[k]);

			}
		}
	}

}



Measured memory_bytes: 26864
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,sum,i,a;
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++)	{
		scanf("%d",&a);
		sum+=a-1;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


l = list(map(int, sys.stdin.readline().split()))
K =  int(sys.stdin.readline())

l.sort()
print(l[0] + l[1] + l[2] * (2 ** K))

Measured memory_bytes: 66668
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Arrays;

public final class Main {

  private Main() {}

  public static int readCount(Reader reader) throws Exception {
    char[] buffer = new char[3];
    int bIndex = 0;

    for (;;) {
      int read = reader.read();
      if (read == '\r' || read == ' ') continue;
      if (read == '\n') return Integer.parseInt(String.valueOf(buffer, 0, bIndex));
      buffer[bIndex++] = (char) read;
    }
  }

  private static int[] parse(int count, Reader reader) throws Exception {
    char[] buffer = new char[10];
    int bIndex = 0;

    int[] result = new int[count];
    int rIndex = 0;

    for (;;) {
      int read = reader.read();
      if (read == '\r') continue;
      if (read == -1)
        return Arrays.copyOf(result, rIndex);

      char c = (char) read;
      if (c == '\n' || c == ' ') {
        if (bIndex != 0) {
          result[rIndex++] = Integer.parseInt(String.valueOf(buffer, 0, bIndex));
          bIndex = 0;
        }
        if (c == '\n') { return Arrays.copyOf(result, rIndex); }
        continue;
      }
      buffer[bIndex++] = c;
    }
  }

  public static void main(String[] args) throws Exception {
    final Reader reader = new InputStreamReader(System.in);

    final int length = readCount(reader);
    final int[] inputs = parse(length, reader);

    int max = 0;
    for (int tail = 0; tail < length; ++tail) {
      for (int head = tail; head < length; ++head) {
        int r = inputs[tail] - inputs[head];
        r = ((r < 0) ? -r : r);
        if (r > max) max = r;
      }
    }

    System.out.println(max);
  }

}


Measured memory_bytes: 21204
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const ll mod = 1e9 + 7;
 
void solve() {
	int n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		sum %= mod;
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		sum -= a[i];
		sum += mod;
		sum %= mod;
		ans += (a[i] * sum) % mod;
		ans %= mod;
	}
	cout << ans;
}
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

Measured memory_bytes: 4764
N,M = map(int,input().split())
A = list(map(int,input().split()))
c = [2,5,5,4,5,6,3,7,6]

A.sort(reverse=True)

dp = [-1 for _ in range(N+1)]
dp[0] = 0

for a in A:
    c_ = c[a-1]
    for i in range(c_,N+1):
        if dp[i-c_] == -1: continue
        dp[i] = max(dp[i], dp[i-c_]*10 + a)

print(dp[-1])

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

int main() {
	int n,m;cin>>n>>m;
	vector<int>  p(m);
	vector<string> s(m);
	vector<int> ac(n,0),wa(n,0);
	int acnum=0;
	int wanum=0;
	for(int i=0;i<m;i++){
		cin>>p[i]>>s[i];p[i]--;
		if(ac[p[i]]==0){
			if(s[i]=="AC"){
				ac[p[i]]=1;
				acnum++;
				wanum+=wa[p[i]];
			}else{
				wa[p[i]]++;
			}
		}
	}
	cout<<acnum<<' '<<wanum<<endl;
	return 0;
}


Measured memory_bytes: 6912
s = [c for c in input()]
a = [0, 0, 0, 0]
for c in s:
    if c == 'N':
        a[0] += 1
    elif c == 'S':
        a[1] += 1
    elif c == 'E':
        a[2] += 1
    elif c == 'W':
        a[3] += 1
if (a[0] != 0 and a[1] == 0 or a[0] == 0 and a[1] != 0) \
    or (a[2] != 0 and a[3] == 0 or a[2] == 0 and a[3] != 0):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG dpmatome/d.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);//おまじないでcin, cout早くする
    int N, W;
    cin >> N >> W;
    int m[N + 1][2];
    for(int i = 1; i<= N; i++){
        cin >> m[i][0] >> m[i][1];
    }

    ll dp[N + 1][W + 1];// 荷物iまで，重さjのときの価値の最大値
    for(int i = 0; i <= N; i++){
        for(int j = 0; j<= W; j++){
            dp[i][j] = 0;
        }
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W; j++){
            if(j - m[i][0] < 0){
                dp[i][j] = dp[i - 1][j];
            }else{
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - m[i][0]] + m[i][1]);
            }
        }
    }

    ll ans = 0;
    for(int j = 0; j <= W; j++){
        if(ans < dp[N][j]) ans = dp[N][j];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 79104
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int x, y;
	for (;;) {
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0) break;
		if (y < x) {
			x ^= y;
			y ^= x;
			x ^= y;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) (x).begin(),(x).end()
#define Ceil(x, n) (((((x))+((n)-1))/n))
#define CeilN(x, n) (((((x))+((n)-1))/n)*n)

#define INF 2e7
#define INF_LL 1LL<<60
#define ll long long
typedef pair<ll, ll>    P;

int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }


ll gcd(ll a, ll b){
    ll tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

vector<int> Eratosthenes(const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main()
{
    int n = nextint();
    vector<int> inp(n);
    REP(i, n) inp[i] = nextint();
    vector<int> prime;
    prime = Eratosthenes(1005);

    vector<int> ans(1000001, 0);

    REP(i, n) {
        REP(j, prime.size()) {
            int div = prime[j];
            if(div > sqrt(inp[i])) continue;
            if(inp[i] % div == 0) {
                ans[div]++;
                if(div != inp[i]/div) ans[inp[i]/div]++;
                //cout << inp[i] << " " << div << endl;
            }
        }
        ans[inp[i]]++;
    }

    bool flag = false;

    REP(i, 1000001) {
        if(i != 1) if(ans[i] > 1) flag = true;
    }

    if(ans[1] == n || !flag) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int num = inp[0];

    REP(i, n-1) {
        num = gcd(num, inp[i+1]);
    }

    if(num > 1) {
        cout << "not coprime" << endl;
    } else {
        cout << "setwise coprime" << endl;
    }

    //cout << prime.size() << endl;

    return 0;
}

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

int main()
{
	while ( true )
	{
		int n,s; cin>>n>>s;
		if ( n==0 && s==0 )
			break;
		int c = 0;
		for ( int i=0; i<1<<10; i++ )
		{
			int tn = 0;
			int ts = 0;
			for ( int j=0; j<10; j++ )
			if ( i>>j&1 )
				tn++,
				ts += j;
			if ( tn==n && ts==s )
				c++;
		}
		cout << c << endl;
	}
	return 0;
}

					

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;

    vector<bool>hund(10,false);
    vector<bool>ten(100,false);
    vector<bool>ans(1000,false);

    for(int i=0;i<n;i++){
        int num = (int)(s[i] - '0');
        for(int j=0;j<100;j++){
            if(ten[j]){
                ans[j*10 + num] = true;
            }
        }
        
        for(int j=0;j<10;j++){
            if(hund[j]){
                ten[j*10 + num] = true;
            }
        }

        hund[num] = true;
    }
    
    int answ = 0;
    for(int i=0;i<1000;i++){
        if(ans[i])answ++;
    }
    cout << answ << endl;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInput() string {
	sc.Scan()
	return sc.Text()
}

func convertStrToIntAry(str string, n int) (result []int) {
	ary := strings.Split(str, " ")
	for i := 0; i < n; i++ {
		a, err := strconv.Atoi(ary[i])
		if err != nil {
			panic(err)
		}
		result = append(result, a)
	}
	return
}

func main() {
	s1 := getInput()
	n, err := strconv.Atoi(s1)
	if err != nil {
		panic(err)
	}
	s2 := getInput()
	ary := convertStrToIntAry(s2, n)
	// fmt.Printf("n = %d, ary = %v\n", n, ary)

	result := math.MaxInt64
	for i := -100; i <= 100; i++ {
		var cost int
		for _, a := range ary {
			cost += (i - a) * (i - a)
		}
		// fmt.Printf("i = %d, cost = %d\n", i, cost)
		if cost < result {
			result = cost
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
  while(true){
    ll a,b;
    cin >> a >> b;
    if(a == 0 && b == 0)return 0;
    ll A = max(a,b),B = min(a,b);
    int cnt = 0;
    while(A % B != 0){
      A = (A % B);
      swap(A,B);
      cnt++;
    }
    cout << B << " " << cnt + 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool prime_num(long x){
    if(x == 1) return false;
    for(long i=2; i<=int(sqrt(x)); i++){
        if(x%i == 0) return false;
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    int temp = 11;
    for(int i=0; i<N; i++){
        while(!prime_num(temp)){
            temp += 10;
        }
        cout << temp;
        if(i!=N-1) cout << " " ;
        temp += 10;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  if(s=="RRR") print(3);
  else if(s=="SRR"||s=="RRS") print(2);
  else if(s=="SSS") print(0);
  else print(1);
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() 
{ 
    fastio
    ll a, v;
    ll b, w;
    ll t;
    cin>>a>>v>>b>>w>>t;
    if(b<a) {
        swap(a, b);
    }

    if(a - b >= t*(w-v)) {
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    ll l, r;    cin >> l >> r;
    ll res=LINF;
    if(2019<=r-l+1) res = 0;
    else{
        FOR(i, l, r+1)
            FOR(j, i+1, r+1) res = min(res, i*j%2019);
    }
    cout << res << endl;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
int H,W;
int i,j;
for(;;)
{
scanf("%d %d",&H,&W);
if(H!=0&&W!=0)
{
for(i=1;i<=H;i++)
{
for(j=1;j<=W;j++)
{
printf("#");
}
printf("\n");
}
printf("\n");
}
else
{
break;
}
}
return 0;
}

Measured memory_bytes: 1000
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s, t;std::cin >> s >> t;
  reverse(all(s));
  std::cout << (s==t?"YES":"NO") << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#include <unordered_map>
#define int long long 
#define pi pair<int,int> 
#define endl "\n"
using namespace std ;

const int inf = 1e15 ;
const int size = 1e5 + 5 ;
const int mod = 1e9 + 7 ;
vector<int>a(size) ;
int dp[size] ;
int x , n , k ;

int32_t main() 
{


     /*#ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/
     
     cin >> n >> k ;

     for(int i = 1 ; i <= n ; i++ )
     {
         cin >> a[i]  ;
     } 
     
     for(int i = 0 ; i <= k ; i++ )
     {
         for(int j = 1 ; j <= n ; j++ )
         {
              if( i - a[j] >= 0 && dp[i-a[j]] == 0 )
              {
                 dp[i] = 1 ;
              }
         }
     }
     if(dp[k])cout<<"First"<<endl;
     else cout<<"Second"<<endl;

    return 0 ;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#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 MOD 1000000007
#define MAX 2000010

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int main(){
  ll x,y,m,n;
  cin >> x;
  cin >> y;
  ll ans;
  
  if((2*x-y)%3 != 0 || (2*y-x)%3 != 0 || (2*x-y)/3 < 0 || (2*y-x)/3 < 0){
    cout << 0 << endl;
    return 0;
  }
  m = (2*x-y)/3;
  n = (2*y-x)/3;

  COMinit();
  ans = fac[m+n] * (finv[m] * finv[n] % MOD) % MOD;

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

Measured memory_bytes: 47232
import itertools
#K = int(input())
N,M,Q = map(int,input().split())
#N = str(input())
#A = list(map(int,input().split()))
nums=[i for i in range(1,M+1)]
count=0
inp=[]
for i in range(Q):
    I=list(map(int,input().split()))
    inp.append(I)

for v in itertools.combinations_with_replacement(nums, N):
    c=0
    v=list(v)
    for i in inp:

        if v[i[1]-1] - v[i[0]-1]==i[2]:
            c+=i[3]
    count=max(count,c)
print(count)


Measured memory_bytes: 9208
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int t = saori.saori_hayami();
		if(x - t <= 0){
			System.out.println(0);
		} else {
			System.out.println(x-t);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};


struct Solver {
  std::array<std::string, 2> xs; 
  Solver() {
    S002 reader;
    reader >= xs;
  }
  void solve() {
    if( xs[0].size() != xs[1].size() ) {
      puts(xs[0].size() < xs[1].size() ? "LESS" : "GREATER");
      return;
    }
    puts(xs[0] < xs[1] ? "LESS" : xs[0] == xs[1] ? "EQUAL" : "GREATER");
  }    
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N, M;
int A[5];
 
int main() {
  cin >> N >> M;
  int pos, num;
  memset(A, -1, sizeof(A));
  for(int i = 1; i <= M; i++) {
    cin >> pos >> num;
    if(A[pos] == -1) {
      A[pos] = num;
    }else if(A[pos] != num) {
      puts("-1");
      return 0;
    }
  }
  if(A[1] == 0 && N > 1) {
    puts("-1");
    return 0;
  }
  for(int i = 1; i <= N; i++) {
    if(A[i] == -1) {
      if(i == 1 && N > 1)cout << 1;
      else cout << 0;
    }else cout << A[i];
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int Q,H,S,D,N;
  cin>>Q>>H>>S>>D>>N;
  int A = Q*4*N;
  int B = H*2*N;
  int C = S*N;
  int E = D*(N/2) + S*(N%2);
  int F = D*(N/2) + H*2*(N%2);
  int G = D*(N/2) + Q*4*(N%2);
  cout<<min(min(min(A,B),min(C,E)),min(F,G))<<endl;
  return;
}




int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
d = []
4.times { d << gets.chomp.to_i }
A, B, C, X = d
count = 0
(A + 1).times do |a|
    (B + 1).times do |b|
        (C + 1).times do |c|
            if 500 * a + 100 * b + 50 * c == X
                count += 1
            end
        end
    end
end
puts count

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

using namespace std;

int N, C;
vector<vector<int> > D;
vector<vector<int> > c;
map<tuple<short, int>, int> dp;
map<tuple<short, short>, int> dp2;

int add(short now, short col) {
	int cnt = 0;
	auto status = make_tuple(now, col);
	if (dp2.count(status)) return dp2[status];
	for (int j = 0; j < N; j++) {
		for (int k = 0; k < N; k++) {
			if ((j + k) % 3 != now) continue;
			cnt += D[c[j][k]][col];
		}
	}
	return dp2[status] = cnt;
}

int dfs(short now, int color) {
	if (now == 3) return 0;
	auto status = make_tuple(now, color);
	if (dp.count(status)) return dp[status];
	int res = numeric_limits<int>::max();
	for (short i = 0; i < C; i++) {
		if (color & (1 << i)) continue;
		int cnt = 0;
		cnt += add(now, i);
		res = min(res, cnt + dfs(now + 1, color | (1 << i)));
	}
	return dp[status] = res;
}

void hawawa()
{
	cin >> N >> C;
	D.resize(C, vector<int>(C));
	c.resize(N, vector<int>(N));
	for (auto&& i : D) {
		for (auto&& j : i) {
			cin >> j;
		}
	}
	for (auto&& i : c) {
		for (auto&& j : i) {
			cin >> j;
			j--;
		}
	}
	cout << dfs(0, 0) << "\n";
}

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


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
char mapa[2001][2001];
int rows[2001][2001];
int cols[2001][2001];
int main(){
    int i, j, k;
    int n, m;
    scanf("%d%d", &n, &m);
    for(i=0; i<n; i++){
        scanf("%s", mapa[i]);
    }
    int lastValid=0, validCount=0;
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            if(mapa[i][j]=='#'){
                for(k=lastValid; k<j && j>=0; k++){
                    cols[i][k]=validCount;
                }
                validCount=0;
                lastValid=j+1;
            }
            else{
                validCount++;
            }
        }
        for(k=lastValid; k<j; k++){
            cols[i][k]=validCount;
        }
        lastValid=0;
        validCount=0;
    }
    for(i=0; i<m; i++){
        for(j=0; j<n; j++){
            if(mapa[j][i]=='#'){
                for(k=lastValid; k<j && j>=0; k++){
                    rows[k][i]=validCount;
                }
                validCount=0;
                lastValid=j+1;
            }
            else{
                validCount++;
            }
        }
        for(k=lastValid; k<j; k++){
            rows[k][i]=validCount;
        }
        lastValid=0;
        validCount=0;
    }
    int ans=0;
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            ans=max(ans, rows[i][j]+cols[i][j]-1);
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 35456
#!/usr/bin/env ruby
s = gets.strip

unless s.chars.reject { |c| c == 'x' }.tap { |k| break (k == k.reverse) }
  puts '-1'
  exit
end

result = 0
ue = s.chars
st = ue.reverse

while !ue.empty? || !st.empty?
  if ue.first == st.first
    ue = ue.drop(1)
    st = st.drop(1)
  else
    if ue.first == 'x'
      result += 1
      ue = ue.drop(1)
    else
      result += 1
      st = st.drop(1)
    end
  end
end

puts result / 2


Measured memory_bytes: 18668
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn],b[maxn],p[maxn];
int c[100],d[100];
int x[maxn],y[maxn],t[maxn];
int cal(int n){
	int ans = 0;
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
		if(p[i]>p[j])ans++;
	return ans;
}
bool check(int n){
	sort(x,x+(n+1)/2);
	sort(y,y+n/2);
	for(int i=0;i<n;i++){
		if(i%2==0)t[i] = x[i/2];
		else t[i] = y[i/2];
	}
//	for(int i=0;i<(n+1)/2;i++)cout<<x[i]<<" ";cout<<endl;
//	for(int i=0;i<n/2;i++)cout<<y[i]<<" ";cout<<endl;
//	for(int i=0;i<n;i++)cout<<t[i]<<" ";cout<<endl;
	for(int i=1;i<n;i++)
		if(t[i]<t[i-1])return 0;
	return 1;
}
int main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	int ans = 1<<30;
	for(int i=0;i<(1<<n);i++){
//		cout<<i<<"*************************"<<endl;
		int odd = 0,even = 0;
		memset(c,0,sizeof(c));
		memset(d,0,sizeof(d));
		for(int j=0;j<n;j++)
			if(i&(1<<j)){
				if(j%2==0){
					x[odd++] = a[j];
					d[a[j]]++;
				}
				else{
					y[even++] = a[j];
					c[a[j]]++;
				}
			}
			else{
				if(j%2==1){
					x[odd++] = b[j];
					d[b[j]]++;
				}
				else{
					y[even++] = b[j];
					c[b[j]]++;
				}
			}
//		cout<<"!!!"<<i<<" "<<odd<<endl;
		if(n-odd!=n/2)continue;
		if(!check(n))continue;
		for(int j=1;j<=50;j++)c[j] += c[j-1],d[j] += d[j-1];
		for(int j=n-1;j>=0;j--){
			if(i&(1<<j)){
				if(j%2==0){
					p[j] = d[a[j]]*2-1;
					d[a[j]]--;
				}
				else{
					p[j] = c[a[j]]*2;
					c[a[j]]--;
				}
			}
			else{
				if(j%2==1){
					p[j] = d[b[j]]*2-1;
					d[b[j]]--;
				}
				else{
					p[j] = c[b[j]]*2;
					c[b[j]]--;
				}
			}
		}
//		for(int j=0;j<n;j++)cout<<p[j]<<" ";cout<<endl;
		ans = min(ans,cal(n));
//		cout<<"!"<<i<<" "<<cal(n)<<endl;
	}
	if(ans==1<<30)cout<<-1<<endl;
	else cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> c;
	cout << 2 * c - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

int main() {
    while (true) {
        int N, M; cin >> N >> M;
        if (N == 0 && M == 0) break;
        vector<int> C(M), x(N);
        REP(i, M) cin >> C[i];
        REP(i, N) cin >> x[i];

        vector<vector<int>> dp(N+1, vector<int>(256, MOD));
        dp[0][128] = 0;

        REP(i, N) {
            REP(j, 256) {
                REP(k, M) {
                    int a = j + C[k];
                    if (a < 0) a = 0;
                    if (a >= 256) a = 255;
                    dp[i+1][a] = min(dp[i+1][a], dp[i][j] + (int)pow(a - x[i], 2));
                }
            }
        }

        int min_sum = MOD;
        REP(i, 256) min_sum = min(min_sum, dp[N][i]);
        PRINT(min_sum);

    }
    return 0;
}


Measured memory_bytes: 23752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n,fr[N];

int main(){
	cin>>n;
	for(int x,i=0; i<n; ++i){
		scanf("%d",&x);
		++fr[x];
		++fr[x+1];
		if(x)
			++fr[x-1];
	}
	int mx=0,id;
	for(int i=0; i<N; ++i)
		if(fr[i]>mx){
			mx=fr[i];
			id=i;
		}
		cout<<mx<<endl;
	
}




Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        for (int i = 0 ; i < m ; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
        }
        int[][] c = new int[n][n];
        for (int i = 0 ; i < m ; i++) {
            c[a[i]][b[i]]++;
            c[b[i]][a[i]]++;
        }
        for (int i = 0 ; i < n ; i++) {
            int count = 0;
            for (int j = 0 ; j < n ; j++) {
                count += c[i][j];
            }
            System.out.println(count);
        }
    }

}

Measured memory_bytes: 22996
import java.util.*;
import java.io.*;

public class Main {
	
	int solve(Scanner in, PrintWriter out)
	{
		long n = in.nextLong();
		long k = in.nextLong();
		
		out.println(n*n - k);
			return 0;
			
	}

	void run()
	{
		try(
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out)) {
		
			solve(in, out);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++)
    {
        if (2 * i + 4 * (X - i) == Y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

int a[10];
void solve(){
    for(int i=0;i<3;++i) {
        int t;
        cin >> t;
        a[t]++;
    }
    cout << (a[5] == 2 && a[7] == 1 ? "YES" : "NO") << "\n";

}

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



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

std::vector<int> KMP(const std::string& t, const std::string& p) {
  std::vector<int> fail(p.size() + 1);
  auto j = fail[0] = -1;
  for(auto i = 1; i <= p.size(); ++i) {
    while(0<=j && p[j]!=p[i-1]) j = fail[j];
    fail[i] = ++j;
  }
  std::vector<int> index(t.size());
  for(auto i = 0, k = 0; i < t.size(); ++i) {
    while(0<=k && p[k]!=t[i]) k = fail[k];
    if(p.size() <= ++k) {
      index[i+1-p.size()] = 1;
      k = fail[k];
    }
  }
  return index;
}

int main() {
  string S, T;
  cin >> S >> T;

  while(S.size() < T.size()) S = S + S;
  auto N = S.size();
  S = S + S;

  auto ok = KMP(S, T);

  const int INF = 1e9;

  vector<int> memo(N);
  vector<bool> used(N);
  function<int(int)> dfs = [&](auto i) {
    if(!ok[i]) return 0;
    if(used[i]) return memo[i] = INF;
    if(memo[i]) return memo[i];
    used[i] = true;
    memo[i] = 1;
    memo[i] = min(memo[i] + dfs((i + T.size()) % N), INF);
    used[i] = false; 
    return memo[i];
  };

  int res = 0;
  for(auto i=0; i<N; ++i) if(ok[i]) if(!memo[i]) res = max(res, dfs(i));
  cout << (res==INF ? -1 : res) << endl;
}


Measured memory_bytes: 45732
#include <iostream>

using namespace std;

int main()
{
	int N, p[100001] = { 0, },mx = 0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		a++;
		p[a - 1]++;
		p[a]++;
		p[a + 1]++;
		if (mx < p[a - 1])
			mx = p[a - 1];
		if (mx < p[a ])
			mx = p[a];
		if (mx < p[a + 1])
			mx = p[a + 1];
		
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> x(n);
        for (int i = 0; i < n; i ++) {
                scanf("%d", &x[i]);
        }
        int l;
        scanf("%d", &l);
        const int LOGM = 30;
        vector<vector<int>> c(n, vector<int> (LOGM, -1));
        for (int i = 0; i < n; i ++) {
                c[i][0] = (int) (upper_bound(x.begin(), x.end(), x[i] + l) - x.begin()) - 1;
        }
        for (int k = 0; k < LOGM - 1; k ++) {
                for (int i = 0; i < n; i ++) {
                        c[i][k + 1] = c[c[i][k]][k];
                }
        }
        int q;
        scanf("%d", &q);
        while (q --) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                if (a > b) swap(a, b);
                int ans = 1;
		for (int i = LOGM - 1; i >=0; i --) {
			if (c[a][i] < b) {
				a = c[a][i];
				ans += pow(2, i);
			}
		}
                printf("%d\n", ans);
        }
        return 0;
}



Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll binpow(ll a, ll b,ll MOD) {
    ll res = 1;
    a%=MOD;
    while (b > 0) {
        if (b & 1)
            res = res * a %MOD;
        a = a * a%MOD;
        b >>= 1;
    }
    return res;
}
ll a[100010],fac[1000010];
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++){
        ll k = a[i];
        for(int j=2;j*j<=a[i];j++){
            if(k%j==0){
                ll c=0;
                while(k%j==0)
                    k/=j,c++;
                fac[j]=max(fac[j],c);
            }
        }
        if(k>1)
            fac[k]=max(fac[k],(ll)1);
    }
    ll lcm=1;
    for(int i=2;i<=1e6;i++){
        if(fac[i]){
            lcm*=binpow(i,fac[i],1000000007);
            lcm%=1000000007;
        }
    }
    //cout<<lcm<<'\n';

    ll res=0;
    for(int i=0;i<n;i++){
        res+=lcm*binpow(a[i],1000000005,1000000007);
        res%=1000000007;
    }
    cout<<res;


}


Measured memory_bytes: 8192
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    while(y>0){
        ll r=x%y;
        x=y;
        y=r;
    }
    return x;
}

signed main(){
    ll k;cin >>k;
    ll ans=0;
    FOR(i,1,k){
        FOR(j,1,k){
            ll ans_=gcd(i,j);
            FOR(l,1,k){
                ans+=gcd(l,ans_);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,greater<int> > q;
int main(){
	double s=0;
	int x,n;
	cin>>n;
	
	for(int i=1;i<=n;++i)
	{
		cin>>x;
		q.push(x);
	}
	s=q.top();
	q.pop();
	for(int i=2;i<=n;++i)
	{
		s=1.0*(s+q.top())/2;
		q.pop();
	 } 
	 printf("%.5f",s);
	return 0;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : kamesh_11 *
* INSTITUTION : GVPCOE *
******************************************/

#include <bits/stdc++.h>
using namespace std;

#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define endl '\n'
#define start_clock clock_t beginn=clock()
#define end_clock clock_t endd=clock()
#define cal_exec_time double time_spent=(double)(endd-beginn)/CLOCKS_PER_SEC
#define print_exec_time cout<<endl<<time_spent<<" secs"

typedef long long int ll;

const ll MOD = 1000000007;

ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

ll ways(vector<vector<char>>&v, ll i, ll j, ll H, ll W, vector<vector<ll>>&dp){
	if(i==H-1 && j==W-1) return 1;
	if(dp[i][j] != -1) return dp[i][j];
	if(v[i][j] == '#')
		return 0;
	
	ll r = 0, d = 0;
	if(j+1 < W)
		r = ways(v, i, j+1, H, W, dp);
	if(i+1 < H)
		d = ways(v, i+1, j, H, W, dp);

	return dp[i][j] = (r%MOD + d%MOD)%MOD;
}

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

	ll H, W;
	cin>>H>>W;
	vector<vector<char>>v(H, vector<char>(W));
	for(ll i=0;i<H;i++){
		for(ll j=0;j<W;j++)
			cin>>v[i][j];
	}

	vector<vector<ll>>dp(H, vector<ll>(W, -1));
	cout<<ways(v, 0, 0, H, W, dp)%MOD;

	return 0;
}

Measured memory_bytes: 9344
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include<algorithm>
using namespace std;

int main() {

	int n;
	int c;
	int a;
	int b;
	int d[101]={};
	int s;
	int t=0;
	int m=0;

	cin>>n;
	cin>>a>>b;
	cin>>c;


	for(int i=0; i<n; i++){
		cin>>d[i];
	}
	sort(d, d + n, greater<int>());
	t=c;
	for(int i=0; i<n; i++){
		t+=d[i];
		s=t/(a+(i+1)*b);
		if(m<s)m=s;
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 3088
n = int(input())
A = list(map(int,input().split()))
f = n-1
change_sum = 0

while True:
    if f == 0 :
        break
    
    for i in range(f):
        if A[i] > A[i+1]:
            v = A[i]
            A[i] = A[i+1]
            A[i+1] = v
            change_sum += 1
    f += -1    

for i in range(n):
    if i == n-1:
        print(A[i])
    else:
        print(A[i],end=' ')

print(change_sum)


Measured memory_bytes: 5600
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a, b;
  cin >> a >> b;
  cout << ceil((a + b) / 2) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
def main():
    N, L = map(int, input().split())
    lst = []
    for i in range(N):
        lst.append(L+i+1-1)
    convertLst = list(map(abs, lst))
    minElement = min(convertLst)
    lst.pop(convertLst.index(minElement))
    print(sum(lst))
main()

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int a,b,i;
	scanf("%d %d",&a,&b);
	if(a<=b){
		for(i=0;i<b;i++){
			printf("%d",a);
		}
	}else{
		for(i=0;i<a;i++){
			printf("%d",b);
		}
	}
	return 0;
}

Measured memory_bytes: 128
(let* ((n (read))
       (k (read))
       (hs (make-array n :element-type 'integer)))
  (loop for i from 0 below n do (setf (aref hs i) (read)))
  (setf hs (sort hs #'>=))
  (format t "~a~%" (loop for i from k below n
                         summing (aref hs i))))

Measured memory_bytes: 69988
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int a[N],b[N],n,m,p,ma=1e9,mb=1e9;long long ans;
int main(){
    scanf("%d%d%d",&n,&m,&p);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),ma=min(ma,a[i]);
    for(int i=1;i<=m;i++)scanf("%d",&b[i]),mb=min(mb,b[i]);
    ans=0ll+ma+mb;
    for(int i=1,x,y,z;i<=p;i++){
        scanf("%d%d%d",&x,&y,&z);
        ans=min(ans,0ll+a[x]+b[y]-z);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int main()
{
    int N, sum = 0, d = 0, flag = 0;
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; i++)
    {
        cin >> W.at(i);
        sum += W.at(i);
    }
    for (int i = 0; i < N; i++)
    {
        flag += W.at(i) ;
        if(flag > sum/2) 
        {
            d = W.at(i);
            break;
        }
    }
   cout << min(abs(sum - 2 * flag), sum- 2 * (flag - d) ) << endl;
    return 0;
}

Measured memory_bytes: 256