akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/dp/tasks/dp_y

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%lld%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int H_MAX = 1e5;
const int W_MAX = 1e5;
const int N_MAX = 3000;
const int MOD = 1e9+7;

//------------------------------------------------------------------------------
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

ll mod_inverse(ll x, ll mod) {
  return mod_pow(x, mod - 2, mod);
}

ll fact[H_MAX + W_MAX + 1];
ll fact_inv[H_MAX + W_MAX + 1];

void init_fact(ll n, ll mod) {
  fact[0] = 1;
  FOR(i, 1, n) fact[i] = fact[i - 1] * i % mod;
  fact_inv[n] = mod_inverse(fact[n], mod);
  for (int i = n; i > 0; i--) fact_inv[i - 1] = fact_inv[i] * i % mod;
}

ll mod_comb_fast(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  ll a = fact[n];
  ll b = fact_inv[k] * fact_inv[n - k] % mod;
  return a * b % mod;
}

//------------------------------------------------------------------------------
int H, W, N;

pair<int, int> rc[N_MAX + 2];
ll dp[N_MAX + 2][2];

ll path_cnt(int i, int j) {
  int h = rc[j].first - rc[i].first;
  int w = rc[j].second - rc[i].second;
  return mod_comb_fast(h + w, h, MOD);
}

void solve() {
  rc[N] = {1, 1};
  rc[N + 1] = {H, W};
  sort(rc, rc + N + 2);
  dp[0][0] = 1;
  dp[0][1] = 0;
  init_fact(H + W, MOD);
  FOR(j, 1, N + 1) {
    REP(i, j) {
      if (rc[j].second < rc[i].second) continue;
      ll cmb = path_cnt(i, j);
      REP(b, 2) {
        dp[j][b] = (dp[j][b] + dp[i][1 - b] * cmb % MOD) % MOD;
      }
    }
  }
  ll ans = (MOD + dp[N + 1][1] - dp[N + 1][0]) % MOD;
  printf("%lld\n", ans);
}

void input() {
  scanf("%d%d%d", &H, &W, &N);
  REP(i, N) {
    int r, c;
    scanf("%d%d", &r, &c);
    rc[i] = {r, c};
  }
}

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


Measured memory_bytes: 3456
S = list(input())

P = set(S)

flag = 0
if len(S) == 26:
    Q = set()
    for i in range(25):
        if ord(S[25 - i]) < ord(S[25 - i - 1]):
            Q.add(ord(S[25 - i]))
            S.pop()
        else:
            while len(Q)>0 and ord(S[25 - i - 1])>min(Q):
                Q.remove(min(Q))
            if len(Q)>0:
                S.pop()
                S.pop()
                S.append(chr(min(Q)))
                flag = 1
                break
            else:
                Z = S[25-i]
                S.pop()
                S.pop()
                S.append(Z)
                flag = 1
                break
else:
    for j in range(26):
        M = chr(97 + j)
        if M in P:
            pass
        else:
            S.append(M)
            flag = 1
            break

if flag == 0:
    print(-1)
else:
    print(''.join(S))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 300005
#define endl "\n"
#define mod 1000000007
ll n,m;
ll ar[N],br[N]; ll dp[2001][2001];
ll maxval(ll i,ll j){
	if(i<=0||j<=0){
		return 0;
	}
	if(dp[i][j]!=-1){
		return dp[i][j];
	}

	if(ar[i]==br[j]){
		return dp[i][j]=(maxval(i-1,j)%mod+maxval(i,j-1)%mod+1)%mod;
	}
	else {
		return dp[i][j]=(maxval(i-1,j)%mod+maxval(i,j-1)%mod-maxval(i-1,j-1)%mod+mod)%mod;
	}
}
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));

	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=1;i<=m;i++){
		cin>>br[i];
	}

	k=(maxval(n,m)%mod+1)%mod;
	cout<<k;
	return 0;
}


Measured memory_bytes: 35456
import itertools
N = int(input())
S = [int(_) for _ in input().split()]

