akhauriyash/Code-Regression huggingface dataset:
mod = 1000000007
fact = []
fact_inv = []
pow_ = []

def pow_ini(nn):
	global pow_
	pow_.append(nn)
	for j in range(62):
		nxt = pow_[j] * pow_[j]
		nxt %= mod
		pow_.append(nxt)
	return

def pow1(k):
    ansk = 1
    for ntmp in range(62):
        if((k >> ntmp) % 2 == 1):
            ansk *= pow_[ntmp]
            ansk %= mod
    return ansk

def fact_ini(n):
	global fact
	global fact_inv
	for i in range(n + 1):
		fact.append(0)
		fact_inv.append(0)
	fact[0] = 1
	for i in range(1, n + 1, 1):
		fact_tmp = fact[i - 1] * i
		fact_tmp %= mod
		fact[i] = fact_tmp
	pow_ini(fact[n])
	fact_inv[n] = pow1(mod - 2)
	for i in range(n - 1, -1, -1):
		fact_inv[i] = fact_inv[i + 1] * (i + 1)
		fact_inv[i] %= mod
	return

def nCm(n, m):
	assert(m >= 0)
	assert(n >= m)
	ans = fact[n] * fact_inv[m]
	ans %= mod
	ans *= fact_inv[n - m]
	ans %= mod
	return ans;

def nPm(n, m):
	assert(m >= 0)
	assert(n >= m)
	ans = fact[n]
	ans *= fact_inv[n - m]
	ans %= mod
	return ans;

fact_ini(5500000)
N, M = (int(x) for x in input().split())
ans = 0
for i in range(0, N+1, 1):
	anstmp = nCm(N, i) * nPm(M-i, N-i)
	anstmp %= mod
	if(i%2 == 1):
		anstmp *= -1
		anstmp += mod
		anstmp %= mod
	ans += anstmp
	ans %= mod
ans *= nPm(M, N)
ans %= mod
print(ans)

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


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}


int main() {
    fast();
    ll n;cin>>n;
    ll x=0,y=0;
    while(n--){
        ll a,b;cin>>a>>b;
        ll l=1,r=1e18/max(a,b),mid,solu;
        while(l<=r){
            mid=(l+r)/2;
            if(mid*a>=x&&mid*b>=y)r=mid-1;
            else l=mid+1;
        }
        //cout<<solu<<" ";
        x=a*l;
        y=l*b;
       // cout<<x<<" "<<y<<" ";
    }
    cout<<x+y;
}

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


using namespace std;


void security()
{
  string s;
  cin >> s;

  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i - 1] == s[i])
    {
      cout << "Bad\n";
      return;
    }
  }
  cout << "Good\n";
}


void fifty_fify()
{
  string s;
  cin >> s;

  sort(s.begin(), s.end());

  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes\n";
  else cout << "No\n";
}


void dodecagon()
{
  int r;
  cin >> r;

  cout << 3 * r * r << "\n";
}


void harmony()
{
  int a, b;
  cin >> a >> b;

  if (a % 2 == b % 2) cout << (a + b) / 2 << "\n";
  else cout << "IMPOSSIBLE\n";
}


int main()
{
  //security();
  //fifty_fify();
  //dodecagon();
  harmony();
}

Measured memory_bytes: 256
s=input()
k=int(input())
t="abcdefghijklmnopqrstuvwxyz"
a=[t.index(i)for i in s]
i=0
while k:
  if i==len(s)-1:a[i]+=k;a[i]%=26;k=0
  if a[i]==0 or 26-a[i]>k:i+=1
  else:a[i]+=1;a[i]%=26;k-=1
print("".join([t[i]for i in a]))

Measured memory_bytes: 4980
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cut = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'L' && i < n - 1 && s[i + 1] == 'R') {
      cut++;
    } else if(s[i] == 'R' && i < n - 1 && s[i + 1] == 'L') {
      cut++;
    }
  }
  cout << min(n - 1 - cut + k * 2, n - 1) << endl;
  return 0;
}

