akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int n;
long long A[200000];
long long calc(int b){
    long long ans = 0;
    for(int i = 0; i < n; i++){
        ans += abs(A[i] - (b + i + 1));
    }
    return ans;
}

int main(){
    
    cin >> n;
    long long maxint = 0;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        maxint = max(maxint,A[i]);
    }
    long long  l = -1000000000;
    long long  r = 1000000000;
    while(abs(l - r) > 1){
        long long next = (l + r) / 2;
        long long tmp1 = calc(next);
        long long tmp2 = calc(next+1);
        if(tmp1<tmp2){
            r = next;
        }else{
            l = next + 1;
        }
    }
    cout << min(calc(l),calc(r)) << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a[100];
double sum,absmin = INF;

signed main() {
    cin >> n;
    rep(i,n) cin >> a[i],sum+=a[i];
    sum /= n;
    rep(i,n) absmin = min(absmin,abs(a[i]-sum));
    rep(i,n) if (a[i] + absmin == sum || a[i] - absmin == sum) {cout << i << endl;return 0;}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 int n;
 long long k;
 scanf("%d  %lld",&n , &k);
  
  long long s[100001] = {0}; 
  int  a , b;
  for(int i = 0;i < n;i ++){
    scanf("%d  %d",&a,&b);
    s[a] += b;
  }
  
  long long nagasa = 0;
  int  ans = 0;
  for(int i = 1;i <= 100000;i ++){
    nagasa += s[i];
    if(nagasa >= k){
      ans = i;
      break;
      
    }
  }
  
  printf("%d",ans);
  return 0;
}


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

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

  int n, x;
  cin >> n >> x;

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

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    if(i == n-1 && a[i] < x){
      break;
    }else if(a[i] <= x){
      x -= a[i];
      ans++;
    }else{
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  const int Mod = 1000000000+7;
  int n;
  cin >> n;
  long long a[3*100000+10];
  long long b[65];
  
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int j=0; j<62; j++){
    b[j]=0;
  }
  
  for(int i=0; i<n; i++){
    for(int j=0; j<62; j++){
      b[j] += ((a[i] >> j) & 1);
    }
  }
  long long ans = 0;
  long long p = 1;
  for(int j=0; j<62; j++){
    long long x = b[j]*(n-b[j])%Mod;
    ans = (ans + p*x)%Mod;
    //cout << p << " " << b[j] << " " << ans << endl; 
    p = (p*2)%Mod;
  }
  cout << ans;
  

}
 


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

public class my
{
	private static StringBuilder sb = new StringBuilder();
	
	public static void Main()
	{
		var str = Console.ReadLine().Split(' ');
		
		Stack myStack = new Stack();
		
		long ret = 0;
		
		foreach(var s in str) {
			long tmp;
			
			switch(s) {
				case "+":
					tmp = myStack.Pop();
					ret = myStack.Pop() + tmp;
					myStack.Push(ret);
					break;
				case "-":
					tmp = myStack.Pop();
					ret = myStack.Pop() - tmp;
					myStack.Push(ret);
					break;
				case "*":
					tmp = myStack.Pop();
					ret = myStack.Pop() * tmp;
					myStack.Push(ret);
					break;
				case "/":
					tmp = myStack.Pop();
					ret = myStack.Pop() / tmp;
					myStack.Push(ret);
					break;
				default:
					if(long.TryParse(s, out tmp)) {
						myStack.Push(tmp);
					}
					break;
			}
		}
		
		Console.WriteLine(ret);
	}
	
	private static void Flush()
	{
		Console.Write(sb);
		sb.Length = 0;
	}
	