ans = 0
for i in range(1, N - 1):
    maxj = (N - 1) // i
    if (N - 1) % i == 0:
        maxj = ((N - 1) // i + 1) // 2
    dp = itertools.accumulate(
        x + y for x, y in zip(S[:i * maxj:i], S[-1:-1 - i * maxj:-i]))
    ans = max(ans, max(dp))
print(ans)


Measured memory_bytes: 14452
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    getline(cin,s);
    for(int i=0;i < s.size();i++) {
        if(isalpha(s[i])) {
            if(islower(s[i]))
                s[i] = toupper(s[i]);
            else
                s[i] = tolower(s[i]);
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 3228
import math

k=int(input())

count=0

for i in range(1,k+1):
    for j in range(1,i):
        tmp_gcd=math.gcd(i,j)
        for l in range(1,k+1):
            count+=2*math.gcd(tmp_gcd,l)
for i in range(1,k+1):
    for l in range(1,k+1):
        count+=math.gcd(i,l)

print(count)


Measured memory_bytes: 9188
N = gets.to_i
M = 1000
imos = (M+1).times.map{[0] * (M+1)}
$<.map{|s|
  x1, y1, x2, y2 = s.split.map &:to_i
  imos[y1][x1] += 1
  imos[y1][x2] -= 1
  imos[y2][x1] -= 1
  imos[y2][x2] += 1
}
M.times{|y|
  sum = 0
  M.times{|x|
    imos[y][x] = sum += imos[y][x]
  }
}
M.times{|x|
  sum = 0
  M.times{|y|
    imos[y][x] = sum += imos[y][x]
  }
}

p imos.map{|s|s.max}.max

Measured memory_bytes: 18028
#include<stdio.h>

int main(){
	int N, T , A;
	scanf("%d%d%d",&N ,&T ,&A);
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d",&H[i]);
	}
	int x[N];
	int min = 0;
	for(int j=0;j<N;j++){
		x[j] = 1000*T - H[j]*6;
	}
	for(int k=0;k<N;k++){
		if((x[k]>1000*A?x[k]-1000*A:1000*A-x[k]) < (x[min]>1000*A?x[min]-1000*A:1000*A-x[min])){
			min = k;
		}
	}
	printf("%d",min+1);
	return 0;
}	

Measured memory_bytes: 128
N,K = map(int, input().split())
A = [int(a) for a in input().split()]

S = [0]*(N+1)
for i in range(N):
    S[i+1] = S[i] + A[i]

M = 50
memo = [0]*M
L = []
for i in range(N):
    for j in range(i+1, N+1):
        L.append(S[j]-S[i])
        
for n in L:
    for i in range(M):
        if n&(1<<i):
            memo[i] += 1

p = -1
for i in range(M-1, -1, -1):
    if memo[i] >= K:
        p = i
        break

def f(s, List):
    #Listに含まれる要素の中に1<<sとのANDが正になるものがK個以上あるか判定
    L2 = []
    for n in List:
        if n&(1<<s):
            L2.append(n)
            
    mem = [0]*s
    for n in L2:
        for i in range(s):
            if n&(1<<i):
                mem[i] += 1
                
    p = -1
    for i in range(s-1, -1, -1):
        if mem[i] >= K:
            p = i
            break
            
    return [p, L2]
            
if p < 0:
    ans = 0
else:
    ans = 0
    L2 = L
    while p >= 0:
        ans += 1<<p
        t = f(p, L2)
        p = t[0]
        L2 = t[1]
            
print(ans)

Measured memory_bytes: 65916
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

int[] numberConcat(int[] a, int[] b) {
  int[] combinations;
  foreach(i; a) {
    foreach(o; b) {
      combinations ~= i*10 + o;
    }
  }
  return combinations;
}

void main() {
  int N, K; readf("%d %d\n", &N, &K);
  auto Dn = readln.split.to!(int[]).sort;
  auto likeNumbers = 10.iota.filter!(a => !Dn.any!(d => d == a)).array;

  foreach(size; N.to!string.length..6) {
    auto combinations = likeNumbers.dup;
    (size-1).iota.each!(x => combinations = numberConcat(combinations, likeNumbers));
    
    auto answers = combinations.filter!(x => x >= N);
    if (!answers.empty) {
      writeln(answers.front);
      break;
    }
  }
}


Measured memory_bytes: 316
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n,m;
  cin >> n >> m;
  if(n<=m) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()

s = []
for i in range(N):
  tmp = [i for i in S()]
  tmp.sort()
  s.append(tmp)

t = s[0]
for i in range(1,N):
  tt = s[i]
  n = 0
  d = []
  for j in range(len(t)):
    for k in range(n, len(tt)):
      if t[j] == tt[k]:
        d.append(t[j])
        n = k + 1
        break
  else:
    t = d
t.sort()
print("".join(t))

Measured memory_bytes: 39152
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

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

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

const int mod=1000000007;

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,p;scanf("%d%d",&n,&p);
	int s=0;
	for (int i=0;i<n;i++)
    {
        int x;scanf("%d",&x);
        if (x&1) s++;
    }
    ll ans=1;
    for (int i=0;i<n-s;i++) ans*=2;
    if (!s)
    {
        if (p) puts("0"); else printf("%lld\n",ans);
        return 0;
    }
    for (int i=1;i<s;i++) ans*=2;
    printf("%lld\n",ans);
	return 0;
}



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

int main() {

    int n;

    cin >> n;

    vector<int> a;

    for(int i=0; i<n; i++){
        int input;
        cin >> input;
        a.push_back(input);
    }

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

    int ans = 0;

    vector<int>::iterator itr = a.begin();

    while(itr != a.end()){
        int check_num = *itr,count = 0;

        while(check_num == *itr){
            count++;
            itr++;
        }

        if(count > check_num){
            ans += count - check_num;
        }
        else if(count < check_num){
            ans += count;
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 892
N, M = list(map(int, input().split()))
num = [-1]*N
for i in range(M):
  s, c = list(map(int, input().split()))
  if num[s-1] >= 0 and num[s-1] != c:
    num[s-1] = 10
  else:
    num[s-1] = c
if N != 1 and num[0] == 0:
  num[0] = 10
num = [0 if num[i]<0 else num[i] for i in range(N)]
if N != 1 and num[0] == 0:
  num[0] = 1
tmp = 0
for i in range(N):
  tmp += num[i]*10**(N-1-i)
if 10 in num:
  print(-1)
else:
  print(tmp)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char table[2][4];

int main(){

	for(int row = 0; row < 2; row++){
		scanf("%s",table[row]);
	}

	if(table[0][0] == table[1][2] && table[0][1] == table[1][1] && table[0][2] == table[1][0]){

		printf("YES\n");

	}else{

		printf("NO\n");
	}

	return 0;
}


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

int main() {
    int x,y;
    
    cin >> x >> y;
    int sum =1;
    if(y == 1){
        cout << 0 << endl;
    }
    else {
        for(int i =1;i<100;i++) {
        if(i*(x-1)+1<y) {
            sum++;
        }
        else{
            break;
        }
    }
    
    cout << sum <<endl;
    }
}

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

int main() {
    int n, a, max_num = -1000000, min_num = 1000000;
    long long sum = 0;
    cin >> n;
    for (int i = 0; i<n; i++) {
        cin >> a;
        if (a>max_num) max_num = a;
        if (a<min_num) min_num = a;
        sum += a;
    }
    cout << min_num << " " << max_num << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;


int main(){
    i64 X,Y;cin>>X>>Y;
    int cnt=0;
    REP(i,100){
        if(X<=Y){
            X *= 2;
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
s = gets.to_s.split("")

min = 753

for i in 0..s.length - 3 do
  check = (s[i] + s[i + 1] + s[i + 2]).to_i
  value = (753 - check).abs
  min = value if min > value
  break if min == 0
end

puts min

Measured memory_bytes: 1788
n,m=map(int,input().split())
ps=[list(map(str,input().split())) for _ in range(m)]
acwa=[True]*n
wa=[0]*n
ac=0
for P,s in ps:
  p=int(P)-1
  if acwa[p] and s=='WA':
    wa[p]+=1
  elif acwa[p] and s=='AC':
    ac+=1
    acwa[p]=False
for i in range(n):
  if acwa[i]:
    wa[i]=0
print(ac,sum(wa))

Measured memory_bytes: 33688
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = 0;
		if (n>k) {
			ans = k*x+(n-k)*y;
		}else {
			ans = n*x;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main(void)
{
    int n, x, t;
    cin >> n >> x >> t;
    ll r;
    r = (n / x) * t;
    if (n % x != 0)
    {
        r += t;
    }
    cout << r << endl;
}


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

int main() {
    int a1,b1,sum=0;
    cin >> a1 >> b1;
    for(int i = 0; i < b1 - a1 + 1 ; i++){
        int num[5];
        int n,a=0,b;
        n = a1 + i;
        b = n;
        for(int i = 4; i >= 0; i--){
            a = n % (int)pow(10,i);
            num[i] = (b-a)/pow(10,i);
            b = a;
        }
        if(num[4] == num[0] && num[3] == num[1]){
            sum++;
        }
    }
    cout << sum << endl;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a >= 6) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}


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

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

    int internal_stu = 0;
    int international_stu = 0;
    int passed_stu = 0;
    for(size_t i = 0; i < s.size(); i++){
        if(s[i] == 'a') {
            if(passed_stu < a + b){
                internal_stu++;
                passed_stu = internal_stu + international_stu;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else if(s[i] == 'b'){
            if(passed_stu < a + b && international_stu < b){
                international_stu++;
                passed_stu = internal_stu + international_stu;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 3788
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();

            var ans = 0;
            var N = cin.ri();
            for (var i = 0; i < N; ++i)
            {
                var l = cin.ri();
                var r = cin.ri();
                ans += r - l + 1;
            }
            WriteLine(ans);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
        public string r() => Read();
        public int ri() => ReadInt();
        public long rl() => ReadLong();
        public double rd() => ReadDouble();
    }
}


Measured memory_bytes: 13268
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::cmp::Reverse;
use std::collections::*;

fn main() {
    input! {
        tt:usize
    }
    for _ in 0..tt {
        input! {
            n:i64,
            a:i64,
            b:i64,
            c:i64,
            d:i64,
        }
        let divs = vec![(2, a), (3, b), (5, c)];
        let mut dp = BTreeMap::new();
        dp.insert(n, 0);
        let mut heap = BinaryHeap::new();
        heap.push(Reverse((0, n)));
        while let Some(Reverse((sum, now))) = heap.pop() {
            if sum > dp[&now] {
                continue;
            }
            if now < (1e+18 as i64) / d {
                let zero = dp.entry(0).or_insert(std::i64::MAX);
                *zero = std::cmp::min(*zero, sum + d * now);
            }
            if now > 1 {
                for &(div, cost) in divs.iter() {
                    let (next_floor, next_ceil) = (now / div, (now + div - 1) / div);
                    for &next in [next_ceil, next_floor].iter() {
                        let next_ref = dp.entry(next).or_insert(std::i64::MAX);
                        let next_cost = sum + cost + (now - next * div).abs() * d;
                        if next_cost < *next_ref {
                            *next_ref = next_cost;
                            heap.push(Reverse((next_cost, next)));
                        }
                    }
                }
            }
        }
        println!("{}", dp[&0]);
    }
}

Measured memory_bytes: 2628
<?php

fscanf(STDIN, "%d", $in_n);
fscanf(STDIN, "%s", $in_s);

$ans = "No" ;
if($in_n % 2 == 0) {
    $arr_s = str_split($in_s, ($in_n / 2));
    sort($arr_s);
//    var_dump($arr_s);

    if ($arr_s[0] == $arr_s[1]) {
        $ans = "Yes";
    }
}
echo "$ans\n";

?>

Measured memory_bytes: 4732
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Set<String> set = new HashSet<>();
			IntStream.range(0, n).forEach(i -> set.add(scanner.next()));
			System.out.println(set.size());
		}
	}
}


Measured memory_bytes: 77344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    map<int,bool>mp;
    int cnt = 0;
    if (mp[a] == false)cnt++;
    mp[a] = true;
    if (mp[b] == false)cnt++;
    mp[b] = true;
    if (mp[c] == false)cnt++;
    mp[c] = true;
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int sum = 0, i = 0;
		while(sum < x){
			sum +=(i + 1);
			i++;
		}
		System.out.println(i);
	}
}


Measured memory_bytes: 21972
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    L = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = 0
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                    big = max(L[i],L[j],L[k])
                    s = L[i] + L[j] + L[k]
                    if s-big > big:
                        ans += 1
                else:
                    pass
    print(ans)




if __name__ == '__main__':
    solve()


Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;// при желании можно поменять

int main(){
    //ios_base::sync_with_stdio(false);
    //cout<<fixed<<setprecision(20);
    ll a,b;
    cin>>a>>b;
    if(a%2==1)a++;
    a/=2;
    if(a>=b)cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
/**
 * 
 */
import java.util.*;
/**
 * @author afterCmidday
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		final double eps = 1e-10;
		int n;
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for(int i = 0;i < n;i++){
			double x1 = scan.nextDouble(), y1 = scan.nextDouble(), x2 = scan.nextDouble(), y2 = scan.nextDouble();
			double a = x2 - x1, b = y2 - y1;
			double x3 = scan.nextDouble(), y3 = scan.nextDouble(), x4 = scan.nextDouble(), y4 = scan.nextDouble();
			double c = x4 - x3, d = y4 - y3;
			double e = a * d - b * c;
			if(Math.abs(e) < eps){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}

	}

}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	ll D, count = 1e9;
	ll G;
	
	cin >> D >> G;
	
	int p[D+4];
	ll c[D+4];
	
	for(int i=0; i<D; i++)
		cin >> p[i] >> c[i];
	
	for(int i=0; i < (1<<D); i++){
		ll s = 0, num = 0, rest_max = -1;
		for(int j=0; j<D; j++){
			if(i >> j & 1){
				s += 100 * (j+1) * p[j] + c[j];
				num += p[j];
			}else
				rest_max = j;
		}
		if(s < G){
			int s1 = 100 * (rest_max + 1);
			int need = (G - s + s1 - 99) / s1;
			if(need >= p[rest_max])
				continue;
			num += need;
		}
		count = min(count, num);
	}
	
	cout << count;
	
	return 0;
}

Measured memory_bytes: 256
#include <random>

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<ll> a(n), dp(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0] = 1000;
  for (int i = 0; i < n; i++) {
    if(i) dp[i] = dp[i - 1];
    for (int j = 0; j < i; j++) {
      ll cnt = dp[j] / a[j];
      dp[i] = max(dp[i], dp[j] - cnt * a[j] + cnt * a[i]);
    }
    //cout << i << " " << dp[i] << endl;
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 3660
N = int(input())
l = list(map(int, input().split()))
if l == [i+1 for i in range(N)]: # 1, 2, 3, ...
  print(0)
elif 1 not in l:
  print(-1)
else:
  detected = 0
  target = 1
  for i in l:
    if i == target:
      detected += 1
      target += 1
  
  print(N - detected)

Measured memory_bytes: 26140
#include<iostream>
using namespace std;
typedef long long ll;
struct person{ll s,e,d;};
int main(){
  ll n,i,j,k,t,q;
  cin >> n >> t >> q;
  person ps[100001];
  ll p1=-1,p2=-1;
  for(i=0;i<n;i++){
    cin >> ps[i].s >> ps[i].d;
    if(ps[i].d==1) p1=i;
    else{
      ps[i].e=ps[i].s-t;
      if(p1==-1){
      }else if(p2!=-1){
        if(ps[p1].s<ps[p2].s) 
          ps[i].e=max(ps[i].e,ps[p2].e);
        else
          ps[i].e=max(ps[i].e,(ps[i].s+ps[p1].s)/2);
      }else{
        ps[i].e=max(ps[i].e,(ps[i].s+ps[p1].s)/2);
      }
      p2=i;
    }
  }
  p1=-1;p2=-1;
  for(i=n-1;i>=0;i--){
    if(ps[i].d==2) p2=i;
    else{
      ps[i].e=ps[i].s+t;
      if(p2==-1){
      }else if(p1!=-1){
        if(ps[p1].s<ps[p2].s) 
          ps[i].e=min(ps[i].e,ps[p1].e);
        else
          ps[i].e=min(ps[i].e,(ps[i].s+ps[p2].s)/2);
      }else{
        ps[i].e=min(ps[i].e,(ps[i].s+ps[p2].s)/2);
      }
      p1=i;
    }
  }
  //cout<<endl;
  /*
  for(i=0;i<n;i++){
    cout << ps[i].e << endl;
  }
  cout << endl;
  */
  for(i=0;i<q;i++){
    cin >> k;
    cout << ps[k-1].e << endl;
  }
  return 0;
}

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

using namespace std;

long long int dfs ( vector<long long int>v[],long long int a[],bool vis[],long long int i){

    long long int m,k,l,max1=0;

  /*  cout<<"in dfs call vis:"<<vis[i]<<"\n";
    cout<<"in dfs received:"<<i<<"\n";*/

    if(vis[i]){
    //    cout<<"'''already visited a:"<<(a[i])<<"'''\n";
        return (a[i]);
    }
    else{

        vis[i]=true;
        for(k=0;k<v[i].size();k++){
            long long int p=v[i][k];
            max1=max(dfs(v,a,vis,p),max1);
            a[i]=max1+1;
            //cout<<"In dfs call k:"<<v[i][k]<<",m2:"<<max1<<"\n";
            vis[v[i][k]]=true;
        }

        if(v[i].size()==0)
            a[i]=1;
    }

    //cout<<"''''for i:"<<i<<",returnned k:"<<(max1+1)<<"'''\n";
    return max1+1;
}

int main(){

    long long int n,m,i,j,k,max2=0;

    cin>>n>>m;

    long long int a[n+1];
    bool vis[n+1];
    vector<long long int>v[n+1];

    for(i=1;i<=n;i++){
        a[i]=0;
        vis[i]=false;
    }

    for(i=0;i<m;i++){

        long long int a1,b;

        cin>>a1>>b;

        v[a1].push_back(b);
    }

    for(i=1;i<=n;i++){
       // cout<<"In main i:"<<i<<"\n";
        long long int h=dfs(v,a,vis,i);
        max2=max(h,max2);
        a[i]=h;
       // cout<<"''''i:"<<i<<",in main a:"<<h<<"''''\n";
    }

  /*  cout<<"\n\n";
    for(i=1;i<=n;i++)
        cout<<"a:"<<a[i]<<"\n";*/

    cout<<(max2-1)<<"\n";

    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

const int N = 2000010;
char s[N], str[N*2];
int p[N*2],a[N];
long long manacher()
{
    int i;
    for(i = 1; s[i]; i++)
        str[i*2] = s[i], str[i*2+1] = '#';
    str[0] = '?', str[1] = '#', str[i*2] = '\0';
    int res = 0, k = 0, maxk = 0,n=strlen(s+1);
    long long mmh=1LL*n*(n+1)/2;
    for (int i=1;i<=n;i++){
    	a[s[i]]++;
    	mmh-=a[s[i]];
	}
    return mmh+1;
}

int main()
{
    scanf(" %s", s + 1);
    printf("%lld\n", manacher());
    return 0;
}


Measured memory_bytes: 4352
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    
    let s = get().as_bytes();
    let mut dp = vec![0; 13];
    let n = s.len();
    if s[n-1] == b'?' {
        for i in 0 .. 10 {
            dp[i] = 1;
        }
    } else {
        let x = (s[n-1] - b'0') as usize;
        dp[x] = 1;
    }
    let mut p = 10;
    let md = 1_000_000_007;
    for i in 1 .. s.len() {
        let i = (s.len()-1) - i;
        let mut tmp = vec![0; 13];
        if s[i] == b'?' {
            for c in 0 .. 10 {
                let x = ((c * p) % 13) as usize;
                for j in 0 .. 13 {
                    tmp[(j + x) % 13] += dp[j];
                    tmp[(j + x) % 13] %= md;
                }
            }
        } else {
            let c = (s[i] - b'0') as i64;
            let x = ((c * p) % 13) as usize;
            for j in 0 .. 13 {
                tmp[(j + x) % 13] = dp[j];
            }
        }
        p = (p * 10) % 13;
        dp = tmp;
    }
    let ans = dp[5];
    println!("{}", ans);
}


Measured memory_bytes: 4352
A, B, C, D, E, F = map(int, input().split())

water = [0 for _ in range(30 + 1)]
sugar = [0 for _ in range(3000 + 1)]

water[0] = 1
sugar[0] = 1

for i in range(30):
    if water[i]:
        if i + A <= 30:
            water[i + A] = 1
        if i + B <= 30:
            water[i + B] = 1

for j in range(3000):
    if sugar[j]:
        if j + C <= 3000:
            sugar[j + C] = 1
        if j + D <= 3000:
            sugar[j + D] = 1

concentration = 0
ans = (100 * A, 0)

for i in range(31):
    if not water[i]:
        continue
    for j in range(3001):
        if not sugar[j]:
            continue
        if i + j == 0 or 100 * i + j > F or j > E * i:
            continue
        if concentration * (100 * i + j) < 100 * j:
            concentration = (100 * j) / (100 * i + j)
            ans = (100 * i + j, j)

print(*ans)

Measured memory_bytes: 3064
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        mut hh: [usize; n],
    }
    hh.sort();
    let result = hh.into_iter().rev().skip(k).fold(0, |sum, a| sum + a);

    println!("{}", result);
}


Measured memory_bytes: 6396
N, M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  E[A-1] += [B-1]
  E[B-1] += [A-1]

ans = [-1]*N
T = [0]
while len(T)>0:
  P = T
  T = []
  for x in P:
    for e in E[x]:
      if ans[e]==-1:
        T += [e]
        ans[e] = x

print("Yes")
for a in ans[1:]:
  print(a+1)


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

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MOD = 1000000007;
static const ll MAX = 10000;
static const ll INFTY = 1e18;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

  string S;
  cin >> S;
  ll ans = 0;
  ll start = 0;

  if(S.length() % 2 == 0){
    start = S.length() / 2 - 1;
    ans = S.length() / 2;
    // cout << start << endl;
    // cout << ans << endl;
    ll std = S[start];
    REP(i, S.length() / 2){
      // cout << S[start+i] << endl;
      if( std == S[start-i] && std == S[start+i+1] ){
        ans++;
      } else {
        break;
      }
    }
  }else {
    start = S.length() / 2;
    ans = S.length() / 2;
    REP(i, S.length() / 2 + 1){
      if( S[start] == S[start-i] && S[start] == S[start+i] ){
        ans++;
      } else {
        break;
      }
    }
  }
  cout << ans << endl;

 

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 512
MODE = "stdio"

line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  5 14 80
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end


list = Array.new

a,b,c = line[0].split(" ").map(&:to_i)

k=0
(a..b).each do |n|
  if(c%n == 0)
    k += 1
  end
end 

puts k

Measured memory_bytes: 8692
x = int(input())
if x<600:
    print(8)
elif x<800:
    print(7)
elif x<1000:
    print(6)
elif x<1200:
    print(5)
elif x<1400:
    print(4)
elif x<1600:
    print(3)
elif x<1800:
    print(2)
elif x<2000:
    print(1)

Measured memory_bytes: 9180
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------


int main() {

  int n, m, cnt = 0;
  int L = -1, R = INF, l, r;
  cin >> n >> m;

  rep(i, m) {
    cin >> l >> r;
    L = max(L, l);
    R = min(R, r);
  }

  cout << max((R-L+1), 0) << endl;

  return 0;
}


Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident $($r:tt)*) => {
        let mut $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident $($r:tt)*) => {
        let $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().unwrap()
    };
}

use std::io::{stdout, BufWriter, Write};
use std::cmp::min;

fn main() {
    input! {n, m, l, abc: [(usize1, usize1, usize); m], q, st: [(usize1, usize1); q]};
    let mut dp = vec![vec![l+1; n]; n];
    for (a,b,c) in abc {
        dp[a][b] = c;
        dp[b][a] = c;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    for i in 0..(n-1) {
        for j in (i+1)..n {
            if dp[i][j] <= l {
                dp[i][j] = 1;
            }
            if dp[j][i] <= l {
                dp[j][i] = 1;
            }
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    let stdout = stdout();
    let mut stdout = BufWriter::new(stdout.lock());
    for (s,t) in st {
        let c = if dp[s][t] <= l {(dp[s][t] - 1) as isize} else {-1};
        writeln!(stdout, "{}", c).unwrap();
    }
}

Measured memory_bytes: 10492
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define CLR(x) memset((x), false, sizeof(x))
const int MAXD = 12801;
const int MAXN = 81;
int  A[2][MAXN][MAXN];
bool   dp[MAXN][MAXN][MAXD];
int H, W;

int solve() {
  CLR(dp);
  dp[0][0][0] = true;
  dp[0][1][0] = true;
  dp[1][0][0] = true;
  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      for (int k = 0; k < MAXD; ++k) {
        int d = std::abs(A[0][i][j] - A[1][i][j]);
        int nk1 = k + d;
        if (nk1 < MAXD) {
          dp[i][j][k] |= dp[i-1][j][nk1] | dp[i][j-1][nk1];
        }
        int nk2 = std::abs(k - d);
        dp[i][j][k] |= dp[i-1][j][nk2] | dp[i][j-1][nk2];
      }
    }
  }
  for (int k = 0; k < MAXD; ++k) {
    if (dp[H][W][k]) {
      return k;
    }
  }
  return -1;
}

int main() {
  scanf(" %d%d", &H, &W);
  for (int k = 0; k < 2; ++k) {
    for (int i = 1; i <= H; ++i) {
      for (int j = 1; j <= W; ++j) {
        scanf("%d", &A[k][i][j]);
      }
    }
  }
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 82432
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main(){

	int n,m; //問題文のn,m

	while(std::cin >> n >> m){
		if(n==0&&m==0) break;
		std::vector<int> p(n); //野菜価格一覧
		for(int i=0;i<n;++i){
			std::cin >> p[i];
		}
		sort(p.begin(), p.end());

		reverse(p.begin(), p.end()); //降順ソート
		
		for(int i=m-1;i<=n-1;i+=m){
			p[i]=0;
		}
		std::cout << accumulate(p.begin(), p.end(), 0) << std::endl;
		
	}

	return 0;
}


Measured memory_bytes: 3140
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vll h(n + 1, 0); REP(i, n) cin >> h[i + 1];
    vvll dp(n + 1,  vll(n - k + 1,  HIGHINF));  // dp[i][j]: 左から見ていって i 個目を残す時に j 個ある時の最小コスト
    dp[0][0] = 0;
    rep(i, 1, n + 1) {
        rep(j, 1, min(i + 1, n - k + 1)) {
            ll tmp = HIGHINF;
            REP(k, i) {
                chmin(tmp, dp[k][j - 1] + max(h[i] - h[k], 0LL));
            }
            dp[i][j] = tmp;
        }
    }
    
    ll ans = HIGHINF;
    REP(i, n + 1) chmin(ans, dp[i][n - k]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

int X[100010];
int Y[100010];
int Z[100010];
int done[100010];
vector<int> tos[100010];

void dfs(int s)
{
	done[s] = 1;
	for (auto to : tos[s]) {
		if (!done[to]) {
			dfs(to);
		}
	}
}

void Main()
{
	int N, M; cin >> N >> M;
	rep(i,M) {
		int x, y, z; cin >> x >> y >> z;
		--x, --y;
		tos[x].push_back(y);
		if (x != y) tos[y].push_back(x);
	}
	int res = 0;
	rep(i,N) {
		if (!done[i]) {
			dfs(i);
			++res;
		}
	}
	cout << res << endl;
}

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


Measured memory_bytes: 9216
n = int(input())
a = list(map(int, [input() for i in range(n)]))

m1 = max(a)
b = sorted(a, reverse = True)
m2 = max(b[1:])

for i in range(n):
    if a[i] == m1:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 23728
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] c = str.split(" ");
		int sum= Integer.parseInt(c[0])+Integer.parseInt(c[1])*5+Integer.parseInt(c[2])*10+Integer.parseInt(c[3])*50+Integer.parseInt(c[4])*100+Integer.parseInt(c[5])*500;
		if(sum>=1000){
			System.out.println("1");
		}else
			System.out.println("0");	
		}
}

Measured memory_bytes: 17092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#define REP(i,m,n) for(int i = (int)(m),i < (int)(n);i++)
#define rep(i,n) REP(i,0,n);
using namespace std;

int n, a, b;
int x1, x2;

int main(){
	cin >> n >> a >> b;
	x1 = a * n;
	x2 = b;
	cout << min(x1, x2) << endl;
	return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0158

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int calc(int n){
	return (n % 2 == 0) ? n/2 : 3*n+1 ;
}

int main()
{
	int N;

	while(cin >> N && N)
	{
		int tmp=N, cnt=0;

		while(true)
		{	
			if(tmp == 1){ break; }
			cnt++;
			tmp = calc(tmp);
		}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
//using System.Linq;
class Program
{
  //static List<string> list;
	static void Main(string[] args)
	{
		// 入力フェーズ
        string input = Console.ReadLine();

        int a = int.Parse(input[0].ToString());
        int b = int.Parse(input[1].ToString());
        int c = int.Parse(input[2].ToString());
        int d = int.Parse(input[3].ToString());

        // a+b+c+d
        if(a+b+c+d == 7)
          Console.WriteLine(a + "+" + b + "+" + c + "+" + d + "=7");
        else if(a+b+c-d == 7)
          Console.WriteLine(a + "+" + b + "+" + c + "-" + d + "=7");
        else if(a+b-c+d == 7)
          Console.WriteLine(a + "+" + b + "-" + c + "+" + d + "=7");
        else if(a+b-c-d == 7)
          Console.WriteLine(a + "+" + b + "-" + c + "-" + d + "=7");
        else if(a-b+c+d == 7)
          Console.WriteLine(a + "-" + b + "+" + c + "+" + d + "=7");
        else if(a-b+c-d == 7)
          Console.WriteLine(a + "-" + b + "+" + c + "-" + d + "=7");
        else if(a-b-c+d == 7)
          Console.WriteLine(a + "-" + b + "-" + c + "+" + d + "=7");
        else if(a-b-c-d == 7)
          Console.WriteLine(a + "-" + b + "-" + c + "-" + d + "=7");


    // 出力
        //Console.WriteLine(sum + "");
    }
		class myClass{ //自作クラス
			public int ID {set; get;}
			public long Point {set; get;}
		}

    static private long Calculation(string input, int bin)
    {
      // ２進数iが 000だとすると、どこにも＋をいれない
      // 101だとすると、? + ? ? + ? （４桁のinput）っていう感じに計算した値を返す
      if(bin==0)
      {
        return long.Parse(input);
      }

      long sum = 0;
      string str = "";
      //for(int i=0; i<input.Length-1; i++)
      int i=0;
      while(bin>0)
      {
        int plus = bin%2;
        bin = bin/2;
        //Console.WriteLine("bin " + bin + " plus " + plus);
        if(plus == 1)
        {
          // inputの後ろからi+1文字分もぎとってsumに加える
          str += long.Parse(input.Substring(input.Length-i-1)) + " + (input:" + input.Substring(0, input.Length-i-1) + ")";
          sum += long.Parse(input.Substring(input.Length-i-1));
          input = input.Substring(0, input.Length-i-1);
          i=0;
        }else
        {
          i++;
        }
      }
      str += input;
      //Console.WriteLine(str);
      sum += long.Parse(input);

      return sum;
    }

}


Measured memory_bytes: 11220