Measured memory_bytes: 3704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {

	class Vertex {
		int id;
		List<Integer> vertices = new ArrayList<>();
		int visited = -1;
		int completed = -1;
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	public void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Vertex[] vertices = new Vertex[n];
		for (int i = 0; i < n; i++) {
			vertices[i] = new Vertex();
			StringTokenizer st = new StringTokenizer(reader.readLine());
			vertices[i].id = Integer.parseInt(st.nextToken());
			int k = Integer.parseInt(st.nextToken());
			for (int j = 0; j < k; j++) {
				vertices[i].vertices.add(Integer.parseInt(st.nextToken()));
			}
		}
		reader.close();
		
		dfs(vertices);
		
		for (int i = 0; i < n; i++) {
			Vertex v = vertices[i];
			System.out.println(v.id + " " + v.visited + " " + v.completed);
		}
	}

	private void dfs(Vertex[] vertices) {
		int time = 0;
		for (Vertex vertex : vertices) {
			if (vertex.visited != -1) continue;
			time = dfs(vertex, vertices, time);
		}
	}

	private int dfs(Vertex vertex, Vertex[] vertices, int time) {
		Stack<Integer> stack = new Stack<>();
		stack.push(vertex.id);
		while (!stack.empty()) {
			int id = stack.peek() - 1;
			if (vertices[id].visited == -1) {
				vertices[id].visited = ++time;
			}
			int nId = getNextUnvisitedId(vertices[id].vertices, vertices);
			if (nId == -1) {
				vertices[id].completed = ++time;
				stack.pop();
			} else {
				stack.push(nId);
			}
		}
		return time;
	}

	private int getNextUnvisitedId(List<Integer> ids, Vertex[] vertices) {
		for (Integer id : ids) {
			if (vertices[id - 1].visited != -1) continue;
			return id;
		}
		return -1;
	}
}


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

int A, B;

int main() {
    cin >> A >> B;

    if (abs(A - B) % 2 == 0) {
        cout << min(A, B) + abs(A - B) / 2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}


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

using namespace std;

int main()
{
    int x,y;
    cin>>x>>y;
    if (x==y)
        cout<<x*2<<endl;
    else
    {
        int ans=max(x,y);
        cout<<ans+(ans-1)<<endl;
    }


    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<char> s(n);
    
    for(int i=0;i<n;i++)
        cin>>s[i];
    
    int c=0;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C')
                    c++;
            }
        }
    }
    
    cout<<c<<endl;
}

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

int main(){
    int N; cin >> N;
    vector<long> v;
    for (int i = 0; i < N+1; i++)
    {
        int A; cin >> A;
        v.push_back(A);
    }

    long long ans = 0;
    long prev = 0;
    for (int i = 0; i < N; i++)
    {
        int B; cin >> B;
        if(v[i]<=prev){
            ans+=v[i];
            prev = B;
        } else {
            v[i] -= prev;
            ans += prev;
            if(v[i]>=B){
                ans += B;
                prev = 0;
            } else{
                ans += v[i];
                prev = B - v[i];
            }
        }
    }
    ans += min(prev, v[N]);
    cout << ans << endl;
}

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

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


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