	private static void AppendLine(int v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(long v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(string[] v)
	{
		sb.AppendLine(string.Join(" ", v));
	}
	
	private static void Swap(ref string a, ref string b) 
	{
		string tmp = a;
		a = b;
		b = tmp;
	}
	
	private static void Swap(ref int a, ref int b) 
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static long GetLong()
	{
		return long.Parse(Console.ReadLine());
	}
}

public class Stack
{
	private List<long> val;
	
	public Stack()
	{
		val = new List<long>();
	}
	
	public void Push(long v)
	{
		val.Add(v);
	}
	
	public long Pop()
	{
		long ret = val.Last();
		val.RemoveAt(val.Count() - 1);
		return ret;
	}
}

Measured memory_bytes: 9592
#include<bits/stdc++.h>
#define M 100002
using namespace std;
int A[M];
multiset<int>Q;
multiset<int>::iterator it;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	for(int i=1;i<=n;i++){
		if(Q.empty())Q.insert(A[i]);
		else {
			it=Q.lower_bound(A[i]);
			if(it==Q.begin()){
				Q.insert(A[i]);
				continue;
			}
			it--;
			Q.erase(it);
			Q.insert(A[i]);
		}
	}
	printf("%d\n",Q.size());
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    int X;
    cin >> X;
    cout << lcm(X, 360) / X << endl;


    solve();
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using lint=long long;
inline lint msb(lint x){
    x|=x>>1;x|=x>>2;x|=x>>4;
    x|=x>>8;x|=x>>16;x|=x>>32;
    return x^x>>1;
}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint all=std::accumulate(a.begin(),a.end(),0ll,std::bit_xor<>{});
    for(lint&x:a)x&=~all;
    for(lint i=0;i<n;i++){
        std::swap(a.at(i),*std::max_element(a.begin()+i,a.end()));
        if(!a.at(i))break;
        lint test=msb(a.at(i));
        for(lint j=0;j<n;j++){
            if(j==i||!(a.at(j)&test))continue;
            a.at(j)^=a.at(i);
        }
    }
    lint max=std::accumulate(a.begin(),a.end(),0ll,std::bit_xor<>{});
    std::cout<<(all^max)+max<<'\n';
}


Measured memory_bytes: 1024
#include <stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF (-1000)

int n;
int d[MAX],c[MAX],M[MAX][MAX];
int Q_tail=0,Q_head=0,Q[MAX];

void enqueue(int s)
{
  Q[Q_tail]=s;
  if(Q_tail + 1 == n)
  Q_tail=0;
  else Q_tail++;
}

int dequeue()
{
  int x;
  x=Q[Q_head];
  if(Q_head+1==n) Q_head=0;
  else Q_head++;
  return x;
}

void bfs(int s)
{
  int u;

  enqueue(s);
  for(int i=0;i<n;i++)
  {
    d[i]=INF;
  }
  d[s]=0;
  while(Q_tail!=Q_head)
  {
    u=dequeue();
    for(int v=0;v<n;v++)
    {
      if(M[u][v]&&c[v]==WHITE)
      {
        c[v]=GRAY;
        d[v]=d[u]+1;
        enqueue(v);
      }
      c[u]=BLACK;
    }
  }

  for(int i=0;i<n;i++)
  {
    printf("%d ",i+1);
    if(d[i]==INF) printf("-1\n");
    else printf("%d\n",d[i]);
  }
}

int main()
{
  int u;
  int k;
  int v;

  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      M[i][j]=0;
    }
  }

  for(int i=0;i<n;i++)
  {
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++)
    {
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 2136
#![allow(dead_code)]
use std::io::*;

fn main(){
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut cnt = 0;
    for i in 1..n + 1{
        if a[i - 1] != i {
            cnt += 1;
        }
    }
    let ans = if cnt == 0 || cnt == 2 {"YES"} else {"NO"};
    println!("{}", ans);
}

fn upper_bound(a: &Vec<i32>, x: &i32) -> Option<usize>
{
    let mut ok: isize = a.len() as isize;
    let mut ng: isize = -1;
    if ok == 0 || a[ok as usize - 1] <= *x{
        None
    }else{
        while (ng - ok).abs() > 1{
            let mid = (ok + ng) / 2;
            if a[mid as usize] > *x{
                ok = mid;
            }else{
                ng = mid;
            }
        }
        Some(ok as usize)
    }
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

#define ll long long

using namespace std;

const int MAXN = 1e5 + 10;
const int MAXM = 1e5 + 10;
const int INF = 0x3fffffff;
const int MOD = 1e9 + 7;

int n, m, k;
int tot, cnt, ans;

int a[MAXN];

string s;

int main() {
	int T;
	char c;
	cin >> c;
	if ('a' <= c && c <= 'z') cout << 'a' << endl;
	else cout << 'A' << endl;
	return 0;
}


Measured memory_bytes: 3624
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

N, K = [int(x) for x in input().split()]

treat = [0] * N

for k in range(K):
    input()
    P = [int(x) for x in input().split()]
    for p in P:
        treat[p-1] = 1

print(N-sum(treat))


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  cout << (b/x) - (a/x) + (a%x==0) << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(m)]
p = list(map(int,input().split()))
res = 0

for i in range(2**n):
    res+=1
    for j in range(len(arr)):
        on = 0
        for k in range(arr[j][0]):
            on += (i>>(arr[j][k+1]-1))%2
        if (on%2 != p[j]):
            res -=1
            break
print (res)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long

using namespace std;


//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
// vector<int> v(1000);

long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  int N;
  cin>>N;
  int a[N+10];
  int b[N+10];
  vector<int> v;
  
  rep(i, N) cin >> a[i+1];

  int tmp_sum=0;
  int M=0;
  b[N] = a[N];
  for(int i=N;i>0;i--){
    b[i] = a[i];
    tmp_sum = 0;
    for(int j=i;j<=N;j+=i){
      tmp_sum += b[j];
    }
    if(tmp_sum % 2==a[i]){
      if(a[i]==1){
        b[i]=1;
        v.push_back(i);
        M++;
      }else{
        b[i]=0;
      }
    }else{
      if(a[i]==0){
        b[i]=1;
        v.push_back(i);
        M++;
      }else{
        b[i]=0;
      }
    }
  }

  int count=0;
  cout << M << endl;
  for(int x : v){
    if(count==(M-1)){
      cout << x;
    }else{
      cout << x << " ";
    }
    count++;
  }
  if(M>0) cout << endl;
  return 0;
}


