akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import numpy as np
iNum, iM = map(int, input().split())
naB = np.zeros(iNum, dtype = "bool")
naW = np.zeros(iNum, dtype = int)
iC = 0
iW = 0
for _ in range(iM):
  l = input().split()
  iP = int(l[0]) - 1
  if not(naB[iP]):
    if l[1][0] == "A":
      naB[iP] = True
      iC += 1
      iW += naW[iP]
    else:
      naW[iP] += 1
print(iC, iW)

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

int main()
{
    int n;
    string s;
    cin>>n>>s;
    vector<int>a(n);
    ll r=0;
    ll g=0;
    ll b=0;

    rep(i,n){
        if(s[i]=='R'){
            a[i]=0;
            r++;
        }else if(s[i]=='G'){
            a[i]=1;
            g++;
        }else {
            a[i]=4;
            b++;
        }
    }
    ll c=0;
    rep(i,n){
        for(int j=i+1;2*j-i<n;j++){
            if(a[i]+a[j]+a[2*j-i]==5)c++;
        }
    }
    cout<<r*g*b-c<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    unordered_map<int, int> f;
    long long ans = 0LL;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ans += f[i - x];
        ++f[i + x];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 18416
#include <iostream>
#define ll long long
using namespace std;
//for study. i copied other code's code. 
ll n,m;
ll a[55];
ll dfs(ll x,ll y)
{
	//cout <<x<<" "<<y<<" "<<a[x]<<"\n";
	if (y<=x) return 0;
	else if (x==0) return 1;
	else
	{
	    if (y-1<=a[x-1]) return dfs(x-1,y-1);
	    else if (y-1==a[x-1]+1) return dfs(x-1,y-2)+1;
	    else if (y!=a[x]) return dfs(x-1,a[x-1])+1+dfs(x-1,y-a[x-1]-2);
		else return dfs(x-1,a[x-1])*2+1;
	}
}
int main()
{
	cin >>n>>m;
	a[0]=1;
	for (int i=1;i<=n;i++) a[i]=a[i-1]*2+3;
	cout <<dfs(n,m);
	return 0;
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    left = [[0] * W for _ in range(H)]
    right = [[0] * W for _ in range(H)]
    up = [[0] * W for _ in range(H)]
    down = [[0] * W for _ in range(H)]
    for i in range(H):
        cnt = 0
        for j in range(W):
            if S[i][j] == '#':
                cnt = 0
            else:
                cnt += 1
            left[i][j] = cnt
    
    for i in range(H):
        cnt = 0
        for j in range(W-1,-1,-1):
            if S[i][j] == '#':
                cnt = 0
            else:
                cnt += 1
            right[i][j] = cnt
    
    for j in range(W):
        cnt = 0
        for i in range(H):
            if S[i][j] == '#':
                cnt = 0
            else:
                cnt += 1
            up[i][j] = cnt
    
    for j in range(W):
        cnt = 0
        for i in range(H-1,-1,-1):
            if S[i][j] == '#':
                cnt = 0
            else:
                cnt += 1
            down[i][j] = cnt
    
    ans = 0
    for i in range(H):
        for j in range(W):
            tmp = up[i][j] + down[i][j] + left[i][j] + right[i][j] - 3
            ans = max(ans, tmp)


    print(ans)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 310152
using System;
using System.Collections.Generic;
using System.Linq;
using console=System.Console;
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            args=new string[2];
            args[0] = console.ReadLine();
            if(args[0].Count()==26)
            {
                 args[1] = ((char)(25 - args[0].Skip(1).Zip(args[0],(a,b)=>a-b).Reverse().TakeWhile(i=>i<0).Count())).ToString();
                 if(args[1][0]==0)
                     console.WriteLine(-1);
                 else
                 {
                 var s = args[0].Take(args[1][0]).ToArray();
                 s[args[1][0]-1]=args[0].Last(c=>c>s[args[1][0]-1]);
                 console.WriteLine(string.Join("",s));
                 }
            }
            else
                console.WriteLine(args[0] +(char)('a'+ args[0].OrderBy(c=>c).Where((c,i)=>c-i=='a').Count()));
        }
    }
}

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

int main()
{

        long long A, B, C, D;
        cin >> A >> B >> C >> D;

        long long S1 = A * B;
        long long S2 = C * D;

        if (S1 > S2) {
                cout << S1 << endl;
        }
        else {
                cout << S2 << endl;
        }







}


Measured memory_bytes: 256
s = input()
n = int(input())