int main(){
int H,W;
while(1){
cin>>H>>W;
if(H==0&&W==0) break;
for(int i=0;i<H;i++){
for(int h=0;h<W;h++){
if((i+h)%2==0)cout<<"#";
else if((i+h)%2==1)cout<<".";
}
cout<<endl;
}
cout<<endl;
}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	int ans = 0;
	sort(all(l));
	rep(i, n-2) {
		for(int j = i+1; j < n-1; j++){
			for(int k = j+1; k < n; k++){
				if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
				if (l[i]+l[j]>l[k]) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define INF 100100100
#define MOD 1000000007

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

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N;
   cin>>N;
   if(N%2)cout<<N*2;
   else cout<<N;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
using lint = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vii = vector<pii>;

struct segtree{
  int n; vi t;
  segtree(int n) : n(n), t(n<<2) {}

  int qry(int l,int r){ return qry(1,0,n-1,l,r); }
  int qry(int n,int s,int e,int l,int r){
    if(r<s || e<l) return 0;
    if(l<=s&&e<=r) return t[n];
    int m = (s+e)>>1;
    return max(qry(n<<1,s,m,l,r), qry(n<<1|1,m+1,e,l,r));
  }

  void upd(int i,int v){ upd(1,0,n-1,i,v); }
  int upd(int n,int s,int e,int i,int v){
    if(i<s || e<i) return t[n];
    if(s==e) return t[n] += v;
    int m = (s+e)>>1;
    return t[n] = max(upd(n<<1,s,m,i,v), upd(n<<1|1,m+1,e,i,v));
  }

};

int H, W, M, h[300000], w[300000];

int hh[300001];
vi b[300001];

int solve(){
  int ret = 0;
  for(int i=0;i<M;++i)
    hh[h[i]]++, b[h[i]].eb(w[i]);

  segtree st(W+2);
  for(int i=0;i<M;++i)
    st.upd(w[i], 1);

  for(int i=1;i<=H;++i){
    for(auto &it : b[i-1])
      st.upd(it, 1);
    for(auto &it : b[i])
      st.upd(it,-1);
    ret = max(ret, hh[i] + st.qry(1,W)); 
  }
  return ret;
}

int main(){
  scanf("%d%d%d",&H,&W,&M);
  for(int i=0;i<M;++i)
    scanf("%d%d",h+i,w+i);

  int ans = solve();
  printf("%d",ans);
}


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

int main()
{
  long long lprev = 2;
  long long lnow = 1;
  int i, n;
  long long lnew;
  cin >> n;
  for(i = 0; i < n-1; i++)
  {
    lnew = lnow + lprev;
    lprev = lnow;
    lnow = lnew;
  }
  cout << lnow << endl;
}

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

class Program
{
    public static void Main()
    {
        var N = long.Parse(Console.ReadLine());

        List<long> list = new List<long>();
        list.Add(long.Parse(Console.ReadLine()));
        list.Add(long.Parse(Console.ReadLine()));
        list.Add(long.Parse(Console.ReadLine()));
        list.Add(long.Parse(Console.ReadLine()));
        list.Add(long.Parse(Console.ReadLine()));    

        double a = Math.Ceiling((double)N / (double)list.Min());

        Console.WriteLine((long)a + 4);

    }
}

Measured memory_bytes: 13268
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
t = ns()

n = len(s)
m = len(t)
ans = 99999999999
for i in range(n-m+1):
    dif = 0
    for j in range(m):
        if s[i+j] != t[j]:
            dif += 1
    ans = min(ans, dif)
print(ans)


Measured memory_bytes: 67552
// AOJ 1077: The Great Summer Contest
// 2017.10.14

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

int n[3];

int main()
{
	int i, j, a, fin, ans;
	char k[3], f[3];

	while (1) {
		memset(n, 0, sizeof(n));
		memset(k, 0, sizeof(k));
		memset(f, 0, sizeof(f));

		for (fin = 0, j = 0; j < 2; j++) for (i = 0; i < 3; i++)
			scanf("%d", &a), n[i] += a, fin |= a;
		if (!fin) break;

		for (ans = 0, i = 0; i < 3; i++) {
			if (n[i] >= 3) f[i] = 1;
			ans += n[i] / 3, n[i] %= 3;
			k[n[i]]++;
		}
		if (k[0] > 0) {
			if (k[2] == 2) {
				for (i = 0; n[i]; i++);
				if (f[i]) ans++;
			}
		} else if (k[1] > 0) ans++;
		else if (k[2] > 0) ans += 2;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1700
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int a = sc.nextInt();
            int l = sc.nextInt();
            if (a == 0 && l == 0) break;
            List<Integer> list = new ArrayList<Integer>();
            for (int i = 1; i <= 20; i++) {
                list.add(a);
                char[] chars = String.format("%0"+ l + "d", a).toCharArray();
                Arrays.sort(chars);
                String small = new String(chars);
                String big = new StringBuilder(small).reverse().toString();
                a = Integer.parseInt(big) - Integer.parseInt(small);
                int j = list.indexOf(a);
                if (j != -1) {
                    System.out.println(j + " " + a + " " + (i-j));
                    break;
                }
            }
        }
        sc.close();
    }
}

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

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i = 0;i<n-1;i++)
        cout<<a[i]<<' ';
    cout<<a[n-1];
    cout<<endl;
    for (int i=1;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(j>=0 and v<a[j]){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;

        for(int k = 0;k<n-1;k++)
            cout<<a[k]<<' ';
        cout<<a[n-1];
        cout<<endl;

    }
    return 0;
}

Measured memory_bytes: 3080
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//Union-Find??¨

int main(void){
	int a,b;
	cin>>a>>b;
	if(a>b)cout<<"a > b"<<endl;
	if(a<b)cout<<"a < b"<<endl;
	if(a==b)cout<<"a == b"<<endl;
	return 0;
}

Measured memory_bytes: 3076
N=int(input())
V=list(map(int,input().split()))

A={0:0}
B={0:0}
for i in range(N):
    v=V[i]
    if i%2==0:
        if v in A:
            A[v]+=1
        else:
            A[v]=1
    else:
        if v in B:
            B[v]+=1
        else:
            B[v]=1

P=max(A,key=lambda x:A[x])
Q=max(B,key=lambda x:B[x])

if P!=Q:
    print(N-(A[P]+B[Q]))
else:
    X=A[P]
    del A[P]
    R=max(A,key=lambda x:A[x])

    Y=B[Q]
    del B[Q]
    S=max(B,key=lambda x:B[x])

    print(N-max(X+A[R],Y+B[S]))


Measured memory_bytes: 98236
package main

import (
	"fmt"
)

var count int = 0

func main() {
	var n int
	fmt.Scanf("%d", &n)

	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &nums[i])
	}

	operate(nums)

	fmt.Println(count)
}