Measured memory_bytes: 4980
#include "bits/stdc++.h"
    using ll = long long;
    using namespace std;
    int main(){
    string a;
    cin>>a;
    ll ans =700;
    for(ll i=0;i<3;i++){
    if(a[i]=='o')
    ans+=100;
    }
    cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main(){
	LL x;
	cin>>x;
	
	for(LL i=0;i<1000;i++)
	{
		for(LL j=0;j<1000;j++)
		{
			if(i*i*i*i*i-j*j*j*j*j==x)
			{
				cout<<i<<" "<<j<<"\n";
				i=1000;
				break;
			}
			if(i*i*i*i*i+j*j*j*j*j==x)
			{
				cout<<i<<" "<<-j<<"\n";
				i=1000;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


const int MOD = 998244353;
long long dp[210000][4][4][3]; // (mod 3, last, already)

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

long long solve(const string &S) {
    set<char> se;
    bool exist_ren = false;
    long long smod = 0;
    for (int i = 0; i < S.size(); ++i) {
        se.insert(S[i]);
        smod = (smod + (S[i] - 'a')) % 3;
        if (i + 1 < S.size() && S[i] == S[i+1]) exist_ren = true;
    }

    if (se.size() == 1) return 1;
    else if (S.size() == 2) return 2;
    else if (S.size() == 3) {
        if (se.size() == 3) return 3;
        else if (S[0] == S[2]) return 7;
        else return 6;
    }
    
    memset(dp, 0, sizeof(dp));
    for (int last = 0; last < 3; ++last) {
        dp[1][last][last][0] = 1;
    }
    for (int i = 1; i < S.size(); ++i) {
        for (int sum = 0; sum < 3; ++sum) {
            for (int last = 0; last < 3; ++last) {
                for (int last2 = 0; last2 < 3; ++last2) {
                    add(dp[i+1][(sum+last2)%3][last2][1], dp[i][sum][last][1]);
                    add(dp[i+1][(sum+last2)%3][last2][last==last2], dp[i][sum][last][0]);
                }
            }
        }
    }
    long long res = (exist_ren ? 0 : 1);
    for (int last = 0; last < 3; ++last) add(res, dp[S.size()][smod][last][1]);
    return res;
}

int main() {
    string S; cin >> S;
    cout << solve(S) << endl;
}










Measured memory_bytes: 82484
import sys
input = sys.stdin.readline

n,q = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(n-1)]
PX = [tuple(map(int, input().split())) for i in range(q)]
#print(AB)

C = [[] for i in range(n)] #Cはグラフ表示
for a,b in AB:
  C[b-1].append(a-1)
  C[a-1].append(b-1)
Q = [0] * n
for p,x in PX:
  Q[p-1] += x
#print(Q)
  
STACK = [0]
VISITED = [0] * n
ANS = [0] * n
ANS[0] = Q[0]
VISITED[0] = 1

while STACK:
  d = STACK.pop()
  for i in C[d]:
    if VISITED[i]:
      continue
    else:
      VISITED[i] = 1
      ANS[i] = ANS[d] + Q[i]
      STACK.append(i)

print(*ANS)

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

const int MX = 100005;

int main(){
	int n, q;
  	cin >> n;
  	vector<ll> cnt(MX);
  	rep(i, n){
    	int a;
      	cin >> a;
      	cnt[a]++;
    }
  	ll tot = 0;
  	rep(i, MX) tot += i*cnt[i];
  
  	cin >> q;
  	rep(i, q){
    	int b, c;
      	cin >> b >> c;
 
      	tot -= b * cnt[b];
      	tot -= c * cnt[c];
      	
      	cnt[c] += cnt[b];
      	cnt[b] = 0;
      	
      	tot += c * cnt[c];
      
      	cout << tot << endl;
    }
}

Measured memory_bytes: 4052
n=int(input())

s_list=[]

for i in range(n):
    s,p=input().split()
    p=int(p)*(-1)
    s_list.append([s,p,i+1])
#print(s_list)
s_list.sort()
#print(s_list)

for i in s_list:
    print(i[2])

    

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<int> G[n];//辺
  for(int i=0;i<n;i++)cin>>h[i];
  for(int i=0;i<m;i++){
    int a, b;
    cin >> a >> b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    bool flag = true;
    for(auto a:G[i]){
        if(h[a]>=h[i])flag = false;
    }
    if(flag)ans++;    
  }
    
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8700
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H,W,K=map(int,input().split())
    S=[[] for _ in range(H)]
    for i in range(H):
        S[i]=list(map(int,list(input())))
    ans=INF
    for i in range(2**(H-1)):
        f=True
        tmp=0
        wari=0
        d={}
        d[0]=0
        for j in range(H-1):
            if (i>>j)&1:
                tmp+=1
            d[j+1]=tmp
        wari+=tmp
        l=[0]*H
        for yoko in range(W):
            f=False
            for tate in range(H):
                if S[tate][yoko]:
                    l[d[tate]]+=1
                    if l[d[tate]]>K:
                        wari+=1
                        l=[0]*H
                        f=True
                        break
            if f:
                f2=False
                for tate in range(H):
                    if S[tate][yoko]:
                        l[d[tate]]+=1
                        if l[d[tate]]>K:
                            f2=True
                            break
                if f2:
                    wari=INF
                    break
        ans=min(ans,wari)
    print(ans)
                    
            
            

if __name__ == '__main__':
    main()


Measured memory_bytes: 44012
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,k;
char st[1001];
int main(){
    cin>>st;
    n=strlen(st);
    int ans=0;
    for (i=0;i<n-1;i++)
      for (j=i+1;j<n;j++)
       if (st[i]=='C' && st[j]=='F') ans++;
    if (ans!=0) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a==5 && b==5 && c==7 || a==5 && b==7 && c==5 || a==7 && b==5 && c==5)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
a=Counter(v[::2])
a[0]=0
a=a.most_common()
b=Counter(v[1::2])
b[0]=0
b=b.most_common()
if a[0][0]!=b[0][0]:
  print(n-a[0][1]-b[0][1])
else:
  print(n-max(a[0][1]+b[1][1],a[1][1]+b[0][1]))

Measured memory_bytes: 20572
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <time.h>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;

int main()
{
	int x; cin >> x;
	x = 1 - x;
	cout << x << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,n;
	cin >> h >> n;
	for (int z=0;z<n;z++){
		ll temp;
		cin >> temp;
		h -= temp;
	}
	if (h <= 0) cout << "Yes" << endl;
	else cout << "No" << endl;
} 
 


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

int main()
{
    LL n,total,i,j,k;
    cin>>n>>total;
    LL weight[n+1],value[n+1];
    LL dp[total+1][n+1];
    LL maxima[total+1][n+1];
    for(i=1;i<=n;i++)
    {
        cin>>weight[i]>>value[i];
        //cout<<i<<" "<<weight[i]<<" "<<value[i]<<endl;
    }  

    for(i=0;i<=total;i++)
    {
        for(j=0;j<=n;j++)
        {
            dp[i][j]=0;
            maxima[i][j]=0;     
        }
    }
    for(i=1;i<=total;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(i-weight[j]>=0)
            {
                dp[i][j]=value[j]+maxima[i-weight[j]][j-1];                 
            }          
            maxima[i][j]=max(maxima[i][j-1],dp[i][j]); 
        }
    } 
    cout<<maxima[total][n]<<endl;    
}

Measured memory_bytes: 158080
from heapq import heappush, heappop,heapify
n,m = map(int,input().split())
def minusint(x):
  return -int(x)
a = list(map(minusint,input().split()))
heapify(a)
for _ in range(m):
  ai = heappop(a)*(-1)
  heappush(a,-(ai//2))
print(-sum(a))

Measured memory_bytes: 72088
import math

a, b, h, m = map(int, input().split())
h, m = h * 30 + m / 2, m * 6
angle = abs(h - m)
ans2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle))
print(math.sqrt(ans2))


Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	yorn(n >= 30);
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using namespace std;
 
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main() 

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef vector<V> VV;
const int INF = 1e9;

const int MAX_N = 100010;

int par[MAX_N];
int myrank[MAX_N];

void init(int n)
{
    for (int i=0; i<n; i++) {
        par[i] = i;
        myrank[i] = 0;
    }
}

int find(int x)
{
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (myrank[x] < myrank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (myrank[x] == myrank[y]) myrank[x]++;
    }
}

bool same(int x, int y)
{
    return find(x) == find(y);
}

int N;
int X[100010], Y[100010];
pair<int, int> x[100010];
pair<int, int> y[100010];

struct edge { int u, v, cost; };
bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}
edge es[400010];

signed main()
{
    cin >> N;
    REP(i,N) {
        cin >> X[i];
        x[i].first = X[i];
        x[i].second = i;
        cin >> Y[i];
        y[i].first = Y[i];
        y[i].second = i;
    }

    sort(x, x + N);
    sort(y, y + N);

    REP(i,N-1) {
        edge e;
        e.u = x[i].second;
        e.v = x[i+1].second;
        e.cost = x[i+1].first - x[i].first;
        es[i] = e;
    }
    REP(i,N-1) {
        edge e;
        e.u = y[i].second;
        e.v = y[i+1].second;
        e.cost = y[i+1].first - y[i].first;
        es[N-1+i] = e;
    }

    sort(es, es + 2 * N - 2, comp);
    init(N);
    int res = 0;
    for (int i=0; i<2*N-2; i++) {
        edge e = es[i];
        if (!same(e.u, e.v)) {
            unite(e.u, e.v);
            res += e.cost;
        }
    }

    cout << res << endl;
}


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

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

    int n,k;cin>>n>>k;

    map<int,int> m;

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

    vector<int> a;
    for(auto mm:m)
    {
        a.push_back(mm.second);
    }

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

    int ans=0;

    int sz=a.size();

    for(int i=0;i<sz-k;i++)ans+=a[i];

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 13588
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  lll N;
  cin>>N;
  if(N%2!=0){
    cout<<0<<endl;
    return 0;
  }
  lll t=50;
  lll num2=0;
  while(true){
    num2+= N/t;
    if(N/t==0)break;
    t*=5;
  }
  cout<<num2+N/10<<endl;
      
  return 0;
}


Measured memory_bytes: 256
N = int(input())
seatingPlaces = []
sum_number_of_people = 0

for i in range(N):
    seatingPlaces.append(list(map(int, input().split())))

for onegroup in seatingPlaces:
    number_of_people = onegroup[1] - onegroup[0] + 1
    sum_number_of_people += number_of_people

print(sum_number_of_people)

Measured memory_bytes: 3188
n = int(input())
b = list(map(int,input().split()))
"""
b_i >= max(a_i, a_(i+1))
"""
a = [10**18 for _ in range(n)]
for i in range(n):
	if i == 0:
		a[i] = b[i]
	elif i == n-1:
		a[i] = b[i-1]
	else:
		a[i] = min(b[i], b[i-1])
print(sum(a))

Measured memory_bytes: 3188
N,A,B=map(int,input().split())
H=[int(input()) for _ in range(N)]

def judge(t):
    base_damage=B*t
    add_attack=0
    for hi in H:
        if hi <= base_damage:
            continue
        res=hi-base_damage
        q,r=divmod(res,A-B)
        add_attack+=q
        if r:
            add_attack+=1
    return add_attack<=t

MAX=max(H)
max_attack=MAX//B+1
min_attack=0
while True:
    mid=(min_attack+max_attack)//2
    if mid==min_attack:
        break
    else:
        if judge(mid):
            max_attack=mid
        else:
            min_attack=mid
print(max_attack)

Measured memory_bytes: 7072
from typing import List


def answer(n: int, m: int, ab_s: List[List[int]]) -> List[int]:
    roads = [0 for _ in range(n)]
    for ab in ab_s:
        a, b = ab
        roads[a - 1] += 1
        roads[b - 1] += 1

    return roads


def main():
    n, m = map(int, input().split())
    ab_s = [list(map(int, input().split())) for _ in range(m)]
    for i in answer(n, m, ab_s):
        print(i)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10168
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll N,M;
    ll Ans=0;
    cin>>N>>M;
    vl num(M,0);
    vector<pll> vec(N);
    rep(i,N){
        cin>>vec.at(i).first>>vec.at(i).second;
    }
    sort(all(vec));
    priority_queue<ll> Q;
    ll l=0;
    rep(i,M){
        if(l<N){
        while(vec.at(l).first-1==i){
            Q.push(vec.at(l).second);
            l++;
            if(l==N){
                break;
            }
        }
        }
        if(Q.size()>0){
            ll MAX=Q.top();
            Ans+=MAX;
            Q.pop();
        }
    }
    cout<<Ans<<endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int ans_num, count = 0;
    vector<int> flag_array(M);
    vector<vector <int> > data(N, vector<int>(M));
    for(int i = 0; i < M; i++)
    {
        flag_array.at(i) = 0;
    }
    
    for(int i = 0; i < N; i++)
    {
        cin >> ans_num;
        for(int j = 0; j < ans_num; j++)
        {
            cin >> data.at(i).at(j);
        }
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < M; j++)
        {
            if(data.at(i).at(j) - 1 != -1) flag_array.at(data.at(i).at(j) - 1) += 1;
        }
        
    }
    for(int i = 0; i < M; i++)
    {
        if(flag_array.at(i) == N) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	string s;cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;
	return 0;
}


