akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	private static List<Long> getStrings(Scanner sc, int num) {
		List<Long> stringList = new ArrayList<>();
		while(num>0) {
			long nextInt = sc.nextLong();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> array = getStrings(sc, n);
		long sum = 0;
		Map<Long, Long> arraymin = new HashMap<>();
		for (int i = 0; i < n; i++) {
			long r = array.get(i) + i;
			if (arraymin.containsKey(r)) {
				arraymin.put(r, arraymin.get(r)+1);
			} else {
				arraymin.put(array.get(i) + i, 1l);
			}
		}

		for (int i = 0; i < n; i++) {
			long r = i - array.get(i);
			if (arraymin.containsKey(r)) {
				sum+=arraymin.get(r);
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 71468
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,dp[3000][3000],a[220000], b[220000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
		}
	}
	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {

			if (i + 1 < h&&c[i + 1][j] != '#') {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= MOD;
			}
			if (j + 1 < w&&c[i][j + 1] != '#') {
				dp[i][j + 1] += dp[i][j];
				dp[i][j + 1] %= MOD;
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}


Measured memory_bytes: 30976
#include <iostream>
#include <vector>

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

int main() {
  vector<int> a(10000);

  rep(i,10000) cin >> a[i];

  rep(i,10000){
    if(a[i] == 0) return 0;
    cout << "Case " << i+1 << ": " << a[i] << endl; 
  }
}



Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int to_int(char ch) { return ch - '0'; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int val; cin >> val;
    int L = to_int(s[0]);
    for(int i = 1; i < s.size(); i += 2)
    {
        if(s[i] == '+') L += to_int(s[i + 1]);
        if(s[i] == '*') L *= to_int(s[i + 1]);
    }
    vector<int> v;
    for(int i = 1; i < s.size(); i += 2)
    {
        int tmp = to_int(s[i - 1]);
        while(s[i] == '*')
        {
            tmp *= to_int(s[i + 1]);
            i += 2;
        }
        v.push_back(tmp);
    }
    if(s[s.size() - 2] == '+' || s.size() == 1) v.push_back(to_int(s.back()));
    int M = 0;
    for(int i = 0; i < v.size(); i++) M += v[i];
    // for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout << endl;
    // cout << L << " " << M << endl;
    if(val == L && val == M) cout << "U" << endl;
    else if(val == L) cout << "L" << endl;
    else if(val == M) cout << "M" << endl;
    else cout << "I" << endl;
    return 0;
}




Measured memory_bytes: 3228
from itertools import accumulate

N, M, K = map(int, input().split())
A = list(accumulate(int(i) for i in input().split()))
B = list(accumulate(int(i) for i in input().split()))

a,b = [0],[0]
for ai in A:
    a.append(ai)
for bj in B:
    b.append(bj)

cnt = 0
best0 = M
for i in range(N+1):
   ai = a[i]
   for j in range(best0, -1, -1):
       bj = b[j]
       if ai + bj <= K:
           cnt = max(cnt, i + j)
           best0 = j
           break

print(cnt)

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

int main(){
	int n,i;cin>>n;
  	int sum,ans=1;
	vector<int>v(n);
  	for(i=0;i<n;++i)cin>>v[i];
  	for(i=n-1;i>=1;--i){
      sum=0;
      for(int j=i;j>=0;--j)if(v[i]>=v[i-j])++sum;
      if(sum==i+1)++ans;
    }
  cout<<ans<<endl;return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    map<int, int> m;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        m[A]++;
    }

    int s = m.size();
    vector<int> v(s);
    int j = 0;
    for (auto i = m.begin(); i != m.end(); i++)
    {
        v.at(j) = i->second;
        j++;
    }
    sort(v.begin(), v.end());
    int cnt = 0;
    for (int i = 0; i < s - K; i++)
    {
        cnt += v.at(i);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 13352
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    rep(i, 0, N-1) {
        if (a[i] == a[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
vector<vector<ll>>dp(2001,vector<ll>(2001,0));
vector<ll>a(2001);
int main(){
    ll n,x;
    cin>>n>>x;
    rep(i,n){cin>>a[i+1];dp[i+1][0]=a[i+1];}
    //k:number of using magic
    rep(i,n+1)rep(k,n){
        if(k==0||i==0)continue;
        int temp=i-k;
        if(temp<1)temp+=n;
        /*dp[i][k]   : i番目のスライムを魔法をk回以下で手に入れるため最短手段*/
        /*あるスライムa(i)を手に入れる推移*/
        dp[i][k]=min(dp[i][k-1],a[temp]);
    }
    ll ans=INF*INF;
    loop(k,0,n){
        ll flag=k*x;
        loop(i,1,n+1){
            flag+=dp[i][k];
        }
        ans=min(ans,flag);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 31744
local bls, brs = bit.lshift, bit.rshift
local n = io.read("*n")
local t = {}

local lastval = 10000
while 0 < n do
  local min, max = 0, lastval
  while 1 < max - min do
    local mid = brs(min + max, 1)
    if n <= brs(mid * (mid + 1), 1) then
      max = mid
    else
      min = mid
    end
  end
  lastval = max
  table.insert(t, max)
  n = n - max
end
print(table.concat(t, "\n"))


Measured memory_bytes: 2760
from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)

Measured memory_bytes: 58452
N, M = map(int, input().split())
A = ["" for i in range(N)]
for i in range(N):
    A[i] = input()
B = ["" for i in range(M)]
for i in range(M):
    B[i] = input()
    
matched = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        matched = True
        for k in range(M):
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    matched = False
        if matched:
            break
    if matched:
        break

if matched:
    print("Yes")
else:
    print("No")

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


int main(){
    while(1){
      int a,b;
      cin >>a>>b;
      if(!(a+b))break;
      if(a>b)swap(a,b);
      cout<<a<<" "<<b<<endl;
    }
}


Measured memory_bytes: 2972
#include<stdio.h>
#include<stdlib.h>

int main()
{
  char str[20],x[10],y[10],z[10];
  int a,b,c,i=0,j=0,l=0;
  
 
    fgets(str,sizeof(str),stdin);
    
    for(;;){
      if(str[i]==' '){
	break;
      }
      x[i]=str[i];
      i++;
    }
    i++;

    for(;;){
      if(str[i]==' '){
	break;
      }
      y[j]=str[i];
      i++;
      j++;
    }

    for(;;){
      if(str[i]=='\0'){
	break;
      }
      z[l]=str[i+1];
      i++;
      l++;
    }

    a=atoi(x);
    b=atoi(y);
    c=atoi(z);

 

    if(a<0 || 100<a || b<0 || 100<b || c<0 || 100<c){
      printf("Error!!\n");
    }else{
      if(a<b && b<c){
	printf("Yes\n");
      }else{
	printf("No\n");
      }
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int N, K, X, Y;
cin >> N >> K >> X >> Y;

int ans = 0;

for (int i = 1; i <= N; i++){
     if(i <= K){
          ans += X;
     }
     else{
          ans += Y;
     }
}

cout << ans << endl;

return 0;
}

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

int main(void){

    string str;
    getline(cin, str);

    if (str == "RRR"){
      cout << "3";
    }else if (str == "SSS"){
      cout << "0";
    }else if (str == "RRS" || str == "SRR" ){
      cout << "2";
    }else{
      cout << "1";
    }

    return 0;
}

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

int n,ma,mi,dum;

int main()
{
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
      scanf("%d",&dum);
      if(i==1)
      {
         ma=dum;
         mi=dum;
      }
      else
      {
         ma = max(ma,dum);
         mi = min(mi,dum);
      }
   }
   printf("%d\n",ma-mi);
 	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || fr_ch>'9') {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while(fr_ch>='0' && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max(T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min(T &a, T b) {if(b<a) a=b;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double pi   = acos(-1.0) ;
const int MOD     = (int)1e9+7 ;
const int INF     = (int)0x3f3f3f3f ;
const LL  LINF    = (LL)INF<<32|INF ;
const int SINF    = (uint)(-1)>>1 ;
const LL  SLINF   = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double eps  = 1e-8 ;
const int maxn    = (int) 200000+20 ;
const int maxm    = (int) 25000+20 ;
const int maxk    = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int n,m;

map<int,int> mp;

int a[maxn];

void work()
{
    read(n), read(m);

    for(int i=0;i<n;i++)
    {
        int x; read(x);
        mp[x]++;
    }

    int nn=0;
    for(map<int,int> :: iterator mit = mp.begin(); mit != mp.end(); mit++)
    {
        a[nn++]=mit->se;
    }

    sort(a,a+nn);
    reverse(a,a+nn);

    int ans=0;
    for(int i=m;i<nn;i++) ans+=a[i];

    cout <<ans <<endl;

}

//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 10368
import fractions
n = int(input())
al = list(map(int,input().split()))
al = sorted(al)
p = al[0]
for i in range(1, n):
    p = p * al[i] // fractions.gcd(p, al[i])

ans = 0

for a in al:
    ans += p // a

print(ans % (10**9 + 7))


Measured memory_bytes: 6200
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin >> n >> s;
    ll r=0,g=0,b=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='R')r++;
    	else if(s[i]=='G')g++;
    	else b++;
    }
    ll ans=r*g*b;
    for(int i=0;i<n;i++){
    	for(int j=i+2;j<n;j+=2){
    		r=g=b=0;
    		if(s[i]=='R')r++;
    	    else if(s[i]=='G')g++;
    	    else b++;

    	    if(s[j]=='R')r++;
    	    else if(s[j]=='G')g++;
    	    else b++;

    	    if(s[(i+j)/2]=='R')r++;
    	    else if(s[(i+j)/2]=='G')g++;
    	    else b++;
    	    
    	    ans-=r*g*b;
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
// finish date: 2018/01/21
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, N) cin >> l[i];
    sort(l.begin(),l.end(),greater<int>());
    int sum = 0;
    rep(i,K) sum+=l[i];
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
// Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include "bits/stdc++.h"

#pragma region Template

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define llint long long int;

using namespace std;

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#pragma endregion

bool is_valid(int num, const vector<bool>& NGs) {
	while (num) {
		if (NGs[num % 10]) return false;
		num /= 10;
	}
	return true;
}

/* Entry Point */
int main()
{
	/* fast_io */
	cin.tie(0);
	ios::sync_with_stdio(false);
	//

	int n;
	cin >> n;
	cout << (1 + n) * n / 2 << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
const int N = 1e5+10;
struct edge {
	int next, to;
}e[N<<1];
int head[N], sum;
inline void add(int x, int y) {
	e[++sum].next = head[x];
	head[x] = sum;
	e[sum].to = y;
}
int h[N], ans, n, m;
int main() {
	scanf("%d%d", &n, &m);
	for (int i=1; i<=n; i++) scanf("%d", &h[i]);
	for (int i=1; i<=m; i++) {
		int x, y; scanf("%d%d", &x, &y);
		add(x, y); add(y, x);
	}
	for (int i=1; i<=n; i++) {
		bool flag = 1;
		for (int j=head[i]; j; j=e[j].next) {
			if (h[i] <= h[e[j].to]) {flag = 0; break;}
		}
		if (flag) ++ans;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 4068
def rev(a):
    return [-v for v in a[::-1]]

def make(s):
    assert len(s)>0
    pre_s = s[:-1]
    v = s[-1]
    if len(pre_s)==0:
        return [v]
    return make(pre_s) + [v] + rev(make(pre_s)) + [-v]

def make_pre_path(v):
    if v>0:
        return [(i,0) for i in range(1,v+1)] + [(v,1), (v-1,1)] + [(i,0) for i in range(v-1,0,-1)]
    elif v<0:
        return make_pre_path(-v)[::-1]
    assert False

def make_path(v):
    return make_pre_path(v)+[(0,0)]

def test():
    #print(make([1,2,3]))
    main("3","11111110")
    #main("8","1"+"0"*(2**8-1))

def main(s1,s2):
    ok = True
    n = int(s1)
    ret_gp = []
    for i in range(2**n-1,-1,-1):
        s = [v+1 for v in range(n) if (i>>v)%2==1 ]
        if s2[i]=="0":
            for ind in range(n):
                if (i>>ind)%2==0 and s2[(i+2**ind)]=="1":
                    ok = False
            if len(s)>0:
                ret_gp += make(s)
    ret_path = [(0,0)] + [p for v in ret_gp for p in make_path(v)]
    if 0:
        print(ret_gp)
    if ok:
        print("Possible")
        print(len(ret_path) - 1)
        for x,y in ret_path:
            print(str(x)+" "+str(y))
    else:
        print("Impossible")

#test()
        
s1 = raw_input()
s2 = raw_input()
main(s1,s2)

Measured memory_bytes: 8812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC057
{
    class RemainingTime
    {
        static public void Main()
        {
            var ab = ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
            WriteLine((ab[0] + ab[1]) % 24);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(void){
    int N,a=0,b=0;
    scanf("%d",&N);
    char l[N];
    scanf("%s",l);
    for(int i=0;i<N;i++){
        if(l[i]=='R'){
            a++;
        }else{
            b++;
        }
    }

    if(a>b){
        printf("Yes");
    }else{
        printf("No");
    }
    
    return 0;
}

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

int main() {
	ll n, m, k, ans = 0;
	cin >> n >> m >> k;
	vector<ll> a(n + 1), b(m + 1);
	a[0] = 0;
	b[0] = 0;
	rep(i,n) {
		cin >> a[i + 1];
		if (i != 0) a[i + 1] += a[i];
	}
	rep(i,m) {
		cin >> b[i + 1];
		if (i != 0) b[i + 1] += b[i];
	}
	ll ng = n + m + 1, ok = 0;
	while (abs(ng - ok) > 1) {
		ll mid = (ng + ok) / 2;
		bool c = false;
		rep(i,mid + 1) {
			if (i <= n && mid - i <= m) {
				if (a[i] + b[mid - i] <= k) c = true;
			}
		}
		if(c) ok = mid;
		else ng = mid;
	}
	ans = ok;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6404
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

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

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
def main():
    N = int(input())
    A = list(map(int, input().split()))

    c = [0] * (100000 + 2)
    for ai in A:
        c[ai+1] += 1
        c[ai] += 1
        c[ai+2] += 1

    print(max(c))

if __name__ == "__main__":
    main()

Measured memory_bytes: 13964
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int line = scan.nextInt();
		int i = 1;
		while (i <= line) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			int c = scan.nextInt();
			if (a * a + b * b == c * c || b * b + c * c == a * a || a * a + c * c == b * b) {
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
			i++;
		}
	}

}

Measured memory_bytes: 33604
from collections import deque
x,y = map(int, input().split())
li = list(map(int, input().split()))
li.sort(reverse=True)
q = deque(li)
if y >= len(li):
    print(0)
else:
    for i in range(y):
        q.popleft()
    s = 0
    for i in range(len(q)):
        s += q[i]
    print(s)

Measured memory_bytes: 26276
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, cnt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 2, N + 1) {
		int boss; cin >> boss;
		cnt[boss]++;
	}
	rep(i, 1, N + 1) printf("%d\n", cnt[i]);
}







Measured memory_bytes: 4464
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

class DisjointSets {
    class Node {
        public: 
        int parent = -1;
        int rank = 0;
        int degree = 1;
    };
    
private:
    Node *nodes;

    void make_set(int x) {
        nodes[x].parent = x;
        nodes[x].rank = 0;
        nodes[x].degree = 1;
    }

public:
    int find_set(int x) {
        if(nodes[x].parent == x)
            return x;

        //経路圧縮
        nodes[x].rank = 0;
        return nodes[x].parent = find_set(nodes[x].parent);
    }

    int count = 0;

    DisjointSets(){}
    DisjointSets(int length) {
        nodes = (Node *)malloc(sizeof(Node) * length);
        count = length;

        for(int i = 0; i < length; ++i)
            make_set(i);
    }

    ~DisjointSets() {
        free(nodes);
    }

    int degree(int x) {
        return nodes[find_set(x)].degree;
    }

    void unite(int x, int y) {
        int set_x = find_set(x);
        int set_y = find_set(y);
        if(set_x == set_y) return;
        --count;

        if(nodes[x].rank < nodes[y].rank) {
            nodes[set_x].parent = set_y;
            nodes[y].degree += nodes[x].degree;
        } else if(nodes[x].rank > nodes[y].rank) {
            nodes[set_y].parent = set_x;
            nodes[x].degree += nodes[y].degree;
        } else {
            nodes[set_y].parent = set_x;
            nodes[x].rank++;
            nodes[x].degree += nodes[y].degree;
        }
    }

    bool same(int x, int y) {
        int set_x = find_set(x);
        int set_y = find_set(y);
        return set_x == set_y;
    }
};

int N, M;
int main(int argc, char **argv) {
    cin >> N >> M;

    DisjointSets *sets = new DisjointSets(N * 2);
    /*
        A_iについて
            偶数である事象...2 * i
            奇数である事象...2 * i + 1
    */

    for(int i = 0; i < M; ++i) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        X--;
        Y--;
        if(Z % 2 == 0) {
            sets->unite(2 * X, 2 * Y);
            sets->unite(2 * X + 1, 2 * Y + 1);
        } else {
            sets->unite(2 * X + 1, 2 * Y);
            sets->unite(2 * X, 2 * Y + 1);
        }
    }

    int groups = 0;
    set<int> new_num;
    for(int i = 0; i < 2 * N; ++i) {
        int root = sets->find_set(i);
        if(new_num.find(root) == new_num.end()) {
            new_num.insert(root);
            ++groups;
        }
    }

    cout << (groups + 1) / 2 << endl;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int A=0,T=0,W=0,R=0,N = 0;
string C;
cin >> N;
vector<string> vec(N);

for (int i = 0; i < N; i++) {
  cin >> C;
 if(C=="AC"){ A = A+1;}
else if(C=="WA"){W=W+1;}
else if(C=="TLE"){T=T+1;}
else {R=R+1;}
}

cout << "AC x " << A <<endl;
cout << "WA x " << W<<endl;
cout << "TLE x " << T<<endl;
cout << "RE x " << R <<endl;
}

Measured memory_bytes: 6392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n; cin>>n;
	ll sm=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				int a=i, b=j;
				int po=__gcd(a,b);
				int y=__gcd(po,k);
				sm+=y;
			}
		}
	}
	cout<<sm;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007
#define pi 3.14159265358979323846264338327950

void solve()
{
    ll n;
    cin >> n;
    vector<ll> q;
    for (int i = 1; i <= 9; i++)
    {
        q.push_back(i);
    }
    ll start = 0;
    while (start != n - 1)
    {
        ll temp = q[start];

        if (temp % 10 == 0)
        {
            q.push_back(temp * 10);
            q.push_back(temp * 10 + 1);
        }
        else if (temp % 10 == 9)
        {
            q.push_back(temp * 10 + 8);
            q.push_back(temp * 10 + 9);
        }
        else
        {
            q.push_back(temp * 10 + (temp % 10) - 1);
            q.push_back(temp * 10 + (temp % 10));
            q.push_back(temp * 10 + (temp % 10) + 1);
        }
        start++;
    }
    cout << q[start] << endl;
}

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

Measured memory_bytes: 7420
#include <iostream>
#include <cstdio>
#include<string>
#include<vector>
using namespace std;
int main(){
   string str;
   int cnt=0;
   long long menseki[20001]={0};int men=0;
   vector<int> deep(20001,0);
   char flag=false;
   cin>>str;
   if(str[0]=='\\')deep[0]++;
   else if(str[0]=='/')deep[0]--;
   for(int i=1;i<str.size();++i){
	   if(str[i-1]=='\\'&&str[i]=='/'||str[i-1]=='_'&&str[i]=='\\'||str[i-1]=='/'&&str[i]=='\\'||str[i-1]=='/'&&str[i]=='_'||str[i]=='_'&&str[i-1]=='_')
		   deep[i]+=deep[i-1];
	   else if(str[i-1]=='\\'&&str[i]=='_')deep[i]+=deep[i-1]+1;
	   else if(str[i]=='\\')deep[i]+=deep[i-1]+1;
	   else if(str[i]=='/')deep[i]+=deep[i-1]-1;
   }
   for(int i=0;i<str.size();++i){//i=始点
       if(str[i]=='\\'){
           for(int j=i;j<str.size();++j){//j=終点
               if(deep[i]==deep[j]&&str[j]=='/'){
                   for(int k=i;k<=j;++k){//始点<=k<=終点
                   if(deep[k]-deep[j]!=0) menseki[men]+=(deep[k]-deep[j])*10;
				   else if(str[k]=='_')menseki[men]+=10;
				   if(str[k]=='/'||str[k]=='\\')menseki[men]+=5;
				   }
                       i=j;
                       men++;
                       break;
                   }
           }
           
       }
       
   }
   int sum=0;
   for(int i=0;i<men;++i){
	   sum+=menseki[i]/10;
   }
   cout<<sum<<endl<<men;

   for(int i=0;i<men;++i){
       cout<<" "<<menseki[i]/10;
       }cout<<endl;
   return 0;
}


Measured memory_bytes: 3456
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> Pint;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  FOR(i,0,M) cin >> P[i] >> Y[i];
  vector<Pint> v(M);
  FOR(i,0,M) {
    v[i] = Pint(Y[i], i);
  }
  sort(v.begin(), v.end());
  vector<int> cnt(N, 0);
  vector<int> ans(M, -1);
  FOR(i,0,M) {
    int shi = v[i].second;
    cnt[P[shi]]++;
    ans[shi] = cnt[P[shi]];
  }
  FOR(i,0,M) {
    cout << setfill('0') << right << setw(6) << P[i] << setfill('0') << right << setw(6) << ans[i] << endl;
  }

}

Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main() {
	int a,x=0,ans=0;
	cin >> a;
	vector<int> s(a),t(a);
	rep(i, a) {
		cin >> s[i];
		t[i] = i + 1;
	}
	rep(i, a) {
		if (s[i] == t[x])x++;
		else ans++;
	}
	if (ans == a)ans = -1;
	cout <<  ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <climits>


using namespace std;


using ll = long long;


int main() {
    ll coins[20];
    ll dp[20][50001] = {{ }};

    ll n, m;
    cin >> n >> m;

    for (ll i = 0; i < m; i++) {
        cin >> coins[i];
    }

    for (ll i = 0; i < 50001; i++)
        dp[0][i] = i;

    for (ll i = 1; i < m; i++) {
        for (ll j = 1; j < n + 1; j++) {
            dp[i][j] = min(dp[i - 1][j], j - coins[i] >= 0 ? dp[i][j - coins[i]] + 1 : LONG_LONG_MAX);
        }
    }

    cout << dp[m - 1][n] << endl;
}



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

int main()
{
    string n;
    cin >> n;
    int x=0;
    rep(i, n.size()) {
        x += n[i] - '0';
    }
    if(x % 9== 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3680
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>

// type alias
using lint = long long;
using ldouble = long double;
template <class T>
using greater_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>;


/* ----- class ----- */

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Edges = std::vector<Edge<Cost>>;

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;


/* ----- debug ----- */

#if __has_include("../setting/source/debug.hpp")
#include "../setting/source/debug.hpp"
#endif


/* ----- short functions ----- */

template <class T>
inline T sq(T a) { return a * a; }

template <class T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <class T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

template <class T, class U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

// 0-indexed
template <class T, class U>
inline T kthbit(T a, U k) { return (a >> k) & 1; }

template <class T, class U>
inline T mask(T a, U k) { return a & ((1 << k) - 1); }

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}


/* ----- constants ----- */

// const int INF = std::numeric_limits<int>::max() / 3;
// const lint INF = std::numeric_limits<lint>::max() / 3;
// const ldouble PI = acos(-1);
// const ldouble EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));


using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> D(N);
    for (auto& d : D) cin >> d;

    sort(D.begin(), D.end());
    cout << D[N / 2] - D[N / 2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 640
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
        return a

def main():
    X = int( input())
    # if X > 90:
    #     X -= 90
    for i in range(1, X+1):
        if i*360%X == 0:
            print(i*360//X)
            return
if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  
 // freopen("input.txt","r",stdin);
 // freopen("outputu.txt","w",stdout);
  int n,m,i;
  cin>>n>>m;
  if(n<=m)for(i=0;i<m;i++)cout<<n;
  else for(i=0;i<n;i++)cout<<m;
  
  


  
 
 
 
    
 
return 0;
}

Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {
//    var (N,L) = readLine()!!.split(" ").map { it.toInt() }
    var N = readLine()!!.toInt()
//    val S = readLine()!!.toInt()
    val P = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var ans = 0
    for (i in 1 until N-1) {
        var p = arrayOf(P[i-1],P[i],P[i+1])
        p.sort()
        if (P[i] == p[1]) ans++

    }

    println(ans)
}



Measured memory_bytes: 37944
def main():
    N = int(input())
    ans = [0]*(N+1)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                a = x*x + y*y + z*z + x*y + y*z + z*x
                if a <= N:
                    ans[a] += 1
    for i in range(1, N+1):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
#include<stdio.h>
#include<string.h>
#define max(a,b) (((a)>(b))?(a):(b))
 
struct Node {
  int xl;
  int yl;
};
struct Node len;

int main(void){
    int i,j,k;
    int q,tmp;

    int dp[1001][1001]={0};
    char x[1001],y[1001];
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%s",x);
        scanf("%s",y);
        len.xl=strlen(x);
        len.yl=strlen(y);
        for(j=1;j<len.xl+1;j++){
            for(k=1;k<len.yl+1;k++){
                if(x[j-1]==y[k-1]){
                    dp[j][k]=dp[j-1][k-1]+1;    
                }else{
                    dp[j][k]=max(dp[j-1][k],dp[j][k-1]);
                }
            }
        }
        printf("%d\n",dp[len.xl][len.yl]);
    }
    return 0;
}           

Measured memory_bytes: 4524
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

vector<int> parents;

int find_root(int now){
    if(parents[now] == now){
        return now;
    }else{
        int ans = find_root(parents[now]);
        parents[now] = ans;
        return ans;
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    if(N - 1 - M > N / 2){
        cout << "Impossible" << endl;
        return 0;
    }else if(N == M + 1){
        cout << 0 << endl;
        return 0;
    }
    parents.resize(N);
    for(int i = 0; i < N; i++){
        parents[i] = i;
    }
    long costs[N];
    for(int i = 0; i < N; i++){
        cin >> costs[i];
    }
    for(int i = 0; i < M; i++){
        int start, goal;
        cin >> start >> goal;
        parents[find_root(start)] = find_root(goal);
    }
    vector<long> cost_of_connected_components[N];
    for(int i = 0; i < N; i++){
        cost_of_connected_components[find_root(i)].push_back(costs[i]);
    }
    for(int i = 0; i < N; i++){
        sort(cost_of_connected_components[i].begin(), cost_of_connected_components[i].end());
    }
    long ans = 0;
    vector<long> not_minimum_costs;
    for(int i = 0; i < N; i++){
        if(cost_of_connected_components[i].size()){
            ans += cost_of_connected_components[i][0];
            for(int j = 1; j < cost_of_connected_components[i].size(); j++){
                not_minimum_costs.push_back(cost_of_connected_components[i][j]);
            }
        }
    }
    sort(not_minimum_costs.begin(), not_minimum_costs.end());
    for(int i = 0; i < N - M - 2; i++){
        ans += not_minimum_costs[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(x,a) for(auto& (x) : (a) )
int main(){
  int n;
  cin>>n;
  int ans = n/2+n%2;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
//TakandHotels.cpp (A)
#include <iostream>
using namespace std;

int main(){
  int n,k,x,y,ans;
  cin >> n >> k >> x >> y;

  if(n>k) ans = x*k, ans += y*(n-k);
  else ans = x*n;
  
  printf("%d\n",ans );

}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>
#include <algorithm>
#include<limits.h>
int main(){
    unsigned int h,n;
    std::cin>>h>>n;
    std::vector<std::pair<int,int>> magic(n);
    //first -> 敵へのダメージ : second -> 消費魔力
    for(unsigned int i = 0;i < n;i++){
        std::cin>>magic[i].first>>magic[i].second;
    }
    std::vector<unsigned long long int> dp(h + 1,ULLONG_MAX);
    dp[0] = 0;
    for(unsigned int i = 1;i < h + 1;i++){
        for(int j = 0;j < n;j++){
            if(i >= magic[j].first){
                if(dp[i] > (dp[i - magic[j].first] + magic[j].second)){
                    dp[i] =(dp[i - magic[j].first] + magic[j].second);
                }
            }else{
                if(dp[i] > (unsigned long long int)magic[j].second){
                    dp[i] = (unsigned long long int)magic[j].second;
                }
            }
        }
    }
    std::cout<<dp[h]<<std::endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(3)

const int mod = 1e9 + 7;
map<int,int> dp;

long long n,ans;

inline long long solve(long long x) {
	if(dp[x] != 0) return dp[x];
	else {
		dp[x] = ((solve(x / 2) + solve((x - 1) / 2)) % mod + solve((x - 2) / 2)) % mod;
		return dp[x];
	}
}

int main() {
	dp[0] = 1;
	dp[1] = 2;
	scanf("%lld",&n);
	ans = solve(n);
	printf("%lld\n",ans);
}

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

int main() {
    int A, B;
  cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#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 ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;
const int MOD = 1000000007;




int main(){
    int cnt=0;
    string s;   cin >> s;
    for (int i=0;i<s.size()/2;i++){
        if(s.at(i)!=s.at(s.size()-1-i)) cnt++;
    }

    cout << cnt << endl;


}

Measured memory_bytes: 256
s = input()
mods = [0]*2019
mods[0] = 1
accu = 0
for i, j in enumerate(reversed(s)):
    accu += int(j)*pow(10, i, 2019)
    accu %= 2019
    mods[accu] += 1
ans = 0
for i in mods:
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9224
#include <cstdio>
#include <string>
#include <cctype>
#include <iostream>
using namespace std;
typedef string::const_iterator State;

string factor(State &begin,int &n,int x);
int number(State &begin);
string seq(State &begin);


int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}

string seq(State &begin){
	string ret="";
	while(*begin>='A' && *begin<='Z'){
		ret+=*begin;
		begin++;
	}
	return ret;
}

string factor(State &begin,int &n,int x){
	int k=1;
	string str="";
	while(1){
		if(*begin=='('){
			begin++;
			string ret=factor(begin,n,x);
			//cout << ret << endl;
			begin++;
			if(n>x)return ret;
			str+=ret;
			for(int i=1;i<k;i++){
				str+=ret;
				n+=ret.size();
				if(n>x){
					string res="";
					res+=ret[ret.size()-(n-x)];
					return res;
				}
			}
			k=1;
		}else if(*begin>='0' && *begin<='9'){
			k=number(begin);
		}else if(*begin>='A' && *begin<='Z'){
			//string ret=seq(begin);
			for(int i=0;i<k;i++){
				str+=*begin;
				n++;
				if(n>x){
					string res="";
					res+=*begin;
					return res;
				}
			}
			k=1;
			begin++;
		}else break;
	}
	return str;
}

int main(void){
	while(1){
		int x;
		string str;
		cin >> str >> x;
		if(str=="0" && x==0)break;
		State begin=str.begin();
		int d=0;
		string res=factor(begin,d,x);
		if(d<=x)res="0";
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 5552
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
#define trace(...)
#endif

using LL = long long;

const int N = 600;
vector<int> adj[N];
double dp[N], dpr[N], prob[N];

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

	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		adj[u - 1].push_back(v - 1);
	}

	dp[n - 1] = 0;
	for (int u = n - 2; u >= 0; u--) {
		double curr = 0;
		int sz = adj[u].size();
		for (int v: adj[u]) {
			curr += dp[v];
		}
		dp[u] = 1 + curr / sz;
		dpr[u] = dp[u];

		if (sz > 1) {
			for (int v: adj[u]) {
				dpr[u] = min(dpr[u], 1 + (curr - dp[v]) / (sz - 1));
			}
		}
	}

	prob[0] = 1;
	for (int u = 0; u < n - 1; u++) {
		double pj = prob[u] / adj[u].size();
		for (int v: adj[u]) {
			prob[v] += pj;
		}
	}

	double ans = dp[0];
	for (int u = 0; u < n - 1; u++) {
		ans = min(ans, dp[0] - prob[u] * (dp[u] - dpr[u]));
	}

	cout << setprecision(10) << fixed << ans << endl;

	return 0;
}


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

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()){
            int a = Integer.parseInt(sc.next());
            String op = sc.next();
            int b = Integer.parseInt(sc.next());            
            if(op.equals("?")) break;
            else if(op.equals("+"))System.out.println(a+b);
            else if(op.equals("-"))System.out.println(a-b);
            else if(op.equals("*"))System.out.println(a*b);
            else if(op.equals("/"))System.out.println(a/b);
        }
    }

}



Measured memory_bytes: 26156
if __name__ == "__main__":
    n, a, b = map(int, input().split())

    if n == 1 and a == b:
        print(1)
        exit()
    elif n == 1:
        print(0)
        exit()
    elif a > b:
        print(0)
        exit()
    elif n == 2:
        print(1)
        exit()

    n_min = b + (n-1)*a
    n_max = a + (n-1)*b

    print(n_max-n_min+1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using lint=long int;
int N;
lint res=0;
vector<int> A(200010);
priority_queue<int> pq;
int main()
{
    cin >> N;
    for(int i=0; i<N; i++) cin>>A[i];
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    pq.push(A[0]);
    for(int i=1; i<N; i++){
        int val=pq.top(); pq.pop();
        res+=val;
        pq.push(A[i]); pq.push(A[i]);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 5036
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n,m,ans = 0;
    int s,c;

    cin >> n >> m;
    vector<bool>check(n,false);
    vector<int>number(n,0);

    for(int i = 0;i < m;i++){
        cin >> s >> c;
        if(check[s-1] && number[s-1] != c) ans = -1;
        else{
            check[s-1] = true;
            number[s-1] = c;
        }
    }

    if(n != 1 && number[0] == 0 && check[0]) ans = -1;
    else if(ans == -1){}
    else{
        if(n > 1 && number[0] == 0) number[0] = 1;
        for(int i = 0;i < n;i++){
            ans *= 10;
            ans += number[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256