func operate(slice []int) {
	if slice == nil {
		return
	}

	var res []int
	for _, e := range slice {
		if e%2 != 0 {
			return
		}
		res = append(res, e/2)
	}
	count++
	operate(res)
}


Measured memory_bytes: 1972
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n, m;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cout << (n - 1) * n / 2 + (m - 1) * m / 2;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    final long max = Long.MAX_VALUE/10;
    int n=1;
    long[] dat;
    public static void main(String[] args) {
        Main main = new Main();
        System.out.println(main.solve());
    }
    // segment tree to record minimum value
    // Each point has a infinite distance from 0 (except itself)
    long solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[][] co = new double[n][2];
        for(int i=0;i<n;i++){
            double x = sc.nextDouble(), y = sc.nextDouble();
            co[i][0] = x; co[i][1] = y;
        }
        double ans = 0.0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j) continue;
                double[] p1 = co[i], p2 = co[j];
                double dx = p1[0]-p2[0], dy = p1[1]-p2[1];
                double cur = Math.sqrt(dx*dx+dy*dy);
                ans += cur/n;
            }
        }
        System.out.println(ans);
        System.exit(0);
        return 0;
        
    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(max(a, b), min(a, b)); }

int main() {
    int N;  cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vector<pair<ll, ll>> p;
    rep(i, N) p.push_back(make_pair(B[i], A[i]));
    sort(all(p));

    ll time = 0;
    rep(i, N) {
        time += p[i].second;
        if (time > p[i].first) {
            no;
            return 0;
        }
    }

    yes;
    return 0;

}

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fs first
#define se second
#define M 1000000007
struct trap{
	ll l=-1,r=-1,d=-1;
};
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,sum=0;
	cin>>n;
	vector<ll>arr[n],v;
	for(ll i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		v.pb(a);
		vector<ll>h(61,0);
		arr[i]=(h);
		ll p=0;
		while(a)
		{
			if(a&1)
				arr[i][p]=1;
			p++;
			a=a>>1;
		}
		if(i!=0)
			for(ll j=0;j<=60;j++)
			{
				arr[i][j]+=arr[i-1][j];
			}
	}
	// for(ll i=0;i<n;i++)
	// {
	// 	for(ll j=0;j<=60;j++)
	// 		cout<<arr[i][j]<<" ";
	// 	cout<<endl;
	// }
	ll ans=0;
	for(ll i=0;i<=60;i++)
	{
		ll p=1LL<<(i);
		// cout<<p<<" ";
		for(ll j=0;j<n-1;j++)
		{
			ll tot=n-1-j;
			ll fin=arr[n-1][i];
			ll ones=0;
			
			ones=fin-arr[j][i];
			ll z=tot-ones;
			if(v[j]&(p))
				z=z;
			else 
				z=ones;
			ans=((ans%M)+((p%M)*(z%M))%M)%M;
			// ans=((ans%M)+((p%M)*(z%M))%M)%M;
			// cout<<ans<<endl;
		}	
	}
	
	// cout<<f<<" "<<s<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 158572
#include <stdio.h>
#include <math.h>
int n, c, b;
long long xt, yt;
long long x[1002];
long long y[1002];
long long r[1002];
double m[1002][1002];
double f;
int e[1002];
double d[1002];
double l = 10000000000;
int main() {
	scanf("%lld%lld%lld%lld", x, y, &xt, &yt);
	scanf("%d", &n);
	n += 2;
	x[n - 1] = xt; y[n - 1] = yt;
	for (int i = 1; i < n - 1; i++) {
		scanf("%lld%lld%lld", x + i, y + i, r + i);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			f = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
			f = sqrt(f);
			f -= (r[i] + r[j]);
			if (f < 0)f = 0;
			m[i][j] = f;
		}
	}
	c = 1;
	e[0] = 1;
	b = 0;
	for (int i = 1; i < n; i++)d[i] = l;
	while (c < n) {
		for (int i = 0; i < n; i++) {
			if (m[b][i] + d[b] < d[i])d[i] = m[b][i] + d[b];
		}
		f = l;
		for (int i = 0; i < n; i++) {
			if (!e[i] && d[i] < f) {
				b = i;
				f = d[i];
			}
		}
		e[b] = 1;
		c++;
	}
	printf("%.18lf\n", d[n - 1]);
}

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