Measured memory_bytes: 3040
/// How many numbers x are there in the range a to b, where the digit d occurs exactly k times in x?

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

vector<int> num;
int a, b, d, k;
int DP[101][4][2];
//DP[pos][cnt][f];
/// DP[p][c][f] = Number of valid numbers <= b from this state
/// p = current position from left side (zero based)
/// c = number of times we have placed the digit d so far
/// f = the number we are building has already become smaller than  nb? [0 =no, 1 = yes]

int call(int pos, int cnt, int f){
    if(cnt > k) return 0;

    if(pos == num.size()){
        if(cnt == k) return 1;
        return 0;
    }

    if(DP[pos][cnt][f] != -1) return DP[pos][cnt][f];
    int res = 0;

    int LMT;

    if(f == 0){
        /// Digits we placed so far matches with the prefix of b
        /// So if we place any digit > num[pos] in the current position, then the number will become greater than b
        LMT = num[pos];
    } else {
        /// The number has already become smaller than b. We can place any digit now.
        LMT = 9;
    }

    /// Try to place all the valid digits such that the number doesn't exceed b
    for(int dgt = 0; dgt<=LMT; dgt++){
        int nf = f;
        int ncnt = cnt;
        if(f == 0 && dgt < LMT) nf = 1; /// The number is getting smaller at this position
        if(dgt != 0) ncnt++;
        if(ncnt <= k) res += call(pos+1, ncnt, nf);
    }

    return DP[pos][cnt][f] = res;
}

