akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int H, W; scanf("%d %d", &H, &W);
  vector<vector<int> > cost(10, vector<int>(10, 0));
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      scanf("%d", &cost[i][j]);
    }
  }
  for (int k = 0; k < 10; ++k) {
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 10; ++j) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  int a;
  int ans = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      scanf("%d", &a);
      if (a != -1) {
        ans += cost[a][1];
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

long n;
string s,ans;

string test(string a) {
  while(a.size()!=n) {
    if(a.substr(a.size()-2,2)=="SS") {
      if(s[a.size()-1]=='o') a+="S";
      else a+="W";
    } else if(a.substr(a.size()-2,2)=="SW") {
      if(s[a.size()-1]=='o') a+="W";
      else a+="S";
    } else if(a.substr(a.size()-2,2)=="WS") {
      if(s[a.size()-1]=='o') a+="W";
      else a+="S";
    } else {
      if(s[a.size()-1]=='o') a+="S";
      else a+="W";
    }
  }
  return a;
}

void aaa(string b) {
  ans=test(b);
  bool x=false;
  if(ans[0]=='S') {
    if(s[0]=='o'&&ans.back()!=ans[1]) x=true;
    if(s[0]=='x'&&ans.back()==ans[1]) x=true;
  } else {
    if(s[0]=='x'&&ans.back()!=ans[1]) x=true;
    if(s[0]=='o'&&ans.back()==ans[1]) x=true;
  }
  if(ans.back()=='S') {
    if(s.back()=='o'&&ans[n-2]!=ans[0]) x=true;
    if(s.back()=='x'&&ans[n-2]==ans[0]) x=true;
  } else {
    if(s.back()=='x'&&ans[n-2]!=ans[0]) x=true;
    if(s.back()=='o'&&ans[n-2]==ans[0]) x=true;
  }
  if(x) ans="-1";
  return;
}

int main() {
  cin >> n >> s;
  aaa("SS");
  if(ans=="-1") aaa("SW");
  if(ans=="-1") aaa("WS");
  if(ans=="-1") aaa("WW");
  cout << ans << endl;
}

Measured memory_bytes: 896
H, W = map(int, input().split())
N = int(input())
As = list(map(int, input().split()))
L = []
for i in range(N):
  A = As[i]
  L = L + [i+1]*A
for h in range(H):
  l = L[h*W:(h+1)*W]
  if h%2 == 1:
    l.reverse()
  print(" ".join(map(str, l)))


Measured memory_bytes: 3572
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val dl = Vector.fill(n)(sc.nextInt).sorted

  val upper = dl(n / 2 )
  val lower = dl(n / 2 - 1)

  val res =
    if(upper == lower) 0
    else upper - lower

  println(res)
}

Measured memory_bytes: 52496
#include <iostream>
#include <malloc.h>
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z -> key = k;
    z -> left = NIL;
    z -> right = NIL;
    
    while( x != NIL){
        y = x;
        if(z -> key < x -> key){
            x = x -> left;
        }else{
            x = x -> right;
        }
    }
    z -> parent = y;
    if(y == NIL){
        root = z;
    }else{
        if(z -> key < y -> key){
            y -> left = z;
        }else{
            y -> right = z;
        }
    }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u -> left);
    cout << " " << u -> key;
    inorder(u -> right);
}
void preorder(Node *u){
    if(u == NIL)return;
    cout << " " << u->key;
    preorder(u -> left);
    preorder(u -> right);
}
int main(void){
    // Your code here!
    int n, i, x;
    string com;
    
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }else if( com == "print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 26580
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  map<string, int> s;
  string t[] = {"AC", "wA", "TLE", "RE"};
  rep(i, n) {
    string str;
    cin >> str;
    if (str == "AC") ++s[t[0]];
    if (str == "WA") ++s[t[1]];
    if (str == "TLE") ++s[t[2]];
    if (str == "RE") ++s[t[3]];
  }

  cout << "AC x " << s[t[0]] << endl;
  cout << "WA x " << s[t[1]] << endl;
  cout << "TLE x " << s[t[2]] << endl;
  cout << "RE x " << s[t[3]] << endl;

  return 0;
}

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

typedef long long i64;
const int N = 100005;
const int MAXN = 32;

i64 x[N << 1], v[N << 1], suc[N << 1], pre[N << 1];