int main(){
  int N, M;
  cin >> N >> M;
  map<int, vector<int>> mp;
  for(int i=0;i<N;i++){
    int a, b;
    cin >> a >> b;
    mp[a].push_back(b);
  }
  int64_t ans = 0;
  priority_queue<int> que;
  for(int i=1;i<=M;i++){
    for(auto j : mp[i]){
     que.push(j);
   }
    if(!que.empty()){
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

int main() 
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    ll happy = 0;
    
    int n;
    cin >> n;
    
    if (n / 500)
    {
        happy += n / 500 * 1000;
        n %= 500;
    }
    
    if (n / 100)
    {
        happy += n / 100 * 100; 
        n %= 100;
    }
    
    if (n / 50)
    {
        happy += n / 50 * 50;
        n %= 50;
    }
    
    if (n / 10)
    {
        happy += n / 10 * 10;
        n %= 10;
    }
    
    if (n / 5)
    {
        happy += n / 5 * 5;
        n %= 10;
    }
    
    cout << happy;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
nums = list(map(int,input().split()))

S = [0]

for i in range(n):
    S.append(S[i] + nums[i])

S.sort()
ans = 0
p = S[0]
c = Counter(S)

for i in range(1, n+1):
    if i == n or S[i] != p:
        x = c[p]
        ans += x * (x-1) // 2
        p = S[i]


print(ans)

Measured memory_bytes: 41696
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int N;
int h[100001];
LL dp[100001];

LL solve(int now){
	if(now == N-1) return 0;
	if(now >= N) return INT_MAX;
	if(dp[now] != INT_MAX) return dp[now];
	return dp[now] = min((LL)INT_MAX, min(abs(h[now]-h[now+1]) + solve(now+1), abs(h[now]-h[now+2]) + solve(now+2)) );
}

#undef int

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	h[N] = 0;
	cout << solve(0) << endl;

	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	set<string> cnt;
	char pre='A';
	bool flag=true;
	rep(i,n){
		string w;
		cin>>w;
		if(i && w[0]!=pre) flag=false;
		if(cnt.count(w)) flag=false;
		pre=w.back();
		cnt.insert(w);
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import accumulate, product

# 各重さごとに価値降順でソート
# とっていく
# 重さ合計は w0 * k ~ (w0 + 3) * kのどれか N=100だと15000通りくらい

def solve(N: int, W: int, ws: "List[int]", vs: "List[int]"):
    w0 = ws[0]
    items = [[] for _ in range(4)]
    accum = [[] for _ in range(4)]
    for w, v in zip(ws, vs):
        items[w-w0].append(v)
    for i in range(4):
        items[i].sort(reverse=True)
        accum[i] = [0] + list(accumulate(items[i]))
    count = [len(items[i]) for i in range(4)]
    
    res = 0
    for nums in product(*[range(count[i] + 1) for i in range(4)]):
        w = sum((w0+i) * nums[i] for i in range(4))
        if w > W:
            continue
        v = sum(accum[i][nums[i]] for i in range(4))
        res = max(v, res)
    
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44780
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 1;
        while (true) {
            int num = sc.nextInt();
            if (num == 0) {
                break;
            }
            System.out.println("Case " + cnt + ": " + num);
            cnt++;
        }
    }
}


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

int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  --a; --b; --c; --d;

  bool sunuke = true;
  bool funuke = true;
  for (int i = a; i < c; ++i) if (s[i] == '#' && s[i+1] == '#') sunuke = false;
  for (int i = b; i < d; ++i) if (s[i] == '#' && s[i+1] == '#') funuke = false;

  bool poss;
  if (c == d) poss = false;
  else if (c < d) {
    if (sunuke && funuke) poss = true;
    else poss = false;
  } else {
    bool skip = false;
    for (int i = b; i <= d; ++i) if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') skip = true;
    if (sunuke && funuke && skip) poss = true;
    else poss = false;
  }
  if (poss) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3704
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#define MAX 10030
using namespace std;
typedef long long lld;
typedef pair<int,int> pii;
int a[MAX],b[MAX];
lld chc1,chc2;
int main(){
    int i,n,t;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) scanf("%d",&b[i]);
    for(i=0;i<n;i++) a[i]-=b[i];
    sort(a,a+n);
    for(i=n-1;i>=0&&a[i]>0;i--) chc1+=(lld)a[i];
    for(;i>=0;i--) chc2+=(lld)(-a[i])/2;
    if(chc1>chc2) printf("No\n");
    else printf("Yes\n");
    //printf("%lld %lld\n",chc1,chc2);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

template<int mod>
struct ModInt{
    int x;

    ModInt() : x(0) {}
    
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    
    ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    
    ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    
    ModInt operator-() const {return ModInt(-x);}

    ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}

    ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}

    ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}

    ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

    bool operator==(const ModInt &p) const {return x == p.x;}

    bool operator!=(const ModInt &p) const {return x != p.x;}

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const{
        ModInt ret(1), mul(x);
        while(n > 0){
            if(n & 1)   ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a){
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() {return mod;}
};

using modint = ModInt<mod>;

int n, k;
vector<int> a;
modint dp[105][100005];

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

    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];

    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= k; ++j){
            if(dp[i][j] == 0)   continue;

            dp[i + 1][j] += dp[i][j];
            int next = min(k, j + a[i]);
            dp[i + 1][next + 1] -= dp[i][j];
        }

        for(int j = 0; j <= k; ++j) dp[i + 1][j + 1] += dp[i + 1][j];
    }

    cout << dp[n][k] << endl;
}