t = ''
for i in range(n):
    q = input().split()
    if len(q) == 1:
        t, s = s, t
    elif len(q) == 3:
        if q[1] == '1':
            t += q[2]
        elif q[1] == '2':
            s += q[2]

t = t[::-1]
print(t + s)

Measured memory_bytes: 4444
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<< #x << ": " << x << "\n";
using namespace std;
#define inf 1e9+7


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0) cout<<1<<"\n";
	if(b==0) cout<<2<<"\n";
	if(c==0) cout<<3<<"\n";
	if(d==0) cout<<4<<"\n";
	if(e==0) cout<<5<<"\n";
	

}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int n,m;
int cc[305],a[305][305];
bool vis[305];
bool chk(int x)
{
	queue<int>q[305];
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)q[i].push(a[i][j]);
	for(int i=1;i<=m;i++)vis[i]=true;
	for(int tt=1;tt<=m;tt++)
	{
		for(int i=1;i<=m;i++)cc[i]=0;
		for(int i=1;i<=n;i++)
		{
			while(!q[i].empty()&&!vis[q[i].front()])q[i].pop();
			if(q[i].empty())return false;
			cc[q[i].front()]++;
		}
		bool f=false;
		for(int i=1;i<=m;i++)if(cc[i]>x)
		{
			f=true;
			vis[i]=false;
		}
		if(!f)break;
	}
	for(int i=1;i<=n;i++)
	{
		int cc=0;
		for(int j=1;j<=m;j++)
		{
			if(vis[j]==1)cc=1;
		}
		if(!cc)return false;
	}
	return true;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	{
		if(chk(i))
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<int64> A(N+1);
	vector<int64> maxleaf(N+1, 0);
	REP(i, N+1) cin >> A[i];
	for (int64 i = N; i >= 0; i--) {
	  maxleaf[i] += A[i];
	  if (i > 0) maxleaf[i-1] += maxleaf[i];
	}
	int64 sum = 0, res = 0, valid = 1;
	REP(i, N+1) {
	  if (valid < A[i]) {
	    cout << -1 << endl;
	    return 0;
	  } else {
	    valid -= A[i];
	    valid *= 2;
	  }
	  chmin(valid, (1LL << 62));
	}
	sum = 1;
	REP(i, N+1) {
	  if (sum < A[i]) {
	    cout << -1 << endl;
	    return 0;
	  } else {
	    chmin(sum, maxleaf[i]);
	    res += sum;
	    sum -= A[i];
	    sum *= 2;
	  }
	}
	cout << res << endl;
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M;
    cout << (N - 1) * (M - 1) << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      int n,y;
      cin >> n >> y;
      for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++){
                  if(i+j>n)continue;
                  if(n-i-j<0)continue;
                  if(10000*i + 5000*j + 1000*(n-i-j) == y){
                        cout << i << ' ' << j << ' ' << n-i-j << endl;
                        return 0;
                  }
            }
      }
      cout << "-1 -1 -1" << endl;
      return 0;
}

Measured memory_bytes: 256
s = gets.strip
n=s.size
i=0
as=[]
while n-1 > i
  j=i
  cntR=0
  cntL=0
  while true
    cntR+=1 if s[j]=="R"
    break if s[j]=="L"
    j+=1
  end
  while true
    cntL+=1 if s[j]=="L"
    break if s[j]=="R" || j==n-1
    j+=1
  end
  as << [cntR,cntL]
  i=j
end

ans=[0]*s.size
idx=-1
for i in 0...as.size
  idx+=as[i][0]
  ans[idx] = as[i].inject(:+)/2 if as[i].inject(:+).even? || (as[i].inject(:+).odd? && as[i][1].odd?)
  ans[idx] = 1+as[i].inject(:+)/2  if as[i].inject(:+).odd? && as[i][1].even?
  ans[idx+1]=as[i].inject(:+) - ans[idx]
  idx+=as[i][1]
end
puts ans.join(" ")