int solve(string &b){
    num.resize(b.size());
    for(int i=0;i<b.size();i++){
    num[i]=b[i]-'0';
    //cout<<num[i]<<" ";
    }
    /// Stored all the digits of b in num for simplicity

    memset(DP, -1, sizeof(DP));
    int res = call(0, 0, 0);
    return res;
}

int main () {

     string str;
     cin>>str;
     
     cin>>k;
    cout<<solve(str);

    return 0;
}

Measured memory_bytes: 256
//

fun main() {
    aising2020c()
}

fun aising2020c() {
    val n = readLine()!!.toInt()
    val count = IntArray(n) {0}
    for (x in 1..98) {
        for (y in 1.. 98) {
            for (z in 1..98) {
                val r = func(x, y, z)
                if (r <= n) {
                    count[r - 1]++
                }
            }
        }
    }
    for (ans in count) {
        println(ans)
    }
}

private fun func(x: Int, y: Int, z: Int): Int {
    return x * (x + y) + y * (y + z) + z * (z + x)
}

Measured memory_bytes: 37612
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int k,f;
    k=n/500;
    f=(n-k*500)/5;
    int ans=k*1000+f*5;
    cout << ans;
    
}

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

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

		String first_line = input.readLine();
		// ?????°??¨?????°?????????
		String[] array_of_li_col = first_line.split(" ");
		// ?????°
		int line = Integer.parseInt(array_of_li_col[0]);
		// ?????°
		int column = Integer.parseInt(array_of_li_col[1]);
		// ??????A???????¬??????????
		int matrix_array_A[][] = new int[line][column];
		// ????????????????????????
		int vector_array_b[] = new int[column];

		// ??????A??????????????°?????°?????????
		for (int line_A = 0; line_A < line; line_A++) {
			String elements_A = input.readLine();
			String[] elements_A_array = elements_A.split(" ");
			for (int column_A = 0; column_A < column; column_A++) {
				// ??\??????????????????A???????´?
				int elements_A_num = Integer.parseInt(elements_A_array[column_A]);
				// ??????A???????¬???????????????\????????????????´????????´?
				matrix_array_A[line_A][column_A] = elements_A_num;
			}

		}
		// ???????????\????????????column?????°??°?????????
		for (int column_b = 0; column_b < column; column_b++) {
			String elements_b = input.readLine();
			int elements_b_num = Integer.parseInt(elements_b);
			// ??????????????????b?????\??????????????°??????????´?
			vector_array_b[column_b] = elements_b_num;
		}
		// ????´?Ci
		int elements_Ci = 0;
		for (int line_A = 0; line_A < line; line_A++) {
			for (int column_A = 0; column_A < column; column_A++) {
				elements_Ci += matrix_array_A[line_A][column_A] * vector_array_b[column_A];
			}
			System.out.println(elements_Ci);
			elements_Ci = 0;
		}

	}//150
}

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