int main ()
{
    i64 n, c;
    scanf("%lld %lld", &n, &c);
    for (i64 i = 1; i <= n; ++i) scanf("%lld %lld", x + i, v + i);
    for (i64 i = n + 1; i <= 2 * n; ++i) x[i] = x[i - n], v[i] = v[i - n];
    suc[n] = max(0ll, v[n] - c + x[n]); for (int i = n - 1; i >= 1; --i) v[i] += v[i + 1], suc[i] = max(suc[i + 1], v[i] - c + x[i]);
    i64 ans = 0;
    for (i64 i = n + 1; i <= 2 * n; ++i) {
        if (i != n + 1) v[i] += v[i - 1];
        ans = max(ans, v[i] - x[i]);
        ans = max(ans, v[i] - 2 * x[i] + suc[i - n + 1]);
    }
    pre[n + 1] = max(0ll, v[n + 1] - x[n + 1]);
    for (i64 i = n + 2; i <= 2 * n; ++i) pre[i] = max(pre[i - 1], v[i] - x[i]);
    for (i64 i = n; i >= 1; --i) {
        ans = max(ans, v[i] - c + x[i]);
        ans = max(ans, v[i] - 2 * c + 2 * x[i] + pre[i + n - 1]);
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p.begin(), p.end());
  for (int i = 1; i <= N; i++) {
    cout << N * i + p[i - 1].second << " ";
  }
  cout << endl;
  for (int i = 1; i <= N; i++) {
    cout << N * (N - i + 1) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define N 40000

int main()
{
    int h, w;
    bool s[400];
    int d[400][400];

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c; cin >> c;
            s[i * w + j] = c == '.';
        }
    }
    for (int i = 0; i < h * w; i++) {
        for (int j = 0; j < h * w; j++) {
            if (not s[i] || not s[j]) {
                d[i][j] = N;
            } else if (i == j) {
                d[i][j] = 0;
            } else {
                d[i][j] = N;
            }
        }
    }

    while (true) {
        bool flag = false;
        for (int p = 0; p < h * w; p++) {
            if (not s[p]) continue;
            int x = p / w;
            int y = p % w;
            for (int i = max(0, x - 1); i < min(h, x + 2); i++) {
                for (int j = max(0, y - 1); j < min(w, y + 2); j++) {
                    if ((x - i) * (y - j) != 0) continue;
                    if (not s[i * w + j]) continue;
                    for (int k = 0; k < h * w; k++) {
                        if (not s[k]) continue;
                        if (d[p][k] > d[i * w + j][k] + 1) {
                            d[p][k] = d[i * w + j][k] + 1;
                            d[k][p] = d[i * w + j][k] + 1;
                            flag = true;
                        }
                    }
                }
            }
        }
        if (not flag)
            break;
    }

    int m = 0;
    for (int i = 0; i < h * w; i++) {
        for (int j = 0; j < h * w; j++) {
            // printf("%5d ", d[i][j]);
            if (d[i][j] == N) continue;
            m = max(d[i][j], m);
        }
        // cout << endl;
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 4236
#include <bitset>
#include <string>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
using ll = unsigned long long;

class Kitei
{
  vector<ll> bases;

public:
  ll normalize(ll a)
  {
    // cout << "normalize" << bitset<8>(a);
    for (auto base : bases)
    {
      if ((a ^ base) < a)
      {
        a = a ^ base;

        // cout << "->" << bitset<8>(a);
      }
    }
    // cout << endl;
    return a;
  }
  void add(ll a)
  {
    a = normalize(a);
    if (a != 0)
    {
      bases.push_back(a);
      sort(bases.begin(), bases.end(), greater<ll>());
    }
  }
  bool contain(ll a)
  {
    a = normalize(a);
    return a == 0;
  }
  void print()
  {
    for (auto base : bases)
    {
      cout << bitset<8>(base) << " ";
    }
    cout << endl;
  }
};
bool solve()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  string S;
  cin >> S;
  Kitei kitei;
  for (int i = N - 1; i >= 0; i--)
  {
    if (S[i] == '0')
    {
      kitei.add(A[i]);
      // cout << "Adding " << A[i] << endl;
      // kitei.print();
    }
    else
    {
      // cout << "Checking " << A[i] << endl;
      // kitei.print();
      if (!kitei.contain(A[i]))
        return false;
    }
  }
  return true;
}
int main()
{
  ll T;
  cin >> T;

  for (int c = 0; c < T; c++)
  {
    cout << (solve() ? 0 : 1) << endl;
  }
}

Measured memory_bytes: 3612
//グローバル変数定義
var N = 0;
var A = 0;
var B = 0;
var C = 0;
var T = [];	//N本の竹の長さを配列BBに格納する

function rec(name, cur, a){

  var LastMP = Infinity;
  
  //回答が書き込まれる変数(要素数N個分)
  for(var a=0 ; a<4 ; a++){
    for(var b=0 ; b<4 ; b++){
      for(var c=0 ; c<4 ; c++){
        for(var d=0 ; d<4 ; d++){
          for(var e=0 ; e<4 ; e++){
            for(var f=0 ; f<4 ; f++){
              for(var g=0 ; g<4 ; g++){
  		        for(var h=0 ; h<4 ; h++){
                  //計算処理
                  var memo = [a,b,c,d,e,f,g,h];
                  var ans0 = 0; //何にも使わない
                  var ansA = 0; //A用回答
                  var cntA = 0; //A用カウンタ
                  var ansB = 0; //B用回答
                  var cntB = 0; //B用カウンタ
                  var ansC = 0; //C用回答
                  var cntC = 0; //C用カウンタ
				  for(var i=0 ; i<N ; i++){
                    if( memo[i]==1 ){
                      ansA += T[i];
                      cntA += 1;
                    } else if (memo[i]==2){
                      ansB += T[i];
                      cntB += 1;
                    } else if (memo[i]==3){
                      ansC += T[i];
                      cntC += 1;
                    } else {
                      //何にも使わない＝何もしない
                    }
                  }
                  //安全装置
                  if(cntA*cntB*cntC > 0){
                    
                    //console.log(memo,ansA,ansB,ansC);
                    
                    //使用MP計算処理
                    var MP = 0;
                    //A用
                    MP += Math.abs(ansA-A);
                    MP += 10 * ( cntA -1 );
                    //B用
                    MP += Math.abs(ansB-B);
                    MP += 10 * ( cntB -1 );
                    //C用
                    MP += Math.abs(ansC-C);
                    MP += 10 * ( cntC -1 );
                    //MPの記録
                    if( LastMP > MP ){
                      LastMP = MP;
                    }
                  }
                  //無駄防止機能
                  //h=4;
                }
                //無駄防止機能
                //g=4;
              }
              //無駄防止機能
              //f=4;
            }
          }
        }
      }
    }
  }
  return LastMP;
}
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  N = Number.parseInt(inputStr[0]);
  A = Number.parseInt(inputStr[1]);
  B = Number.parseInt(inputStr[2]);
  C = Number.parseInt(inputStr[3]);
  //N本の竹の長さを配列BBに格納する
  for( var i=0 ; i<N ; i++ ){
    T.push(Number.parseInt(input[i+1].split(" ")));
  }
  var aaa = rec("start",0,0);
  console.log(aaa);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 12108
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++) {
					int sum = i + j;
					if (sum % 2 == 0) {
						System.out.printf("#");
					} else {
						System.out.printf(".");
					}
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}
}



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