Measured memory_bytes: 7164
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool flag = true;
  int posx = 0;
  int posy = 0;
  int pret = 0;
  rep(i, N) {
    int t, x, y;
    cin >> t >> x >> y;
    int dist = abs(posx - x) + abs(posy - y);
    if (dist == (t - pret))
      ;
    else if (dist > (t - pret))
      flag = false;
    else if (((t - pret - dist) % 2))
      flag = false;
    posx = x;
    posy = y;
    pret = t;
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0) break;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if(i==0 || i==H-1){
                        System.out.print('#');
                    }else{
                        if(j==0 || j==W-1){
                            System.out.print('#');
                        }else{
                            System.out.print('.');
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 36224
#include <iostream>


using namespace std;
int main() {

    int a,b;

    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }


  else if(a!=1&&b!=1){

        if(a>b){
            cout<<"Alice"<<endl;
        }

        else{
cout<<"Bob"<<endl;
}
}

else if(a==1){
cout<<"Alice"<<endl;
}

else if(b==1){
cout<<"Bob"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main()
{
	int a, ac=0, wa=0, tle=0, re=0;
	cin >> a;
	for(int i=0; i<a; i++)
	{
		string str;
		cin >> str;
		if(str == "AC")
		{
			ac ++;
		}
		else if(str == "WA")
		{
			wa ++;
		}
		else if(str == "TLE")
		{
			tle ++;
		}
		else if(str == "RE")
		{
			re ++;
		}
	}
	cout << "AC x " << ac << '\n';
	cout << "WA x " << wa << '\n';
	cout << "TLE x " << tle << '\n';
	cout << "RE x " << re;
}



Measured memory_bytes: 3644
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x) cin >> x
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in(N);

    vll A(N);
    rep(i, N) in(A[i]);

    ll money = 1000;
    ll stock = 0;

    rep(i, N)
    {
        money += A[i] * stock;
        stock = 0;

        if (i < N - 1 && A[i] < A[i + 1])
        {
            stock += money / A[i];
            money %= A[i];
        }
    }

    outl(money);

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s;
  t="CODEFESTIVAL2016";
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int x;
    cin >> x;
    if (x < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 3640
N = int(input())
Alist = list(map(int,input().split()))
tmp = 0
ans = 0

for i in range(N):
  for j in range(N):
    if Alist[i] != Alist[j]:
      tmp = abs(Alist[i] - Alist[j])
    else:
      pass

    if tmp > ans:
      ans = tmp
    else:
      pass

print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		System.out.println(b-a == c-b ? "YES" : "NO");
	}
}


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

int main()
{
	int N, R, buy = 1e9 + 5, sell = 0, ans = -1e9 - 5;
	bool seek = false;
	cin >> N;
	for(int i = 0; i < N; ++i)
	{
		if(seek)
		{
			seek = false;
		}
		else
		{
			cin >> R;
		}
		
		if(R < buy)
		{
			buy = R;
			if(i + 1 < N)
			{
				seek = true;
				
				cin >> R;
				sell = R;
				
				if(sell - buy > ans)
				{
					ans = sell - buy;
				}
			}
		}
		else if(R > sell)
		{
			sell = R;
			
			if(sell - buy > ans)
			{
				ans = sell - buy;
			}
		}		
	}
	
	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1_1_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }

            else if (a > b)
            {
                Console.WriteLine("a > b");
            }

            else
            {
                Console.WriteLine("a == b");
            }

            
        }
    }
}



Measured memory_bytes: 15868
#include<stdio.h>
#define INF 1000000
int p[1000];
int w[1000];
int r[1001];
bool pos[1000][1000];
int dp[1001];

int sum(int a,int b){
	return r[b+1]-r[a];
}

int min(int a,int b){return a<b?a:b;}