int main() {
	int a,b,c,k; cin>>a>>b>>c>>k;

	if (a>b and a>c)
		for (int i=0; i<k; i++) a*=2;
	else if (b>c and b>a)
		for (int i=0; i<k; i++) b*=2;
	else
		for (int i=0; i<k; i++) c*=2;

	cout << a+b+c << endl;
	return 0;
}

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


int main()
{  
   int n;
   cin>>n;
   vector<int> arr(n+1);
   vector<int> bonus(n);
   ll tot_count = 0 ;
   ll temp;
   for(int i = 0 ; i < n ; i++) cin>>arr[i+1];
   for(int i = 0 ; i < n ; i++) 
   {
       cin>>temp;
       tot_count += temp;
   }
   for(int i = 1 ; i <= n-1 ; i++)
   {
       cin>>bonus[i];
   }
   for(int i = 2 ; i<= n ;i++)
   {
       if(arr[i] == arr[i-1]+1)
       {
           tot_count += bonus[arr[i-1]];
       }
   }
   cout<<tot_count<<endl;
        
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll prime[1001];
    prime[0]=0;
    prime[1]=0;
    ll i,j;
    ll mod =1000000007;
    for(i=2;i<1000;i++){
        prime[i]=1;
    }
    for(i=2;i<1000;i++){
        if(prime[i]==1){
            j=2*i;
            while(j<1000){
                prime[j]=0;
                j+=i;
            }
        }
    }
    ll N;
    cin >> N;
    ll ans=1;
    ll cnt,t;
    for(i=1;i<=N;i++){
        if(prime[i]==1){
            t=i;
            cnt=0;
            while(t<=N){
                cnt+=N/t;
                t=t*i;
            }
            ans=ans*(cnt+1)%mod;
        }
    }
    cout << ans;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = 0;
    for (int k = d[n/2 - 1]; k <= d[n/2]; k++) {
        int m = lower_bound(d.begin(), d.end(), k) - d.begin();
        if (m == n/2) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

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

    for (int i = 0; i < a; i++)
    {
        int v = n[i];
        int j = i - 1;
        while (j >= 0 && n[j] > v)
            n[j + 1] = n[j--];
        n[j+1] = v;
        for (int i = 0; i < a; i++)
            cout << n[i] << (i<a - 1 ? " " : "\n");
    }
}



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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n,k;
int r,s,p;
map<char, int>mp;
ll score = 0;
// void dfs(string hands, int x){
// 	if(x < k)score += mp[hands[x]];
// 	else {
// 		// 条件に反した時→勝ちはない
// 		if(hands[x-k] == hands[x]){
// 			if(hands[x] == 'r'){
// 				if(s > p)hands[x] = 'p';
// 				else hands[x] = 's';
// 			}
// 			if(hands[x] == 's'){
// 				if(p > r)hands[x] = 'r';
// 				else hands[x] = 'p';
// 			}
// 			if(hands[x] == 'p'){
// 				if(r > s)hands[x] = 's';
// 				else hands[x] = 'r';
// 			}
// 		}else{
// 			score += mp[hands[x]];
// 		}
// 	}
// 	dfs(hands, x+1);
// }

ll check(string hands){
	ll ret = 0;
	for(int i = 0; i < hands.size(); i++){
		if(i < k-1)ret += mp[hands[i]];
		else {
			if(hands[i-k] == hands[i])hands[i] = 'x';
			else ret +=  mp[hands[i]];
		}
	}
	return ret;
}

int main(){
	cin >> n >> k;
	cin >> r >> s >> p;
	mp['r'] = r;
	mp['s'] = s;
	mp['p'] = p;
	string t;
	cin >> t;
	string ideal = "";
	for(int i = 0; i < n; i++){
		if(t[i] == 'r')ideal += "p";
		if(t[i] == 's')ideal += "r";
		if(t[i] == 'p')ideal += "s";
	}
	cout << check(ideal) << endl;

}

Measured memory_bytes: 640
#include<stdio.h>

#include <bits/stdc++.h> 

using namespace std; 



int main()

{

int a[3],s=0,i;

for(i=0;i<3;i++)
scanf("%d",&a[i]);

sort(a, a+3);

for(i=0;i<2;i++)
	
  s=s+(a[i+1]-a[i]);


printf("%d\n",s);

return 0;

}


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

class Member {
public:
	int height;
};

int main() {
	Member* mem;
	int N,K,x=0;

	cin >> N >> K;

	mem = new Member[N];

	for (int i = 0; i < N; i++) {
		cin >> mem[N].height;
		if (K <= mem[N].height) {
			x++;
		}
	}
	cout << x << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;
#define inf 1e4+1


int main()
{

	int n;
	std::cin >> n;

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

	vector<int> dp((int)n);
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);

	for (int i = 2; i < n; ++i)
	{
		int abs1 = abs(a[i] - a[i - 1]);
		int abs2 = abs(a[i] - a[i - 2]);
		dp[i] = min(dp[i - 1] + abs1, dp[i - 2] + abs2);
	}

	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    if (a>=1000) {
      System.out.println("ABD");
    } else {
      System.out.println("ABC");
    }
  }
}