int main() {
  char a, b;
  cin >> a >> b;
  
  if ((a== 'H' && b=='H') || (a=='D' && b=='D')) cout << 'H' <<endl;
  else cout << 'D' << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int n, k, d, x;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    set<int>st;
    cin >> n >> k;
    while(k--)
    {
        cin >> d;
        while(d--)
            cin >> x, st.insert(x);
    }
    cout << n - st.size();
    return 0;
}


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

using namespace std;

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

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	ll n;
	cin >>n;
	ll sol = 0;
	for (ll i=2 ;  ; i++) {
		if (n == 1) break;
		if (i*i>n) {
			sol++;
			break;
		}
		int br = 0;
		while (n%i == 0) {
			n/=i;
			br++;
		}
		for (int j=1 ; ; j++) {
			if (j>br) break;
			br-=j;
			sol++;
		}
	}
	cout <<sol<<endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		String N = in.nextLine();

		if(N.substring(0,1).equals(N.substring(1,2))&&N.substring(0,1).equals(N.substring(2,3))) {
			System.out.println("Yes");
			System.exit(0);
		}
		if(N.substring(1,2).equals(N.substring(2,3))&&N.substring(1,2).equals(N.substring(3,4))) {
			System.out.println("Yes");
			System.exit(0);
		}
		
		System.out.println("No");
		
		
		in.close();
	}
}

Measured memory_bytes: 21844
# https://atcoder.jp/contests/abc144/tasks/abc144_c

n=int(input())