Measured memory_bytes: 41216
#include<iostream>

using namespace std;

char getGrade( int m, int f, int r){

	int sum = m + f;

	char grade;

	if( m == -1 || f == -1) {

		grade = 'F';

	}	else if ( 80 <= sum) {

		grade = 'A';

	}	else if( 65 <= sum && sum < 80) {

		grade = 'B';

	}	else if( 50 <= sum && sum < 65) {

		grade = 'C';

	}	else if ( 30 <= sum && sum < 50) {

		if( 50 <= r) grade = 'C';

		else grade = 'D';

	}	else if (sum < 30) {

		grade = 'F';

	}

	return grade;

}

int main(){

	int m, f, r;

	while(1) {

		cin >> m >> f >> r;

		if( m == -1 && f == -1 && r == -1) break;

		cout << getGrade(m, f, r) << endl;

	}

	return 0;

}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int S[100],top;
void push(int x);
int pop(void);
int main(void){
    char s[100];
    int a,b;
    top=0;
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(b+a);
        }
        else if(s[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }
        else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else{
            push(atoi(s));
        }
    }
    printf("%d\n",S[1]);
    return 0;
}
void push(int x){
    S[++top]=x;
}
int pop(void){
    top--;
    return S[top+1];
}

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

int main()
{
    int n, ans=0, sum=0;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++)
    {
        if(s[i]=='I') sum++;
        else ans=max(ans, sum), sum--;
    }
    ans=max(ans, sum);
    cout << ans;
}


Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

vector<vector<int> > dp(100001, vector<int>(2,0));
vector<int> a(100,0);
int N,K;

int dfs(int num, int rest){
    if (rest<0){
        return (num%2) ? 2 : 1;
    }
    if (dp[rest][num%2]!=0){
        return dp[rest][num%2];
    }
    int ret;
    if (num%2){
        ret=1;
    }else{
        ret=2;
    }

    for(int i=0; i<N; i++){
        int s=dfs(num+1, rest-a[i]);
        if(s!=ret){
            dp[rest][num%2]=s;
            return s;
        }
    }
    dp[rest][num%2]=ret;
    return ret;
}