Measured memory_bytes: 20820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int l = sc.nextInt();
		int r = sc.nextInt();
		if (r - l >= 2019) {
			System.out.println(0);
		} else {
			long min = Integer.MAX_VALUE;
			long a;
			for (int i = l; i < r; i++) {
				for (int j = l + 1; j <= r; j++) {
					a = ((long) i * j) % 2019;
					min = Math.min(min, a);
				}
			}
			System.out.println(min);
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
bool prime[55555] = {1, 1};
int main()
{
    for (int i = 2; i < 55555; ++i){
        if (!prime[i]){
            for (int j = 2; i * j < 55555; ++j)
                prime[i * j] = 1;
        }
    }
    int n;
    scanf("%d", &n);
    for (int i = 2; n; ++i){
        if (!prime[i] && i % 5 == 2){
            printf(--n ? "%d " : "%d\n", i);
        }
    }
    return 0;
}


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

answer = []
temp_ls = []

for j in [[1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1],[-1, 1, -1], [-1, -1, 1], [-1, -1, -1]]:
    temp_ls = []
    for x in ls:
        temp = 0
        for i in range(3):
            temp += x[i]*j[i]
        temp_ls.append(temp)
    temp_ls.sort(reverse=True)
    temp_ans = 0
    for i in range(M):
        temp_ans += temp_ls[i]
    answer.append(temp_ans)
print(max(answer))


Measured memory_bytes: 3316
def isCLKWISE(ph):
    a = [-ph[-3][0]+ph[-1][0],ph[-1][1]-ph[-3][1]]
    b = [-ph[-3][0]+ph[-2][0],ph[-2][1]-ph[-3][1]]
    crs = b[1]*a[0] - a[1]*b[0]
    if crs < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
 
n = int(input())
P = []
for i in range(n):
    P.append([int(x) for x in input().split()])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

Measured memory_bytes: 33908