def divisors(n):
    div=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            div.append(i)
            if i!=n//i:
                div.append(n//i)
    div.sort()
    return div

div=divisors(n)

ans=float('inf')
for e in div:
    ans=min(ans,(e+n//e)-2)
print(ans)

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s,t;
  cin>>s>>t;
  int ans=INF;
  rep(i,s.size() ){
    int num;
    if((i+t.size()) > s.size()) break;
    num=t.size();
    rep(j,t.size() ){
      
      if(t[j]==s[i+j]) num--;
    }
    ans=min(ans,num);
    // cout<<num<<endl;
    
  }
  cout<<ans<<endl;
  
  
  
  return 0;
}


Measured memory_bytes: 3652
#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() {
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
    }

    int c[H][W];
    int acnt = 0;
    int now = 0;
    for (int i = 0; i < H; i++){
        if(i%2 == 0){
            for (int j = 0; j < W; j++){
                if(now == 0){
                    now = a[acnt];
                    acnt++;
                }
                c[i][j] = acnt;
                now--;
            }
        } else {
            for (int j = W-1; j >= 0; j--){
                if(now == 0){
                    now = a[acnt];
                    acnt++;
                }
                c[i][j] = acnt;
                now--;
            }
        }
    }

    rep(i, H){
        rep(j, W){
            cout << c[i][j];
            if(j == W-1){
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3664
import sys
n, k = map(int, input().split())

if k % 2 == 1:
    print((n // k)**3)
    sys.exit()

# 偶数の時は初項が1/2、公差kの数列から選べる
x = (n - k // 2) // k + 1

print((n // k)**3 + x**3)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int t=a[0],cnt=1;
  for(int i=1;i<n;i++){
    if(a[i]==t){
      cnt--;
      t=0;
    }
    else{
      cnt++;
      t=a[i];
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INIT_YEN 1000000000000000
#define INF 1000000000000000
#define MAX_N 100000
using namespace std;

struct Edge {
    int k;
    long v;
    bool operator>(const Edge &e) const {
        return v > e.v;
    }
};

void find_shortest_paths(long d[], vector<Edge> es[], int n, int s, int t) {
    bool used[n + 1];
    for (int i = 1; i <= n; i++) {
        d[i] = INF;
        used[i] = false;
    }
    priority_queue<Edge, vector<Edge>, greater<Edge> > pque;
    pque.push(Edge {s, 0});
    while (!pque.empty()) {
        auto t = pque.top();
        pque.pop();
        if (used[t.k])
            continue;
        d[t.k] = t.v;
        used[t.k] = true;
        for (auto e: es[t.k]) {
            pque.push(Edge {e.k, t.v + e.v});
        }
    }
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    vector<Edge> es_a[MAX_N + 1], es_b[MAX_N + 1];
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        scanf("%d %d %d %d", &u, &v, &a, &b);
        es_a[u].push_back(Edge {v, a});
        es_a[v].push_back(Edge {u, a});
        es_b[u].push_back(Edge {v, b});
        es_b[v].push_back(Edge {u, b});
    }
    long d_a[n + 1], d_b[n + 1];
    find_shortest_paths(d_a, es_a, n, s, t);
    find_shortest_paths(d_b, es_b, n, t, s);

    long ans[n];
    ans[n - 1] = INIT_YEN - d_a[n] - d_b[n];
    for (int i = n - 2; i >= 0; i--) {
        ans[i] = max(INIT_YEN - d_a[i + 1] - d_b[i + 1], ans[i + 1]);
    }
    for (long x: ans) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 23436
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		long A = in.nextLong();
		long B = in.nextLong();
		long K = in.nextLong();

		long a=A;
		long b=B;
		long k=K;

		if (A < K) {
			a = 0;
			k = k - A;
			b = b < k ? 0 : b - k;
		} else {
			a=a-k;
		}

		System.out.println(a+" "+b);

	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

int main(){
    double M,count=0,sum=0;
    int N;

    cin >> N >> M;
    vector<double> A(N);
for(int i=0;i<N;i++){
    cin >> A[i];
    sum=sum+A[i];
    }
double min = sum/4/M;

    for(int i=0;i<N;i++){
    if(A[i]>=min)
        count++;
    }
    if(count>=M)
    cout << "Yes" <<endl;
    else
    cout << "No" <<endl;   
}

Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc163/tasks/abc163_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int flag = 0;
		for(int i=0;i<m;i++) {
			flag = flag + sc.nextInt();
		}
		sc.close();

		if(n==flag) {
			System.out.println(0);
		} else if(n>flag) {
			System.out.println(n-flag);
		}else {
			System.out.println(-1);
		}



	}
}


Measured memory_bytes: 39204
package main

import "fmt"

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)
	l  := make([]int, M)
	ls := make([][]int, N)

	for i:=0; i<M; i++{
		var tmp int
		fmt.Scan(&tmp)
		l[i] = tmp
	}

	for i:=0; i<N; i++ {
		t  := make([]int, M)
		for j := 0; j < M; j++ {
			var tmp int

			fmt.Scan(&tmp)
			t[j] = tmp
		}
		ls[i] = t
	}

	ans := 0

	for i:=0; i<N; i++ {
		count:=0
		for j := 0; j < M; j++ {
			count += ls[i][j] * l[j]
		}
		if count+C > 0{
			ans++
		}
	}


		fmt.Println(ans)
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
 
#define tate 3
#define yoko 3
#define Total (tate*yoko)

extern inline void down_0(void);
extern inline void up_0(void);
extern inline void right_0(void);
extern inline void left_0(void);

extern int  serch(int x, int y, int MaxCnt, int pre);
extern int  check(void);

int cnt,num = 0;
int val[Total] ={};


int main( void )
{
    int i = 0;
    int x,y = 0;
    
    for(i=0; i<Total; i++)
    {
        scanf("%d",&val[i]);
        
        if(val[i] == 0)
        {
            num = i;
        }
    }
    
    x = tate - (num/yoko) -1;
    y = yoko - (num%yoko) -1;
    
//    printf("%d,%d\n",x,y);
    
    for(i=0; i<45; i++)
    {
        if( serch(x,y,i,4) == 1 )
        {
            printf("%d\n",i);
            break;
        }
    }     
    
    return 0;
}

int serch(int x, int y, int MaxCnt, int pre)
{
    int result;
    int i=0;
    
    // 最大数で打ち切り
    if(MaxCnt==0)
    {
        return check();
    }
    
    for(i=0; i<4; i++)
    {
        result = 0;
        
        switch(i)
        {
            case 0:
                if( (x > 0) && (pre != 3) )
                {
                    down_0();
                    
                    result = serch(x-1, y, MaxCnt-1, 0);
                    
                    up_0();
                }
                break;
            case 1:
                if( (y > 0) && (pre != 2) )
                {
                    right_0();
                    
                    result = serch(x, y-1, MaxCnt-1, 1);
                    
                    left_0();
                }
                break;
            case 2:
                if( (y < yoko -1 ) && (pre != 1) )
                {
                    left_0();
                    
                    result = serch(x, y+1, MaxCnt-1, 2);
                    
                    right_0();
                }
                break;
            case 3:
                if( (x < tate -1 ) && (pre != 0) )
                {
                    up_0();
                    
                    result = serch(x+1, y, MaxCnt-1, 3);
                    
                    down_0();
                }
                break;
            default:
                break;
        }
        
        if(result)
        {
            return 1;
        }
        
    }

    return 0;
}

// TRUE : 完成
// FALSE : 失敗
int check()
{
    int i=0;
    
//    printf("%d%d%d%d%d%d%d%d%d\n", val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7], val[8]);
    
    for(i=0; i<Total-1; i++)
    {
        if(val[i] != (i+1))
        {
            return 0;
        }
    }
    return 1;
}

inline void down_0()
{
    val[num] = val[num + yoko];
    num = num + yoko;
}
 
inline void up_0()
{
    val[num] = val[num - yoko];
    num = num - yoko;
}
 
inline void right_0()
{
    val[num] = val[num +1];
    num = num + 1;
}
 
inline void left_0()
{
    val[num] = val[num -1];
    num = num - 1;
}


Measured memory_bytes: 2100
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string S;
  std::cin >> S;

  ll N = S.size();
  std::ostringstream oss;
  oss << S[0] << N - 2 << S[N-1];
  std::string ans = oss.str();

  print(ans);
  return 0;
}


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

int compar(const int *val1, const int *val2) {//降順並び替え
    if ( *val1 > *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

int main(){
  int n,hitpoint;
  scanf("%d %d",&n,&hitpoint);
  int a[n],b[n];
  for(int i = 0; i < n; ++i) scanf("%d %d",&a[i],&b[i]);
  qsort(a, n, sizeof(int),(int (*)(const void *, const void *))compar);
  qsort(b, n, sizeof(int),(int (*)(const void *, const void *))compar);
  int damage, damage_b = 0;
  int num_attack = 0, num_attack_a;
  int left_point;
  int answer = 1000000000;
  for(int i = 0; i < n; ++i){
    damage_b += b[i];//b[0], .. ,b[i],a[0], .. ,a[0]
    damage = damage_b;
    num_attack = i + 1;
    left_point = hitpoint - damage;
    if(left_point > 0) num_attack_a = (left_point - 1)/a[0] + 1;//ceil
    else num_attack_a = 0;
    num_attack += num_attack_a;
    if(num_attack < answer) answer = num_attack;
    if(num_attack <= 0) break;//bのみでokなら終了
  }
  printf("%d\n",answer);
  return 0;
}

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

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

int a,b,sum;

signed main() {
    cin >> a >> b;
    sum = 1;
    if (sum >= b) {
        cout << 0 << endl;
        return 0;
    }
    rep1(i,INF) {
        sum += a-1;
        if (sum >= b) {
            cout << i << endl;
            return 0;
        }
    }
}





Measured memory_bytes: 256
N = int(input())

a_list = []
for i in range(N):
  x, l = map(int, input().split())
  a_list.append([x - l, x + l])
  
b_list = sorted(a_list, key=lambda x:x[0])
cnt = N
start, end = map(int, b_list[0])
for i in range(1,N):
  start_, end_ = map(int, b_list[i])
  if start_ < end:
    if end_ <= end:
      cnt -= 1
      start = start_
      end = end_
      continue
    else:
      cnt -= 1
      continue
  else:
    start = start_
    end = end_
      
      
print(cnt)

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

string S;

int main()
{

    cin >> S;

    int cnt = 0;
    for (int i = 0; i < 26; i++)
    {
        bool exist = false;
        for (int j = 0; j < S.size(); j++)
        {
            if((char)('a' + i) == S[j]){
                exist = true;
                break;
            } 
            
        }
        if(!exist){
            cout << (char)('a' + i) << endl; 
            return 0;   
        } 
    }

    cout << "None" << endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size()/2;
  for(int i=n-1; i>0; i--) {
    bool f = true;
    for(int j=0; j<i; j++) {
      if(s.at(j) != s.at(j+i)) {
        f = false;
        break;
      }
    }
    if(f) {
      cout << 2*i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC115_A solver = new ABC115_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC115_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long d = in.nextInt();
            out.print("Christmas");
            while (d <= 24) {
                out.print(" Eve");
                d++;
            }
        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    string s;
    int cnt = 0;

    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '1') cnt++;
    }

    cout << cnt << endl;

    return 0;
}


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

int main(){
  int n;cin>>n;
  vector<int> c(n,0),s(n,0),f(n,0);
  REP(i,n-1) cin>>c.at(i)>>s.at(i)>>f.at(i);
  REP(i,n){
    int t=0;
    for(int j=i;j<n-1;j++){
      while(t<s.at(j)||t%f.at(j))t++;
      t+=c.at(j);
    }
    cout<<t<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double ans=0.0;
  cin >> n;
  double v[n];
  for(int i=0;i<n;i++)cin >> v[i];
  sort(v,v+n);
  for(int i=0;i<n;i++){
    if(i==n-1)ans=v[n-1];
    else v[i+1]=(v[i]+v[i+1])/2;
  }
  cout << ans << endl;
}

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

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (w - r >= x && r <= x && h - r >= y && r <= y)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>

constexpr double PI = 3.141592653589;

int main(void)
{
    double r;
    std::cin >> r;

    double area = PI * r * r;
    double round = 2 * PI * r;
    std::cout << std::fixed << std::setprecision(6)
              << area << " " << round << std::endl;

    return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

void solve() {
    ll n;
    cin >> n;
    if(n == 0) exit(0);
    vector<ll> time(n), id(n);
    vector<bool> in(n);
    REP(i, n) {
        ll month, day, hour, minute;
        char c; 
        cin >> month >> c >> day >> hour >> c >> minute;
        time[i] = (month-1) * 31 * 24 * 60 + (day-1) * 24 * 60 + hour * 60 + minute;

        cin >> c;
        in[i] = c == 'I';

        cin >> id[i];
    }
    dump(time);
    dump(in);
    dump(id);

    vector<ll> in_time(1000, -1), ans(1000);
    REP(i, n) {
        if(in[i]) {
            in_time[id[i]] = time[i];
        }
        else {
            assert(in_time[id[i]] != -1);
            if(id[i] == 0) {
                REP(j, 1000) if(in_time[j] != -1) {
                    ans[j] += time[i] - max(in_time[0], in_time[j]);
                }
            } else {
                if(in_time[0] != -1) {
                    ans[id[i]] += time[i] - max(in_time[0], in_time[id[i]]);
                }
            }
            in_time[id[i]] = -1;
        }
    }

    ll ret = 0;
    FOR(i, 1, 1000) chmax(ret, ans[i]);
    cout << ret << endl;
}

int main(void) {
    while(1) solve();

    return 0;
}


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

ll n , k;
ll a [200000];
ll dp [200000];

ll Go (ll);

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

    memset (dp , -1 , sizeof dp);

    cin >> n >> k;

    for (ll i=1; i<=n; ++i)
        cin >> a[i];

    cout << Go (1);


    return 0;
}

ll Go (ll indx)
{
    if (indx == n)
        return 0;
    if (dp [indx] != -1)
        return dp[indx];

    ll ans = 1000000000;

    for (ll i=indx+1; i<=indx+k; ++i)
    {
        if (i<=n)
            ans = min (ans , abs(a[indx]-a[i]) + Go (i));
    }

    return dp [indx] = ans;
}

Measured memory_bytes: 7296
import java.util.*;
public class Main {
	public static void main(String[] args){
	    
	    
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
        int M = sc.nextInt();
        
      	int Road[] = new int[N];
      	
      	//道１つにつき二つ都市がつながっているので、道の数×2する
      	for(int i = 0;i < M * 2;i++){
      	  
		  Road[sc.nextInt()-1] += 1;
        }
        
        
      	for(int i = 0;i < N; i++){
          System.out.println(Road[i]); 
        }
 
    }
}

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

int main(){
    int n,max=0;
    cin >> n;
    vector<string> s(n),a;
    map<string,int>Map,MMap;
    for(int i=0;i<n;i++){
        cin >> s.at(i);
        Map[s.at(i)]++;
        if(Map[s.at(i)]>max)max=Map[s.at(i)];
    }
    for(int i=0;i<n;i++){
        if(Map[s.at(i)]==max)
        {   
            if(MMap[s.at(i)]==0){
                a.push_back(s.at(i));
                MMap[s.at(i)]++;
            }
        }
    }
    sort(a.begin(),a.end());
    for(int i=0;i<a.size();i++){
        cout << a.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 40816
import collections

N = int(input())
S_list = [None]*N
for i in range(N):
    S_list[i] = input()

dict_S = dict(collections.Counter(S_list))
max_count = max(dict_S.values())

max_list = []
for k, v in dict_S.items():
    if v == max_count:
        max_list.append(k)

sorted_max_list = sorted(max_list)
for i in range(len(max_list)):
    print(sorted_max_list[i])

Measured memory_bytes: 41692
#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;

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

  cin >> a >> b >> c >> k;

  if (k > a + b) {
    cout << a - (k - a - b) << endl;
  } else {
    cout << min(a, k) << endl;
  }

}

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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)
ll MOD = 1000000007;
ll INF = 1LL << 60;

int h,w,k; int s[11][1001]; vec bits;

void solve() {
	ll out = (h-1)*(w-1), temp;
	ll pow = 1;
	FOR(i,0,h-1) {pow *= 2;}	// max h-1 horizontal cuts
	FOR(A,0,pow) {
		bits.clear();
		int num=A;
		temp=0;
		bits.push_back(0);
		FOR(cnt,1,h) {
			if (num%2) {
				temp++;
				bits.push_back(cnt);
				if (num==1) break;
			}
			num/=2;
		}
		bits.push_back(h);
		vec cum(temp+1);
		int cnt=0;
		bool cont=false;
		FOR(j,0,w) {
			vec line(temp+1,0);
			cnt=0;	
			FOR(i,0,h) {
				if (!(bits[cnt]<=i&&i<bits[cnt+1])) {
					// assert(cnt+1<bits.size());
					// cout<<A<<" "<<i<<" "<<j<<" "<<cnt<<" "<<cnt+1<<" "<<bits.size()<<endl;
					cnt++;
				}
				if (s[i][j]==1) {
					cum[cnt]++;
					line[cnt]++;
					if (line[cnt]>k) {
						cont=true;
						break;
					}
					if(cum[cnt]>k) {
						FOR(aa,0,cnt+1) {
							cum[aa]=line[aa];
						}
						FOR(aa,cnt+1,cum.size()) {
							cum[aa]=0;
						}
						temp++;
					}
				}
			}
			if (cont) break;
		}
		if (!cont) {
			out=min(out,temp);
		}
	}
	cout<<out;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>h>>w>>k;
	FOR(i,0,h) {
		string st;cin>>st;
		FOR(j,0,w) {
			s[i][j]=(int)(st[j]-'0');
		}
	}
	solve();
}

Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-02 22:54:22
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<(x)>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    if (a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  long ans = 1;
  
  for(int i=1;i<=N;i++){
    ans *= i;
    ans %= 1000000007;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int L;
    cin >> L;
    double ans;
    ans = L*L*L/27.0;
    printf("%5lf", ans);

}

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

public class Main {

    public static void main(String[] args) {
        try {
            InputReader in;
            PrintWriter out;
            boolean useOutput = false;
            // if (System.getProperty("ONLINE_JUDGE") == null) useOutput = true;
            if (useOutput) {
                FileInputStream fin = new FileInputStream(new File("src/testdata.in"));
                in = new InputReader(fin);
                FileOutputStream fout = new FileOutputStream(new File("src/testData.out"));
                out = new PrintWriter(fout);
            } else {
                InputStream inputStream = System.in;
                in = new InputReader(inputStream);
                OutputStream outputStream = System.out;
                out = new PrintWriter(outputStream);
            }
            Solver solver = new Solver();
            solver.solve(in, out);
            out.close();
            // fin.close();
            // fout.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class Solver
    {

        public void solve (InputReader cin, PrintWriter cout)
        {
            try {
                int n;
                String s;
                int[] numleft, numright;
                int ans = 0;
                n = cin.nextInt(); s = cin.next();
                numleft = new int[26]; numright = new int[26];
                for (int i = 0; i < n - 1; ++i) {
                    Arrays.fill(numleft, 0);
                    Arrays.fill(numright, 0);
                    for (int j = 0; j < i + 1; ++j) numleft[s.charAt(j) - 'a'] = 1;
                    for (int j = i + 1; j < n; ++j) numright[s.charAt(j) - 'a'] = 1;
                    int temp = 0;
                    for (int j = 0; j < 26; ++j) temp += numleft[j] * numright[j];
                    ans = Math.max(ans, temp);
                }
                cout.println(ans);
            } catch (RuntimeException e) {
                e.printStackTrace();
                return;
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

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

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

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

    }

}

Measured memory_bytes: 21460
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		int n = 0;
		for(int i = 0; i < 3; i++)
			if(S.charAt(i) == 'o') n++;
			
		System.out.println(700+100*n);
	}
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, a[400000], ans = 0;
	cin >> n;
	rep(i, 3 * n) cin >> a[i];
	sort(a, a + 3 * n);
	reverse(a, a + 3 * n);
	for (int i = 1; i < 2 * n; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}


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

const int N = 100010;

int n;
long long k;
std::pair <int, int> p[N];

int main(){
	scanf("%d%lld", &n, &k);
	for (int i = 0; i < n; ++ i){
		scanf("%d%d", &p[i].first, &p[i].second);
	}
	std::sort(p, p + n);
	for (int i = 0; i < n; ++ i){
		k -= p[i].second;
		if (k <= 0){
			return printf("%d\n", p[i].first), 0;
		}
	}
}

Measured memory_bytes: 1024
n=int(input())
a=n//1000
b=n//100%10
c=n//10%10
d=n%10
op=range(2)
def calc(i,a,b):
    if i==0:
        return a+b
    else:
        return a-b

def opdef(i):
    if i==0:
        return '+'
    else:
        return '-'
flg=False
for i in op:
    if flg:
        break
    for j in op:
        if flg:
            break
        for k in op:
            if flg:
                break
            ans=calc(k,calc(j,calc(i,a,b),c),d)
            if ans==7:
                flg=True
                print(str(a)+opdef(i)+str(b)+opdef(j)+str(c)+opdef(k)+str(d)+'=7')


Measured memory_bytes: 3064
import sys

stdin = sys.stdin

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

h,w = na()
mp = []
for i in range(h):
    mp.append([_ for _  in ns().strip()])

for i in range(h):
    for j in range(w):
        if mp[i][j] != "#":
            bo = 0
            for k in range(-1,2):
                for l in range(-1,2):
                    ni = i + k
                    nj = j + l
                    if 0 <= ni < h and 0 <= nj < w and mp[ni][nj] == "#":
                        bo += 1
            mp[i][j] = chr(bo + 48)
for i in mp:
    print("".join(i))


Measured memory_bytes: 3064
n = int(input())
A = [list(map(int, list('{:020b}'.format(a))))
     for a in map(int, input().split())]

ans = 0
R = 0
X = [0]*20
for L in range(n):
    while R < n and all(x+y != 2 for x, y in zip(X, A[R])):
        for i in range(20):
            X[i] += A[R][i]
        R += 1
    ans += R-L
    for i in range(20):
        X[i] -= A[L][i]
print(ans)

Measured memory_bytes: 124892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner	sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 2];
		for(int i = 1 ; i <= n ; i++) a[i] = sc.nextInt();
		int d = 0;
		for(int i = 1 ; i <= n + 1 ; i++) {
			d += Math.abs(a[i] - a[i - 1]);
		}
		for(int i = 1 ; i <= n ; i++) {
			int ans = d;
			ans -= Math.abs(a[i] - a[i - 1]) + Math.abs(a[i] - a[i + 1]);
			ans += Math.abs(a[i + 1] - a[i - 1]);
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 64140
#include <iostream>

#define INF 1100100100

using namespace std;


int main(void)
{
    int height, width;
    bool isBlack[100][100];
    cin >> height >> width;

    for(int h = 0; h < height; h++){
        for(int w = 0; w < width; w++){
            char floor;
            cin >> floor;

            if(floor == '.'){
                isBlack[h][w] = false;
            }else if(floor == '#'){
                isBlack[h][w] = true;
            }
        }
    }

    int change_counts[100][100];

    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            change_counts[i][j] = INF;
        }
    }

    change_counts[0][0] = 0;
    for(int h = 0; h < height; h++){
        for(int w = 0; w < width; w++){
            int from_upper = INF;
            int from_left = INF;

            if(h != 0){
                if(isBlack[h][w] != isBlack[h - 1][w]){
                    from_upper = change_counts[h - 1][w] + 1;
                }else{
                    from_upper = change_counts[h - 1][w];
                }
            }
            if(w != 0){
                if(isBlack[h][w] != isBlack[h][w - 1]){
                    from_left = change_counts[h][w - 1] + 1;
                }else{
                    from_left = change_counts[h][w - 1];
                }
            }

            if(change_counts[h][w] > from_left){
                change_counts[h][w] = from_left;
            }
            if(change_counts[h][w] > from_upper){
                change_counts[h][w] = from_upper;
            }
        }
    }

    int change_length = change_counts[height - 1][width - 1] + 1;
    int black_count;

    if(isBlack[0][0] && isBlack[height - 1][width - 1]){
        black_count = (change_length + 1) / 2;
    }else{
        black_count = change_length / 2;
    }

    cout << black_count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,j;
	int n;
	int debt=100000;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		debt+=debt*0.05;
		if(debt%1000!=0){
			debt/=1000;
			debt*=1000;
			debt+=1000;
		}
	}
	printf("%d\n",debt);
	
	return 0;
}

Measured memory_bytes: 592