int main(){
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d %d",&p[i],&w[i]);
	r[0]=0;
	for(i=0;i<n;i++)r[i+1]=r[i]+w[i];
	for(i=0;i<n;i++)for(j=0;j<n;j++)pos[i][j]=false;
	for(i=0;i<n;i++)pos[i][i]=true;
	for(int d=1;d<n;d++){
		for(i=0;i+d<n;i++){
			int a=i;
			int b=i+d;
			if(p[a]>=sum(a+1,b)&&pos[a+1][b])pos[a][b]=true;
			if(p[b]>=sum(a,b-1)&&pos[a][b-1])pos[a][b]=true;
		}
	}
	for(i=0;i<=n;i++)dp[i]=INF;
	dp[0]=0;
	for(i=0;i<n;i++){
		for(j=i+1;j<=n;j++){
			if(pos[i][j-1])dp[j]=min(dp[j],dp[i]+1);
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 2020
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
vector<pair<ll, int> > v;  
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        v.push_back(make_pair(a,i));
    }
    if(n==2){
        cout<<v[1].first<<"\n";
        cout<<v[0].first<<"\n";
        return 0;
    }
    sort(v.begin(),v.end());
    ll ans[n];
    REP(i,n){
        if((n-1)%2==1){
            if(i+1>(n-1)/2+1)
            ans[v[i].second]=v[(n-1)/2].first;
            else{
                ans[v[i].second]=v[(n-1)/2+1].first;
            }
        }
        else{
            if(i+1>(n-1)/2+1)
            ans[v[i].second]=(v[(n-1)/2-1].first+v[(n-1)/2].first)/2;
            else if(i==(n-1)/2+1){
                ans[v[i].second]=(v[(n-1)/2-1].first+v[(n-1)/2+1].first)/2;
            }
            else{
                ans[v[i].second]=(v[(n-1)/2].first+v[(n-1)/2+1].first)/2;
            }
        }
    }
    REP(i,n){
        cout<<ans[i]<<"\n";
    }
}

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

int main() {
    int x;
    cin >> x;

    ll ans = 0;
    int k = x / 500;
    ans += 1000 * k;
    x -= 500 * k;

    k = x / 5;
    ans += 5 * k;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;
int main(){
    ll X; cin>>X;
    ll ans=100;
    ll count=0;
    while(ans<X){
        ans=ans+ans*0.01;
        count++;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int N=100005;
vi A,B[10],p,q,res;
int n,K;

vi rev(vi a){
	vi b(n+1,0);
	rep(i,1,n)b[a[i]]=i;
	return b;
}

vi mul(vi a,vi b){
	vi c(n+1,0);
	rep(i,1,n)c[i]=a[b[i]];
	return c;
}

vi power(vi a,int p){
	vi res(n+1,0);
	rep(i,1,n)res[i]=i;
	for(;p;p>>=1,a=mul(a,a))
		if(p&1)res=mul(res,a);
	return res;
}

int main(){
	cin>>n>>K;
	p.resize(n+1,0);
	rep(i,1,n)cin>>p[i];
	q.resize(n+1,0);
	rep(i,1,n)cin>>q[i];
	A=power(mul(q,mul(rev(p),mul(rev(q),p))),(K-1)/6);
	if(K%6==4)A=mul(A,q);
	if(K%6==5||K%6==0)A=mul(A,mul(q,rev(p)));
	B[1]=p;
	B[2]=q;
	B[3]=mul(q,rev(p));
	B[4]=rev(p);
	B[5]=rev(q);
	B[6]=mul(rev(q),p);
	res=mul(A,mul(B[(K-1)%6+1],rev(A)));
	rep(i,1,n)printf("%d ",res[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 6648
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int x[100][100], H, W, maxn;
void solve(vector<pair<int, int>>vec, int X, int Y, int depth) {
	maxn = max(maxn, depth);
	if (x[X - 1][Y] == 1) {
		bool OK = true;
		for (int i = 0; i < vec.size(); i++) { if (vec[i] == make_pair(X - 1, Y))OK = false; }
		if (OK == true) {
			vector<pair<int, int>>vec2 = vec;
			vec2.push_back(make_pair(X - 1, Y));
			solve(vec2, X - 1, Y, depth + 1);
		}
	}
	if (x[X + 1][Y] == 1) {
		bool OK = true;
		for (int i = 0; i < vec.size(); i++) { if (vec[i] == make_pair(X + 1, Y))OK = false; }
		if (OK == true) {
			vector<pair<int, int>>vec2 = vec;
			vec2.push_back(make_pair(X + 1, Y));
			solve(vec2, X + 1, Y, depth + 1);
		}
	}
	if (x[X][Y - 1] == 1) {
		bool OK = true;
		for (int i = 0; i < vec.size(); i++) { if (vec[i] == make_pair(X, Y - 1))OK = false; }
		if (OK == true) {
			vector<pair<int, int>>vec2 = vec;
			vec2.push_back(make_pair(X, Y - 1));
			solve(vec2, X, Y - 1, depth + 1);
		}
	}
	if (x[X][Y + 1] == 1) {
		bool OK = true;
		for (int i = 0; i < vec.size(); i++) { if (vec[i] == make_pair(X, Y + 1))OK = false; }
		if (OK == true) {
			vector<pair<int, int>>vec2 = vec;
			vec2.push_back(make_pair(X, Y + 1));
			solve(vec2, X, Y + 1, depth + 1);
		}
	}
}
int main() {
	while (true) {
		cin >> W >> H; maxn = 0; if (W == 0 && H == 0)break;
		for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> x[i][j]; } }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if (x[i][j] == 0) continue;
				vector<pair<int, int>>vec3; vec3.push_back(make_pair(i, j)); solve(vec3, i, j, 1);
			}
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 3124
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    int n, k;
    E[] g;

    void run() {

        Scanner sc = new Scanner(System.in);

        n = sc.nextInt(); k = sc.nextInt();
        g = new E[n];
        for (int i = 0; i < n; i++) g[i] = new E();

        int[][] es = new int[n - 1][2];

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
            es[i][0] = a; es[i][1] = b;
            g[a].add(b);
            g[b].add(a);
        }

        int ans = 0;

        if (k % 2 == 0) {
            for (int i = 0; i < n; i++) {
                boolean[] visited = new boolean[n];
                ans = Math.max(ans, dfs(i, k / 2, visited));
            }
        } else {
            for (int i = 0; i < n - 1; i++) {
                boolean[] visited = new boolean[n];
                visited[es[i][0]] = visited[es[i][1]] = true;
                int tmp = dfs(es[i][0], k / 2, visited) + dfs(es[i][1], k / 2, visited);
                ans = Math.max(ans, tmp);
            }
        }

        System.out.println(n - ans);
    }

    int dfs(int c, int k, boolean[] visited) {
        visited[c] = true;
        if (k == 0) {
            return 1;
        }
        int sum = 1;
        for (int next: g[c]) if (!visited[next]) {
            sum += dfs(next, k - 1, visited);
        }
        return sum;
    }

    class E extends ArrayList<Integer>{}

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 63604
#include <cstdio>
#include <cstring>

using namespace std;

int N;
char S[10005], ans[10005];

int main()
{
    scanf("%d", &N);
    scanf(" %s", &S);
    for (int i = 0; i < strlen(S); i++)
    {
        ans[i] = (S[i] - 'A' + N) % ('Z' - 'A' + 1) + 'A';
    }
    printf("%s\n", ans);
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
    int a, b, c, count;
    count = 0;
    cin >> a >> b >> c;
    for (int i=a; a<=b; a++) {
        if (c%a==0) {
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3092
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define asd(n) rep(i, 0, n)
#define jkl(n) rep(j, 0, n)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    vpii a(n);
    cin >> a;
    asd(n -2) {
        if (a[i].first == a[i].second && a[i + 1].first == a[i + 1].second &&a[i + 2].first == a[i + 2].second){
            put("Yes");
            return;
        }
    }
    put("No");
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}


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

int main(void) {
  ll N, K;
  cin >> N >> K;

  cout << ((N + 1) / 2 >= K ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Me3za() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL))
#define endl "\n"
int n,k;
int l;
int arr[100005];
long long mem[100005];
long long solve(int i,long long cur,int prev){
if(i>=n-1)return 0;
if(mem[i]!=-1)return mem[i];
mem[i]=LLONG_MAX;
for(int j=1;i+j<=min(i+k,n-1);j++){
   long long sol=solve(i+j,arr[i+j],i)+abs(cur-arr[i+j]);
   //cout<<i<<" "<<sol<<" "<<i+j<<" "<<min(k,n-i)<<endl;
   mem[i]=min(sol,mem[i]);
}
return mem[i];
}
int main() {
Me3za();
cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>arr[i];
}
memset(mem,-1,sizeof mem);
cout<<solve(0,arr[0],0);
}



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

void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //
bool isprime(ll n)
{
    if(n%2==0)return false;
    for(int i=3;i<=sqrt(n);i+=2)
    {
        if(n%i==0)return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//    input();
    ll n,ans=0,k;
    cin>>n>>k;
    array(a,n);
    sortall(a);
    rep(i,0,k)
    {
    	ans+=a[i];
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3684
function main(input) {
  var splited = input.split(" ")
  var num = Number(splited[0])
  var x = Number(splited[1])
  if (num === 1) {
	return console.log(x)
  }
  var min = (x - (num - 1))
  var max = (x + (num - 1))
  var size = num + (num - 1)
  var availableList = [...Array(size).keys()].map(i => i + min)
  console.log(availableList.join(' '))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
class UnionFind
  def initialize(n)
    @n = n
    @parent = Array.new(n){|i|i}
    @rank = Array.new(n, 0)
  end

  def find(x)
    if @parent[x] == x
      return x
    else
      return @parent[x] = find(@parent[x])
    end 
  end

  def unite(x, y)
    x = find(x)
    y = find(y)
    return if x == y
    if @rank[x] < @rank[y]
      @parent[x] = y
    else
      @parent[y] = x
      @rank[x] += 1 if @rank[x] == @rank[y]
    end
  end

  def same?(x, y)
    find(x) == find(y)
  end
end

def combi(n)
  n*(n-1)/2
end

n,m=gets.split.map(&:to_i)
bridges=m.times.map{gets.split.map{|v|v.to_i-1}}
connected_num=Array.new(n,1)
uf=UnionFind.new(n)
ans=[combi(n)]
bridges.reverse_each{|a,b|
  if uf.same?(a,b)
    ans << ans.last
  else
    na=connected_num[uf.find(a)]
    nb=connected_num[uf.find(b)]
    uf.unite(a,b)
    root=uf.find(a)
    connected_num[root]=na+nb
    ans << ans.last+combi(na)+combi(nb)-combi(na+nb)
  end
}
ans.pop
puts ans.reverse

Measured memory_bytes: 14772
#include<string>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<iostream>
using namespace std;
long long num[100];
 
int main(){
	int n;
	cin >>n;
	int sum=n*n*n;
	cout<<sum<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

#define MYSCAN scanf

int main(void){
	int n, pm, pe, pj;

	while (true){

		MYSCAN("%d", &n);
		if (n == 0){ break; }
		for (int i = 0; i < n; i++){
			MYSCAN("%d%d%d", &pm, &pe, &pj);
			if (pm == 100 || pe == 100 || pj == 100){
				printf("A\n");
			}
			else if (pm + pe >= 180){
				printf("A\n");
			}
			else if (pm + pe + pj >= 240){
				printf("A\n");
			}
			else if (pm + pe + pj >= 210){
				printf("B\n");
			}
			else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)){
				printf("B\n");
			}
			else{
				printf("C\n");
			}	
		}
	}	
	return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
using namespace std;
int zh(string s)
{
	int tmp=0;
	for(int i=0;i<s.size();i++)
	   tmp=tmp*10+(s[i]-'0');
	   return tmp;
	
}
int main()
{
	string a,b;
	cin>>a>>b;
	int x=zh(a+b);
	if(int(sqrt(x))==sqrt(x))
	   cout<<"Yes";
	else
	   cout<<"No";
	   
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

/**
 * 挿入ソート
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=ja">ALDS1_1_A</a>
 */
public class Main {

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

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		insertionSort(a, n);

		sc.close();
	}

	private static void insertionSort(int[] a, int n) {
		for (int i = 0; i < n; i++) {
			int v = a[i];
			int j = i - 1;
			while (j >= 0 && a[j] > v) {
				a[j + 1] = a[j];
				j--;
			}
			a[j + 1] = v;
			System.out.println(Arrays.toString(a).replace("[", "").replace("]", "").replace(",", ""));
		}
	}

}



Measured memory_bytes: 32264
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

from fractions import gcd
from functools import reduce

if max(A) < K:
    print("IMPOSSIBLE")
    quit()

g = reduce(gcd, A)
for a in A:
    if gcd(a, K) == g:
        print("POSSIBLE")
        quit()

print("IMPOSSIBLE")

Measured memory_bytes: 14252
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (long long i = 0; i < (n); ++i)
#define rep(i, a, b) for (long long i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

typedef long long ll;
long long p;

ll mpow(ll x, ll n)
{
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % p;
        x = x * x % p;
        n = n >> 1;
    }
    return ans;
}
int main(void)
{
    long long n;
    cin >> n;

    long long a[n], sum[n];
    cin >> p;
    map<long, long> mp;
    ll ans = 0;

    string s;
    cin >> s;

    if (10 % p == 0) // 2 ,5
    {
        REP(r, n)
        {
            if ((s[r] - '0') % p == 0)
            {
                ans += r + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    sum[0] = 0;
    mp[0]++;
    reverse(s.begin(), s.end());
    REP(i, s.length())
    {
        int num = s[i] - '0';
        a[i] = (num * mpow(10, i)) % p;
        sum[i + 1] = (a[i] + sum[i]) % p;

        mp[sum[i + 1]]++;
    }
    for (auto i : mp)
    {
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4100
n = int(input())
mon = list(map(int, input().split()))
g = min(mon)
div = []
for i in range(1, g + 1):
  if (g % i == 0):
    div.append(i)
    div.append(g // i)
  if (i * i > g):
    break
div.sort(reverse=True)
for d in div:
  mod = []
  for m in mon:
    mod.append(m % d)
  if (list(set(mod)) == [0]):
    print(d)
    break

Measured memory_bytes: 14252
import queue

H,W = map(int,input().split())
s = [ list(input()) for _ in range(H)]

count = 0
for i in range(H):
	for j in range(W):
		if s[i][j] == '.':
			count += 1

ans = [[0 for _ in range(W)] for _ in range(H)]

q = queue.Queue()

def bfs(x,y):
	global q
	global c
	q.put([x,y])
	s[y][x] = '#'
	while not q.empty():
		x,y = q.get()
		if [x,y] == [W-1,H-1]:
			return ans[H-1][W-1]
		if x > 0 and s[y][x-1] == '.':
			q.put([x-1,y])
			ans[y][x-1] = ans[y][x] + 1
			s[y][x-1] = '#'
		if x < W-1 and s[y][x+1] == '.':
			q.put([x+1,y])
			ans[y][x+1] = ans[y][x] + 1
			s[y][x+1] = '#'
		if y > 0 and s[y-1][x] == '.':
			q.put([x,y-1])
			ans[y-1][x] = ans[y][x] + 1
			s[y-1][x] = '#'
		if y < H-1 and s[y+1][x] == '.':
			q.put([x,y+1])
			ans[y+1][x] = ans[y][x] + 1
			s[y+1][x] = '#'

	return -1

bfs = bfs(0,0)
if bfs == -1:
	print(-1)
else:
	print(count-bfs-1)


Measured memory_bytes: 4080
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	getLine
	as <- map pred <$> readInts
	bs <- readInts
	cs <- readInts
	print $ solve as bs cs

solve [a] bs _ = bs !! a
solve (a1:a2:as) bs cs = bs !! a1 + ( if a1 + 1 == a2 then cs !! a1 else 0 ) + solve (a2:as) bs cs

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

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


Measured memory_bytes: 3720
n = gets.to_i
as = gets.split.map(&:to_i).sort!

ans = 0
length = 0

as.each_with_object(Hash.new(0)) { |a, h| h[a] += 1 }
  .each do |k, v|
  next if v < 2

  s = length * k
  s = [length * k, k ** 2].max if v >= 4

  ans = s if s >= ans
  length = k
end

puts ans


Measured memory_bytes: 14960
import Data.List

main = interact $ unlines . map (show' . luck_manipulator) . read' . lines
 where
  read' ("0 0 0 0 0":_) = []
  read' (nabcx:rs:xs) = ((n,a,b,c,x), map read (words rs)) : read' xs
   where [n,a,b,c,x] = map read (words nabcx)
  show' r = case r of {Nothing -> "-1"; (Just x) -> show x}

luck_manipulator ((n,a,b,c,x),rs) =
 case (foldl1 push $ map (\r -> findIndices (== r) rand) rs) of {[] -> Nothing; (x:xs) -> Just x}
  where
   push [] _ = []
   push _ [] = []
   push xs1 xs2 = dropWhile (<= minimum xs1) xs2
   rand = take 10001 (iterate (\x -> (a*x + b) `mod` c) x) 

Measured memory_bytes: 7448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long n,k;cin >> n >> k;
    long long arr[n],sum = 0;
    for(int i = 0;i < n;i++)cin >> arr[i];
    sort(arr,arr + n);
    for(int i = 0;i < n - k;i++)sum += arr[i];
    cout << sum << endl;
    return 0;
}


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

int main()
{
    int N, T, cost=1<<30, num=-1;
    cin >> N>>T;
    vector<int> n(N);
    vector<int> t(N);

    for (int i = 0; i < N; i++){
        cin >> n.at(i)>> t.at(i);
        if(t.at(i)<=T){
            cost = min(n.at(i), cost);
            if(n.at(i)=cost){
                num = i;
            }

        }
    }
    if(num==-1){
        cout << "TLE" << endl;
    }
    else{
        cout << n.at(num) << endl;
    }

}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

const int inf = 1e9 + 7;
const ll inf_ll = 1e18L + 7;

template <typename T>
void mini(T& a, T b) {
  a = min(a, b);
}

template <typename T>
void maxi(T& a, T b) {
  a = max(a, b);
}

// dp(i) <-- true, if first player wins and i stones remaining.
int main() {
  int n, K;
  scanf("%d %d", &n, &K);
  std::vector<int> stones(n);
  for (int& s : stones) scanf("%d", &s);

  std::vector<bool> dp(K + 1, false);
  for (int rem = 0; rem <= K; ++rem)
    for (int s : stones) {
      if (rem - s >= 0 && !dp[rem - s]) dp[rem] = true;
    }

  cout << (dp[K] ? "First" : "Second") << endl;
  return 0;
}


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

using namespace std;

struct DATA{
  int info1;
  int info2;
};

vector<DATA> Convert(vector<DATA>);
int getTime(vector<DATA>, int, int);

int main(){
  int i, n, m, r, q, time, log, t1, t2, ans;
  DATA _data;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    vector< vector<DATA> > data1(m), data2;
    cin >> r;

    for(i=0; i<r; ++i){
      cin >> time >> n >> m >> log;
      _data.info1 = time;
      _data.info2 = log;
      data1[m-1].push_back(_data);
    }

    for(i=0; i<data1.size(); ++i)
      data2.push_back(Convert(data1[i]));

    cin >> q;

    for(i=0; i<q; ++i){
      cin >> t1 >> t2 >> m;
      cout << getTime(data2[m-1], t1, t2) << endl;
    }
  }
  return 0;
}

vector<DATA> Convert(vector<DATA> data1){
  int i, j, in_count, out_count;
  DATA _data;
  vector<DATA> data2;

  i = 0;
  j = i;
  in_count = 0;
  out_count = 0;
  while(j < data1.size()){
    if(data1[j].info2 == 1) ++in_count;
    else ++out_count;

    if(in_count == out_count){
      _data.info1 = data1[i].info1;
      _data.info2 = data1[j].info1;
      data2.push_back(_data);
      i = j + 1;
      in_count = 0;
      out_count = 0;
    }
    ++j;
  }

  return data2;
}

int getTime(vector<DATA> data, int start, int end){
  int i, ans;

  for(i=0, ans=0; i<data.size(); ++i){
    if(start < data[i].info1 && data[i].info1 < end && end < data[i].info2)
      ans += (end - data[i].info1);
    else if(data[i].info1 < start && start < data[i].info2 && data[i].info2 < end)
      ans += (data[i].info2 - start);
    else if(data[i].info1 < start && end < data[i].info2)
      ans += (end - start);
    else if(start <= data[i].info1 && data[i].info2 <= end)
      ans += (data[i].info2 - data[i].info1);
  }
  return ans;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int dp[100009];
vector<int>v;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s,ans;
    vector<int>v;
    rep(i,0,h){
        string ss;
        cin>>ss;
        bool c=false;
        rep(j,0,w){
            if(ss.at(j)=='#')c=true;
        }
        if(c)s.push_back(ss);
    }

    rep(i,0,w){
        bool c=false;
        rep(j,0,s.size()){
            if(s.at(j).at(i)=='#')c=true;
        }
        if(c)v.push_back(i);
    }
    /*for(auto p:v){
        cout<<p<<endl;
    }*/

    ans.resize(s.size());
    rep(i,0,s.size()){
        string sa="";
        for(auto j:v){
            sa.push_back(s.at(i).at(j));
        }
        ans.at(i)=sa;
    }

    rep(i,0,s.size()){
        cout<<ans.at(i)<<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
    int a, b; cin >> a >> b;
    if (a == 2 || b == 2) {
        puts("No");
    }
    else {
        puts("Yes");
    }

    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))
p=[(i+1)/2 for i in p]
a=sum(p[0:k])
b=a
for i in range(0,n-k):
  a=a-p[i]+p[i+k]
  b=max(a,b)
print(b)

Measured memory_bytes: 77448
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    string s;
    cin>>s;
    bool a[2]={};
    rep(i,3){
        a[s[i]-'A']=true;
    }

    Yes(a[0]&&a[1]);


}

Measured memory_bytes: 256
from math import ceil,sqrt
from bisect import bisect_right, bisect_left

def trial_division(n):  
  if n == 2:
    return True
  if n < 2 or n % 2 == 0:
    return False
  for i in range(3, int(ceil(sqrt(n))) + 1, 2):
    if n % i == 0:
      return False
  return True

import sys
input = lambda: sys.stdin.readline().rstrip()
q = int(input())

primes = [i for i in range(10**5+10) if trial_division(i)]  
p2017 = []
for i in range(len(primes)-1):
  if trial_division((primes[i]+1)//2):
    p2017.append(primes[i])
    
for i in range(q):
  l,r = map(int,input().split())  
  print(bisect_right(p2017,r) - bisect_left(p2017,l))  

Measured memory_bytes: 4276
#include<cstdio>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}
}

Measured memory_bytes: 2596