int main(){
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    if (dfs(0,K)==1){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,l,ans=0;
    cin>>n>>l;
    int mi = l;
    for(int i = 0; i < n; i++)
    {
        ans+=l+i;
        if(abs(mi) > abs(l+i))
        {
            mi=l+i;
        }
    }
    ans-=mi;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <bitset>
#include <set>
#include <vector>

using namespace std;
#define LL long long int
#define mod  1000000007

//Func
LL powmod3(LL a,LL b,LL m) {LL res=1;a%=m;for(;b;b>>=1){if(b&1)res=res*a%m;a=a*a%m;}return res;}
LL powmod2(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
LL gcd(LL a,LL b){if(a==0)return(b);else return(gcd(b%a,a));}




int main() {
    ios_base::sync_with_stdio(false);
    int n;LL y;
    LL a = 10000,b=5000,c=1000;
    cin>>n>>y;
    int t = n;
    for(int i = 0; i<=n; i++){
        for(int j = 0; j<=n; j++){
            if((i*a) + (j*b) + abs(t-i-j)*c == y && i+j+abs(t-i-j)<=n){
                cout<<i<<" "<<j<<" "<<abs(t-i-j);
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF= 1LL << 60;

int main() {
    int n; cin >> n;
    int c=0;
    int ans=0;
    for (int i=0;i<2*n;i+=2){
        int a,s; cin >> a >> s;
        if (a==s) c++;
        else c=0;
        if (c==3){
            ans=1;
        }
    }
    if (ans==1){
        cout << "Yes" << "\n";
        return 0;
    }
    cout << "No" << "\n";
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <math.h>

int main(void){
    // Your code here!
    long N, maxyakusu = 1;
    scanf("%ld\n", &N);
    for(long i = 1; i <= (long)sqrt(N); i++)
    {
        if(N%i == 0)
            maxyakusu = i;
    }
    printf("%ld\n", maxyakusu+N/maxyakusu-2);
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] A = GetInts(N);

		var list = new Tuple<int, int>[N];
		for(int i = 0; i < N; i++)
			list[i] = Tuple.Create(i, A[i]);

		Array.Sort(list, (x, y) => x.Item2 - y.Item2);
		string[] ans = new string[N];
		for(int i = 0; i < N; i++)
			ans[i] = (list[i].Item1 + 1).ToString();

		Console.WriteLine(string.Join(" ", ans));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 32600
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x, a, b = map(int, readline().split())

    if abs(x - a) < abs(x - b):
        print("A")
    else:
        print("B")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61608
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        while(true){
        int a=sc.nextInt();
        String x=sc.next();
        int b=sc.nextInt();
        if(x.equals("+"))System.out.println(a+b);
        if(x.equals("-"))System.out.println(a-b);
        if(x.equals("*"))System.out.println(a*b);
        if(x.equals("/"))System.out.println(a/b);
        if(x.equals("?"))break;
        }
        sc.close();
    }
}



Measured memory_bytes: 26172
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long INT;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	INT x,sum=100,ct=0; cin >> x;

	while (sum < x) {
		sum = 1.01*sum;
		ct++;
	}
		
	cout << ct << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <cassert>
#define MOD 1000000007
#define SIZE 200005

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

ll inv[SIZE],fac[SIZE],finv[SIZE];
ll rt[SIZE];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
	rt[0]=1;
	for(int i=1;i<SIZE;i++) rt[i]=rt[i-1]*inv[2]%MOD;
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
	make();
	int B,W;
	scanf("%d %d",&B,&W);
	ll pb=0,pw=0;
	for(int i=1;i<=B+W;i++)
	{
		printf("%lld\n",(pb+(1LL-pb-pw+2LL*MOD)%MOD*inv[2]%MOD)%MOD);
		pb+=rt[i]*C(i-1,W-1)%MOD;
		pw+=rt[i]*C(i-1,B-1)%MOD;
		if(pb>=MOD) pb-=MOD;
		if(pw>=MOD) pw-=MOD;
	}
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

//添え字が素数でないならfalseにする
void eratosthenes(vector<bool> &v,ll N){//０もとってある
    v.at(1)=false;
    for(ll i=2;i < N+1;i++){
        if(v.at(i)==true){
            for(ll j=2*i;j < N+1;j += i){//Nを宣言してなかった、注意
                v.at(j) = false;
            }
        }
    }
}//エラトステネスの篩 添え字が素数ならtrueのまま 素数でないならfalseに変える

vector<ll> finddivisor(ll x){//整数xの約数が入ったvectorを返すよ(xを含む)  
    vector<ll> divisor;
    for(ll i=1; (i*i)<=x ;i++)
    {
        if(x%i==0){
            divisor.push_back(i);
            if(i*i!=x){
                divisor.push_back(x/i);
            }//約数はペアを持つことを利用

        }
    }
    sort(divisor.begin(),divisor.end());
    //divisor.push_back(x);
    return divisor;
}

signed main(){
    ll n;
    cin>>n;
    vector<bool> p(n+1,true);//添え字が素数かどうか
    eratosthenes(p,n);

    ll s=0,f=0,ft=0,tf=0,sf=0,ans=0;//^2の数、^4の数

    vector<ll> w(n+1,0);//個数カウント

    for(ll i=2;i <= n;i++)//iの素因数の個数をカウントしたい
    {
       for(ll j=2;j <= n || j<=i;j++)
       {
           if(p.at(j)){
                ll x=i;
                while(x%j==0){
                    w.at(j)++;
                    if(w.at(j)==2){
                        s++;
                    }else if(w.at(j)==4){
                        f++;
                    }else if(w.at(j)==14){
                        ft++;
                    }else if(w.at(j)==24){
                        tf++;
                    }else if(w.at(j)==74){
                        sf++;
                    }
                    x/=j;
                }
           }
       }
    }

    
        ans+=f*(f-1)/2 *(s-2);//
        ans+=tf*(s-1);
        ans+=ft*(f-1);
        ans+=sf;
        cout << ans << endl;
        //cout << s<<":"<<f<<":"<<ft<<":"<<tf <<":"<<sf<< endl;
    

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.Stream;


public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        int x = sc.nextInt();
        String ars = sc.nextLine();
        int[] arr = Stream.of(ars.split(" ")).mapToInt(Integer::parseInt).toArray();
        int min = 99999999;
        for (int i = 1; i <= 100; i++) {
            int sum  = 0;
            for (int n : arr) {
                sum += ((n - i) * (n - i));
            }
            if(sum<min){
                min = sum;
            }
        }
        System.out.println(min);

    }

    static int getDigit(int n, int d) {
        return n / d != 0 ? 1 + getDigit(n / d, d) : 1;
    }

    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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


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

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

#pragma region segmenttree
template <typename T, typename F>
struct SegmentTree {
    int N;
    const int sz;
    const T ID;
    const F f;
    vector<T> cbt;
    SegmentTree(int n, T ID, F func) : sz(n), ID(ID), f(func) { init(sz); }
    SegmentTree(vector<T> V, T ID, F func)
        : sz(V.size()), ID(ID), f(func) {
        init(sz);
        for (int i = 0; i < sz; ++i)
            cbt[i + N] = V[i];
        for (int i = N - 1; i >= 1; --i)
            cbt[i] = f(cbt[i << 1 | 0], cbt[i << 1 | 1]);
    }
    void init(int n) {
        N = 1;
        while (N < n) N <<= 1;
        cbt.assign(N << 1, ID);
    }
    void update(int idx, T val) {
        idx += N;
        cbt[idx] = val;
        while (idx >>= 1) cbt[idx] = f(cbt[idx << 1 | 0], cbt[idx << 1 | 1]);
    }
    T query(int l, int r) {
        T ret_l = ID, ret_r = ID;
        l += N, r += N;
        while (l < r) {
            if (l & 1) ret_l = f(ret_l, cbt[l++]);
            if (r & 1) ret_r = f(cbt[--r], ret_r);
            l >>= 1, r >>= 1;
        }
        return f(ret_l, ret_r);
    }
    T const& operator[](int idx) const { return cbt[idx + N]; }
    void print() {
        cerr << "*** DEBUG PRINT ***" << endl;
        cerr << " N : " << N << endl;
        cerr << "sz : " << sz << endl;
        int idx = 1;
        while (idx < 2 * N) {
            for (int i = idx; i < 2 * idx; ++i) cerr << cbt[i] << " \n"[i == 2 * idx - 1];
            idx <<= 1;
        }
    }
};
template <typename T, typename F>
auto make_segment_tree(int N, T ID, F func) {
    return SegmentTree<T, F>(N, ID, func);
}
template <typename T, typename F>
auto make_segment_tree(vector<T> V, T ID, F func) {
    return SegmentTree<T, F>(V, ID, func);
}
#pragma endregion

const int MX = 300300;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto& e : A) cin >> e;

    auto dp = make_segment_tree(vector<int>(MX, 0), 0, [](int a, int b) { return max(a, b); });

    for (auto& e : A) {
        int l  = max(0, e - K);
        int r  = min(MX - 1, e + K);
        int nw = dp.query(l, r + 1) + 1;
        if (dp[e] < nw) dp.update(e, nw);
    }

    cout << dp.query(0, MX) << endl;
}


Measured memory_bytes: 10904
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	cout<<(n+1)/2<<endl;
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    cout << A.back() - A[0] << endl;


    return 0;
}


Measured memory_bytes: 256
n, r, t = gets.chomp.split.map(&:to_i)
runners = []
n.times{
    p = gets.to_i
    runners << [0, p, 0]
}
points = Array.new(r){[0, 0]}

sum = 0
t.times{
    for i in 0...r
        points[i][0] = 0 if points[i][0] < 0
        points[i][0] += points[i][1]
        points[i][1] = 0
    end
    for i in 0...n
        point = (runners[i][0] + runners[i][1]) % r
        points[point][0] -= 1
        points[point][1] += runners[i][2]
        runners[i][0] = point
        runners[i][2] = 1
        sum += 1 if points[point][0] < 0
    end
}
puts sum


Measured memory_bytes: 8912
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n, m; cin >> n >> m;
    vector<int> step(n + 1, 1);
    for(int i = 0; i < m; i++) {
        int a; cin >> a;
        step[a] = 0;
    }

    const int mod = 1000000007;
    for(int i = n - 2; i >= 0; i--) {
        if(!step[i]) continue;
        step[i] = (step[i + 1] + step[i + 2]) % mod;
    }

    cout << step[0] << endl;
}


Measured memory_bytes: 1024