akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, T, A;
    cin >> N >> T >> A;

    double min_T = 10000000;
    int pos;
    rep(i, N) {
        int H;
        cin >> H;
        double X = T - H * 0.006;
        double D = abs(A - X);
        if(D < min_T) {
            min_T = D;
            pos = i + 1;
        }
    }

    cout << pos << endl;
}


Measured memory_bytes: 256
# coding: utf-8

n = int(input())
ai = [int(i) for i in input().split()]

counter = {}
for a in ai:
    counter.setdefault(a-1, 0)
    counter.setdefault(a,   0)
    counter.setdefault(a+1, 0)
    
    counter[a-1] = counter[a-1] + 1
    counter[a  ] = counter[a  ] + 1
    counter[a+1] = counter[a+1] + 1

ans = 0
for key in counter.keys():
    ans = max(ans, counter[key])

print(ans)


Measured memory_bytes: 65260
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

//std::cout << std::fixed << std::setprecision(10)
constexpr long long MOD = 1000000007;

int main()
{
  int N, D;
  std::cin >> N >> D;
  std::vector<std::vector<int>> X(N, std::vector<int>(D));
  for (auto& vec: X)
  {
    for (auto& x: vec)
    {
      std::cin >> x;
    }
  }
  int ans = 0;
  for (int i = 0; i < X.size(); ++i)
  {
    for (int j = i + 1; j < X.size(); ++j)
    {
      int d2 = 0;
      for (int k = 0; k < D; ++k)
      {
        int d = X[i][k] - X[j][k];
        d2 += d * d;
      }
      int s = std::sqrt(d2);
      if (d2 % s == 0 && s == d2 / s)
        ++ans;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 256
int main()
{
  int n;
  scanf("%d", &n);
  long h[n];
  int i;
  for (i = 0; i < n; i++)
    scanf("%ld", &h[i]);
  for (i = 0; i < n - 1; i++)
  {
    if (i >= 1)
      if (h[i] > h[i - 1])
        h[i]--;
    if (h[i] > h[i + 1])
    {
      printf("No");
      return 0;
    }
  }
  printf("Yes");
}

Measured memory_bytes: 2456
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int N;
string t;
vector<string> ans;
int main() {
	scanf("%d", &N);
	ans.push_back("a");
	t.push_back('a');
	int pos = 0;
	for (int i = 2; i <= 10; i++) {
		int pos2 = ans.size();
		for (int j = pos; j < pos2; j++) {
			string temp = ans[j];
			for (int k = 0; k <= t[j] - 'a' + 1; k++) {
				string temp2 = temp;
				temp2.push_back('a' + k);
				ans.push_back(temp2);
				t.push_back(max(temp2.back(), t[j]));
			}
		}
		pos = pos2;
	}
	for (auto x:ans) {
		if (x.length() == N) {
			cout << x << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 9712
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    double sum = 0;
    for (int i = 0; i < n; i++) {
        double a;
        std::cin >> a;
        sum += 1.0 / a;
    }

    std::cout << 1.0 / sum << std::endl;

    return 0;
}


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

const int maxn = 1e5 + 10;
int N , M;
vector<int> g[maxn];
int DP[maxn];
bool vis[maxn];

void DFS(int v , int p){
    DP[v] = 1;
    for(int u : g[v]){
        if(u != p){
            if(!DP[u])
                DFS(u , v);
            DP[v] = max(DP[v] , DP[u] + 1);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    for(int i = 1; i <= M; ++i){
        int x , y; cin >> x >> y;
        g[x].push_back(y);
    }
    for(int i = 1; i <= N; ++i){
        if(!DP[i])
            DFS(i , -1);
    }
    int ret = 0;
    for(int i = 1; i <= N; ++i){
        ret = max(ret , DP[i]);
    }
    cout << ret - 1 << endl;
}


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

int main() {
	int N;cin>>N;
	vector<int>a(N);
	bool allzero = true;
	for (int i = 0; i < N; i++)
	{
		cin>>a[i];
		if(a[i] != 0)allzero = false;
	}

	if (allzero == false && N % 3 != 0)
	{
		cout<<"No"<<endl;
		return 0;
	}

	vector<int>kouho;
	for (int j = 0; j < 32; j++)
	{
		int cnt0 = 0, cnt1=0;
		for (int k = 0; k < kouho.size(); k++)
		{
			int i = kouho[k];

			if (((a[i] >> j) & 1) == 0)
			{
				cnt0++;
			}
			else cnt1++;
		}
		if (cnt0 != 0 && cnt1 != 0)
		{
			cout << "No" << endl;
			return 0;
		}

		kouho.clear();
		for (int i = 0; i < N; i++)
		{
			if (((a[i] >> j) & 1) == 0)
			{
				kouho.push_back(i);
			}
		}

		if(kouho.size() == N)
		{
			kouho.clear();
			continue;
		}
		if (N / 3 != kouho.size())
		{
			cout << "No" << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF (1<<30);

int main() {
  int N; cin >> N;
  vector<vector<P> > xy(N);

  rep(i, N) {
    int a; cin >> a;
    rep(j, a) {
      int x, y; cin >> x >> y;
      xy[i].push_back(make_pair(x, y));
    }
  }

  int ans = 0;
  for (int i = 0; i < (1<<N); i++) {
    int tmpans = 0;
    bool isGood = true;

    rep(j, N) {

       if (((i>>j) & 1) == 1) {
         rep(k, xy[j].size()) {
           int z = xy[j][k].first;
           if(((i>>(z-1))&1) != xy[j][k].second) {
              isGood = false;
           }
         }
         tmpans++;
       }
      
    } 

    if (isGood) ans = max(ans, tmpans);

  }


  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	allTestimonies := make([]Testimonies, n)
	for i := 0; i < n; i++ {
		allTestimonies[i] = loadTestimonies()
	}
	answer := honestOrUnkind(allTestimonies)
	fmt.Println(answer)
}

type Testimonies struct {
	x []uint32
	y []uint32
}

func loadTestimonies() Testimonies {
	var a int
	fmt.Scanf("%d", &a)
	x := make([]uint32, a)
	y := make([]uint32, a)
	for i := 0; i < a; i++ {
		fmt.Scanf("%d %d", &x[i], &y[i])
		x[i]--
	}
	return Testimonies{x: x, y: y}
}

func honestOrUnkind(allTestimonies []Testimonies) int {
	// 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
	maxHonest := 0
	for bits := uint32(0); bits < (1 << uint32(len(allTestimonies))); bits++ {
		var flagOns []uint32
		for i := uint32(0); i < bits && i < uint32(len(allTestimonies)); i++ {
			if (bits & (1 << i)) > 0 {
				flagOns = append(flagOns, i)
			}
		}
		if len(flagOns) > maxHonest && isCompleted(allTestimonies, flagOns) {
			maxHonest = len(flagOns)
		}
	}
	return maxHonest

}

func in(i uint32, list []uint32) bool {
	for _, v := range list {
		if v == i {
			return true
		}
	}
	return false
}

func isCompleted(allTestimonies []Testimonies, honestIndex []uint32) bool {
	for _, i := range honestIndex {
		honestTestimonies := allTestimonies[i]
		for j, isHonest := range honestTestimonies.y {
			targetPerson := honestTestimonies.x[j]
			if isHonest == 0 {
				if in(targetPerson, honestIndex) {
					return false
				}
			} else {
				// this case covered by other honestIndex, so ignore.
				if !in(targetPerson, honestIndex) {
					return false
				}
			}
		}
	}
	return true
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main()
{
          long long x=1e9;
          x+=7;
          long long n,k;
          cin>>n>>k;
          long long arr[n+1];
          long long dp[n+1][k+1];
          long long i,j;
          for(i=0;i<=n;i++)
          {
                    for(j=0;j<=k;j++)
                    {
                              dp[i][j]=0;
                    }
          }
          for(i=1;i<=n;i++)
          {
                    cin>>arr[i];
                    dp[i][0]=1;
          }
          long long sum[k+1];
          for(j=0;j<=k;j++)
          {
                    sum[j]=0;
          }
          //sum[0]=1;
          for(i=1;i<=n;i++)
          {
                    if(i==1)
                    {
                              for(j=1;j<=arr[i];j++)
                              {
                                        dp[i][j]=1;
                              }
                    }
                    else
                    {
                              for(j=1;j<=k;j++)
                              {
                                        long long c=0;
                                        c=max(c,j-arr[i]);
                                        if(c==0)
                                        {
                                                  dp[i][j]=(sum[j])%x;
                                        }
                                        else
                                        {
                                                  if(sum[j]>=sum[c-1])
                                                  {
                                                            dp[i][j]=(sum[j]-sum[c-1])%x;
                                                  }
                                                  else
                                                  {
                                                            dp[i][j]=(x+sum[j]-sum[c-1])%x;
                                                  }
                                        }
                              }
                    }
                    sum[0]=1;
                    for(j=1;j<=k;j++)
                    {
                              sum[j]=(sum[j-1]+dp[i][j])%x;
                    }
          }
         /*for(i=1;i<=n;i++)
          {
                    for(j=0;j<=k;j++)
                    {
                              cout<<dp[i][j]<<" \n";
                    }
          }*/
          cout<<dp[n][k];
}

Measured memory_bytes: 79872
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DUniquePath {
public:

    std::vector<int> par;
    std::vector<int> rak; // number of the vertices
    void init(int n) {
      par.resize(n);
      rak.resize(n);
      for(int i=0; i<n; i++) {
        par[i] = i;
        rak[i] = 1;
      }
    }

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

    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x==y) return;
      if (rak[x] < rak[y]) {
        rak[y] += rak[x];
        par[x] = y;
      } else {
        rak[x] += rak[y];
        par[y] = x;
      }
    }

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

    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n, m, q; cin >> n >> m >> q;
      init(n);
      vector<P> vec;

      while(q--) {
        int a, b, c; cin >> a >> b >> c;
        if (c==0) {
          if (!same(a, b)) {
            unite(a, b);
            m--;
          }
        } else {
          vec.emplace_back(a,b);
        }
      }

      for(auto e: vec) {
        if (same(e.first, e.second)) {
          cout << "No" << endl;
          return;
        }
      }

      ll cnt = 0;
      vector<int> used(n);
      rep(i, n) {
        int p = find(i);
        if (!used[p]) {
          cnt++;
          used[p] = true;
        }
      }
      if ((!vec.empty()) && cnt <= 2) {
        cout << "No" << endl;
        return;
      }
      ll mi, ma;
      ma = cnt*(cnt-1)/2;
      if (vec.empty()) {
        mi = cnt-1;
      } else {
        mi = cnt;
      }
      debug(cnt, mi, m, ma);
      if (mi <= m && m <= ma) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
};

signed main() {
  DUniquePath solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3188
a = input().split()

stack = []
for inp in a:
    if inp == "+":
        x = stack.pop()
        y = stack.pop()
        stack.append(x+y)
    elif inp == "-":
        x = stack.pop()
        y = stack.pop()
        stack.append(y-x)
    elif inp == "*":
        x = stack.pop()
        y = stack.pop()
        stack.append(x*y)
    else:
        stack.append(int(inp))

print(*stack)

Measured memory_bytes: 7720
#include<stdio.h>
int main(){
	int i,a,b;
	for(i=1;;i++){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0)break;
		if(a>b){
			printf("%d %d\n",b,a);
		}else{
			printf("%d %d\n",a,b);
		}
	}
}


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

typedef long long ll;

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0)
#define endl '\n'
#define DB(x) cout<<#x<<" : "<<x<<'\n'
#define PB push_back

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


void max_self(int &a, int b){
    a = max(a,b);
}
vector<vector<int>> dp(1000, vector<int>(1000,0 )); 
//dp[i][j] -> gives total number of ways from i,j to N,M
bitset<1000> visited[1000];
int N,M; //N: row , M:column
int go(int i,int j, vector<vector<char>> &grid){
    //takes the index and returns the Number of paths from i,j to N,M
    if(i == N-1 && j == M-1) return 1;
    int path = 0;
    visited[i][j] = 1;
    if(i+1 < N && grid[i+1][j] != '#'){

        path += (visited[i+1][j] == 1)? dp[i+1][j] : go(i+1,j,grid);
    }
    if(j+1< M && grid[i][j+1] != '#'){
        path += (visited[i][j+1] == 1)? dp[i][j+1] : go(i,j+1,grid);
    }
    dp[i][j] = path % MOD;
    return dp[i][j];
}
int main(){
    
    cin>>N>>M;
    vector<vector<char>> grid(N, vector<char>(M));

    for(int i = 0; i< N; ++i ){
        for(int j = 0; j<M; ++j){
            cin>>grid[i][j];
        }
    }

    int answer = go(0,0, grid);
    cout<<answer;
}


Measured memory_bytes: 5504
n = gets.to_i

x = Array.new(n)
y = Array.new(n)
n.times do |i|
  x[i], y[i] = gets.chomp.split.map(&:to_i)
end
num = 0
sum = 0
(1..n).to_a.permutation.to_a.each do |a|
  (a.length - 1).times do |i|
    sum += Math.sqrt((x[a[i]-1] - x[a[i-1]-1]) ** 2 + (y[a[i]-1] - y[a[i-1]-1]) ** 2)
  end
  num += 1
end

p sum / num

Measured memory_bytes: 6780
<?php
    ini_set('memory_limit', -1);
    $num = array_map('intval',explode(" ",trim(fgets(STDIN))));
    $num_vertex = $num[0];
    $num_side   = $num[1];
    $start = $num[2];
    $vertex_info =array_fill(0,$num_vertex,[]);
    for($i=0;$i<$num_side;$i++){
        list($s,$t,$d) = array_map('intval',explode(" ",trim(fgets(STDIN))));
        $vertex_info[$s][] = [$t,$d];
    }
    $inf = 10**10;
    $visited = array_fill(0,$num_vertex,false);
    $dist = array_fill(0,$num_vertex,$inf);
    $dist[$start] = 0;
    $queue= new SplPriorityQueue();
    $queue->insert([$start,0],0);
    while(!$queue->isEmpty()){
        list($vetex_standard,$dist_standard) = $queue->extract();

        if($visited[$vetex_standard]==true){
            continue;
        }
        $visited[$vetex_standard] = true;
        foreach($vertex_info[$vetex_standard] as $value){
            list($to,$to_dist) = $value;
            $total_dist = $dist_standard + $to_dist;
            // echo $total_dist."\n";
            if($total_dist<$dist[$to]){
                // echo $to." ";
                // echo $total_dist."\n";
                $dist[$to] = $total_dist;
                $queue->insert([$to,$total_dist],-$total_dist);
            }
        }
    }
    foreach ($dist as $result) {
        if ($result === $inf) {
            echo "INF\n";
        } else {
            echo $result . "\n";
        }
    }
?>


Measured memory_bytes: 405604
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	string s1, s2;
	while (cin >> s1) {
		if (s1 == ".") {
			break;
		}
		cin >> s2;

		if (s1 == s2) {
			cout << "IDENTICAL" << endl;
		}
		else {
			int s1c = 0;
			vector<string> s11;
			string subs1 = "";
			string kk = "";
			for (int i = 0; i < s1.size(); i++) {
				if (s1[i] == '"') {
					subs1 += '"';
					s1c++;
					if (s1c % 2 == 0) {
						s11.push_back('"' + kk + '"');
						kk = "";
					}
				}
				else if (s1c % 2 != 0) {
					kk += s1[i];
				}
				else {
					subs1 += s1[i];
				}
			}
			int s2c = 0;
			vector<string> s22;
			string subs2 = "";
			for (int i = 0; i < s2.size(); i++) {
				if (s2[i] == '"') {
					subs2 += '"';
					s2c++;
					if (s2c % 2 == 0) {
						s22.push_back('"' + kk + '"');
						kk = "";
					}
				}
				else if (s2c % 2 != 0) {
					kk += s2[i];
				}
				else {
					subs2 += s2[i];
				}
			}
			if (subs1 == subs2 && s11.size() == s22.size()) {
				int cc = 0;
				for (int i = 0; i < s11.size(); i++) {
					if (s11[i] != s22[i]) {
						cc++;
					}
				}
				if (cc == 1) {
					cout << "CLOSE" << endl;
				}
				else {
					cout << "DIFFERENT" << endl;
				}
			}
			else {
				cout << "DIFFERENT" << endl;
			}
		}

	}
	return 0;
}


Measured memory_bytes: 3212
N,M,Q = map(int,input().split())

p = [0] * Q
q = [0] * Q
info = [[0] * N for _ in range(N)]
total = [[0] * N for _ in range(N)]

intminus = lambda x:int(x)-1

for s in range(M):
    L,R = map(intminus,input().split())
    info[L][R] += 1
for t in range(Q):
    p[t], q[t] = map(intminus,input().split())

total[0][0] = info[0][0]
for i in range(1,N):
    total[i][0] = total[i-1][0] + info[i][0]
for j in range(1,N):
    total[0][j] = total[0][j-1] + info[0][j]
for i in range(1,N):
    for j in range(1,N):
        total[i][j] = total[i][j-1] + total[i-1][j] - total[i-1][j-1] + info[i][j]

for t in range(Q):
    if p[t] != 0:
        print(total[q[t]][q[t]] - total[q[t]][p[t]-1] - total[p[t]-1][q[t]] + total[p[t]-1][p[t]-1])
    else:
        print(total[q[t]][q[t]])

Measured memory_bytes: 66904
import java.util.Scanner;
     
    public class Main {
     
    	public static final String WAR = "War";
    	public static final String NO_WAR = "No War";
    	
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		
    		String lineStr = scan.nextLine();
    		String[] e = lineStr.split(" ");
    		int N = Integer.parseInt(e[0]);
    		int M = Integer.parseInt(e[1]);
    		int X = Integer.parseInt(e[2]);
    		int Y = Integer.parseInt(e[3]);
     
    		if(X >= Y) {
    			System.out.print(WAR);
    			scan.close();
    			return;
    		}
    		
    		lineStr = scan.nextLine();
    		String[] x = lineStr.split(" ");
    		
    		int maxX = -999;
    		for(int i = 0 ; i < N ; i++) {
    			int intX = Integer.parseInt(x[i]);
     
    			if(maxX < intX) {
    				maxX = intX;
    			}
    		}
    		
    		lineStr = scan.nextLine();
    		String[] y = lineStr.split(" ");
     
    		int minY = 999;
    		for(int j = 0 ; j < M ; j++) {
    			int intY = Integer.parseInt(y[j]);
    			if(minY > intY) {
    				minY = intY;
    			}
    		}
     		scan.close();
    		
                if(maxX >= minY) {
                    System.out.print(WAR);
                    return;
                }
                if(maxX > Y -1) {
    		    System.out.print(WAR);
                    return;
                }
                if(minY <= X){
    		    System.out.print(WAR);
                    return;
                }
            System.out.print(NO_WAR);
    	}
    }

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>
#include <queue>

using namespace std;
using llong = long long;
using P = pair<int,int>;

map<int,int> graph[10000];
bool visited[10000];

int main(){
  int N , M ;
  cin >> N >> M;
  for(int i=0;i<M;++i){
    int s,t,w;
    cin >> s >> t >> w;
    graph[s][t] = w;
    graph[t][s] = w;
  }
  priority_queue<P,vector<P>,greater<P> > Q;
  Q.push(P(0,0));
  int sum = 0;
  while(!Q.empty()){
    int cost = Q.top().first , v = Q.top().second;
    Q.pop();
    if(visited[v]) continue;
    visited[v] = true;
    sum += cost;
    for(const auto &n:graph[v]){
      Q.push(P(n.second,n.first));
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 14732
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
	string st[102];
	cin>>n>>l;
	for(int i=1;i<=n;i++)
		cin>>st[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n-i;j++)
		{
			if(st[j]>st[j+1])swap(st[j],st[j+1]);
		}
	for(int i=1;i<=n;i++)
	{
		cout<<st[i];
	}	
	cout<<endl;
	return 0;
}


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


int main(){
    pair<long long, long long>p[50];
    long long ans = 5000000000000000000;
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> p[i].first >> p[i].second;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                for(int l = 0; l < N; l++){
                    long long x1 = min(p[i].first, p[j].first);
                    long long x2 = max(p[i].first, p[j].first);
                    long long y1 = min(p[k].second, p[l].second);
                    long long y2 = max(p[k].second, p[l].second);
                    int K_ = 0;
                    for(int m = 0; m < N; m++){
                        long long x = p[m].first;
                        long long y = p[m].second;
                        if(x1 <= x && x <= x2 && y1 <= y && y <= y2){
                            K_++;
                        }
                    }
                    if(K_ >= K){
                        ans = min(ans, (x2-x1) * (y2-y1));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,p,q;
    cin>>n>>k;
    int a[n]={0};
    for(int i=0;i<k;i++)
    {
        cin>>p;
        for(int j=0;j<p;j++)
        {
            cin>>q;
            a[q-1]++;
        }
    }
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==0)
        c++;
    }
    cout<<c;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];
    ll ans = 0;
    rep(i, N - 2) {
        rep2(j, i, N - 1) {
            rep2(k, j, N) {
                if(L[i] != L[j] && L[j] != L[k] && L[i] != L[k]) {
                    vector<ll> edges = vector<ll>{L[i], L[j], L[k]};
                    sort(edges.begin(), edges.end());
                    if(edges[0] + edges[1] > edges[2]) ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
def main():
    n, m = map(int, input().split())
    SCs = [list(map(int, input().split())) for _ in range(m)]
    for i in range(0, 10**(n)):
        istr = str(i)
        tr = True
        if len(istr) == n:
            for j in range(m):
                if istr[SCs[j][0]-1] != str(SCs[j][1]):
                    tr = False
            if tr:
                print(i)
                return
    print(-1)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include <stdio.h>
#include <stdlib.h>
#define NMAX 2000000
#define AMAX 10000
int n=AMAX;
void CountingSort(unsigned short *,unsigned short *,int);
int main(){
  int i;
  unsigned short *A;
  unsigned short *B;
  int k;
  

  scanf("%d",&k);

  A=malloc(sizeof(short)*k+1);
  B=malloc(sizeof(short)*k+1);
  
  for(i=0;i<k;i++){
    scanf("%hu",&A[i+1]);
  }
  //  printf("ok1\n");
  CountingSort(A,B,k);
  return 0;
}

void CountingSort(unsigned short *A,unsigned short *B,int k){
  int i,j;
  int C[AMAX+1];
  //printf("ok2\n");
  for(i=0;i<=AMAX;i++){
    C[i]=0;
  }
  //printf("ok3\n");
  for(j=0;j<k;j++){
    C[A[j+1]]++;
  }
  //printf("ok4\n");
  for(i=1;i<=AMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  //printf("ok5\n");
  for(j=1;j<=k;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  //printf("ok6\n");
  for(i=1;i<=k;i++){
    if(i>1)
      printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
}




Measured memory_bytes: 9588
N=int(input())
A=list(map(int,input().split()))
k=0
g=1000
if A[0]<A[1]:
    k=g//A[0]
    g=g%A[0]
for i in range(1,N-1):
    if A[i]>A[i+1]:
        g+=k*A[i]
        k=0
    elif A[i]<A[i+1]:
        k+=g//A[i]
        g=g%A[i]
g+=k*A[-1]
print(g)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	cout << setprecision(13) << fixed;
	double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	P(hypot(x1 - x2, y1 - y2));
	return 0;
}

Measured memory_bytes: 3360
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); 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 all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    ll a, b;
    cin >> a >> b;
    if((a+b)%2){
        cout << "IMPOSSIBLE" << endl;
    }else{
        cout << (a+b)/2 << endl;
    }

}



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


int main(){
    unordered_set<int> squares;
    for(int i = 0; i <= 126; i++){
        squares.insert(i * i);
    }

    int ans = 0;

    int N, D, X[20][10];
    cin >> N >> D;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            int dist = 0;
            for(int k = 0; k < D; k++){
                dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            if(squares.count(dist) > 0){
                ans++;
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<math.h>
#include<functional>
#include<bitset>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> c(n);
	REP(i, n) cin >> c[i];
	vector<ll> tmp(202020, -1);
	vector<ll> bef(n);
	REP(i, n) {
		bef[i] = tmp[c[i]];
		tmp[c[i]] = i;
	}
	vector<ll> dp(n + 1, 0);
	dp[0] = 1;
	FOR(i, 1, n + 1) {
		dp[i] = dp[i - 1];
		if(bef[i - 1] != -1 && bef[i - 1] != i - 2) {
			dp[i] += dp[bef[i - 1] + 1];
			dp[i] %= MOD;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

char ch[maxn];
int q,n,k;
int numc[maxn],numm[maxn];
ll sum[maxn];

int main(){
	scanf("%d%s%d",&n,ch + 1,&q);
	rep(i,1,n){
		numc[i] = numc[i - 1] + (ch[i] == 'C');
		numm[i] = numm[i - 1] + (ch[i] == 'M');
		sum[i] = sum[i - 1] + (ch[i] == 'C') * numm[i];
	}
	while ( q-- ){
		scanf("%d",&k); ll ans = 0;
		rep(i,1,n){
			if ( ch[i] == 'D' ){
				ans += sum[min(n,i + k - 1)] - sum[i - 1] - ((ll)numc[min(i + k - 1,n)] - numc[i - 1]) * numm[i - 1];
			}
		}
		printf("%lld\n",ans);
	}
}


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

int main(){
  string A,B;
  cin >> A >> B;
  if(A.size()>B.size()){
    cout << "GREATER" << endl;
  }
  else if(A.size()<B.size()){
    cout << "LESS" << endl;
  }
  else if(A>B){
    cout << "GREATER" << endl;
  }
  else if(A==B){
    cout << "EQUAL" << endl;
  }
  else{
    cout << "LESS" << endl;
  }
}   


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

int main(){
	int t=0,a,b,c,d,o=0,u=0;
    cin>>a>>b>>c>>d;
    if(a-b>0){
        if(a-b<=d){
            t=1;
        }
    }
    else if (a-b<=0){
            if(b-a<=d){
                t=1;
            }
    }
    if(b-c>0){
        if(b-c<=d){
            o=1;
        }
    }
    else if(b-c<=0){
        if(c-b<=d){
            o=1;
        }
    }
    if(a-c>0){
        if(a-c<=d){
            u=1;
        }
    }
    else if(a-c<=0){
        if(c-a<=d){
            u=1;
        }
    }
    if(u==1){
        cout<<"Yes"<<endl;
    }
    else if(t==1 && o==1){
            cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}


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

class dice{
public:
    vector<int> me = {1, 2, 3, 4, 5, 6};
    void roll(char n){
        vector<int> tmp(6);
        if(n == 'N'){
            tmp[0] = me[1]; tmp[1] = me[5]; tmp[2] = me[2];
            tmp[3] = me[3]; tmp[4] = me[0]; tmp[5] = me[4];
        }
        if(n == 'E'){
            tmp[0] = me[3]; tmp[1] = me[1]; tmp[2] = me[0];
            tmp[3] = me[5]; tmp[4] = me[4]; tmp[5] = me[2];
        }
        if(n == 'S'){
            tmp[0] = me[4]; tmp[1] = me[0]; tmp[2] = me[2];
            tmp[3] = me[3]; tmp[4] = me[5]; tmp[5] = me[1];
        }
        if(n == 'W'){
            tmp[0] = me[2]; tmp[1] = me[1]; tmp[2] = me[5];
            tmp[3] = me[0]; tmp[4] = me[4]; tmp[5] = me[3];
        }
        if(n == 'L'){
            tmp[0] = me[0]; tmp[1] = me[2]; tmp[2] = me[4];
            tmp[3] = me[1]; tmp[4] = me[3]; tmp[5] = me[5];
        }
        if(n == 'R'){
            tmp[0] = me[0]; tmp[1] = me[3]; tmp[2] = me[1];
            tmp[3] = me[4]; tmp[4] = me[2]; tmp[5] = me[5];
        }
        me = tmp;
    }
    int TOP(){
        return me[0];
    }
};

int main(void){
    dice a, b;
    rep(i, 6) cin >> a.me[i];
    rep(i, 6) cin >> b.me[i];
    if(a.me == b.me){
        cout << "Yes" << endl;
        return 0;
    }
    char r[] = "LLLLNLLLLNLLLLNLLLLNLLLLWLLLLWLLLLWLLLLWLLLL";
    rep(i, 43){
        b.roll(r[i]);
        if(a.me == b.me){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    int m=2*n-1;

    if(x==1 || x==m)
    {
        printf("No\n");
        return 0;
    }
    if(n==2)
    {
        printf("Yes\n");
        rep(i,3) printf("%d\n", i+1);
        return 0;
    }

    vector<int> a(m,0);
    vector<bool> used(m+1,false);
    if(x-2>=1)
    {
        a[m/2-2]=x-1;
        a[m/2-1]=x+1;
        a[m/2]=x;
        a[m/2+1]=x-2;
        for(int i=x-2; i<=x+1; ++i) used[i]=true;
    }
    else
    {
        a[m/2-2]=x+1;
        a[m/2-1]=x-1;
        a[m/2]=x;
        a[m/2+1]=x+2;
        for(int i=x-1; i<=x+2; ++i) used[i]=true;
    }

    int now=1;
    rep(i,m)
    {
        if(a[i]!=0) continue;

        while(now<=m && used[now]) ++now;
        a[i]=now;
        used[now]=true;
    }

    printf("Yes\n");
    rep(i,m) printf("%d\n", a[i]);
    return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
ll a[55],p[55];

ll count(int i, ll j){
    if(i == 0) return 1;
    ll res = -1;
    if(j == 1) res = 0;
    if(j > 1 && j <= a[i-1] + 1) res = count(i-1,  j-1);
    if(j == a[i-1] + 2) res = p[i-1] + 1;
    if(j > a[i-1] + 2 && j <= 2*a[i-1] + 2) res = p[i-1] + 1 + count(i-1, j-a[i-1]-2);
    if(j == 2*a[i-1] + 3) res = 2*p[i-1] + 1;
    return res;
}
int main(){
    int n; ll x; cin >> n >> x;
    a[0] = 1; p[0] = 1;
    rep(i,n){
        a[i+1] = 2*a[i] + 3;
        p[i+1] = 2*p[i] + 1;
    }

    cout << count(n, x) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  int data[50];
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> data[i];
  }

  int ans=0;
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n-1-i;j++){
      if(data[j]<data[j+1]){
	int temp=data[j+1];
	data[j+1]=data[j];
	data[j]=temp;
      }
    }
  }

  for(int i=0;i<k;i++)
    ans+=data[i];
    
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <list>
#include <vector>
#include <map>

using namespace std;


int main(void) {
	string str,a;
	cin >> str;
	
	int n = str.length();
	for (int i = 0; i < n; i++) {
		if (str[i] == '0') {
			a.push_back('0');
		}
		else if (str[i] == '1') {
			a.push_back('1');
		}else if(str[i]=='B'){
			if(!a.empty())
				a.pop_back();
		}
	}
	cout << a << endl;

	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input=input.replace(/([2-9])/g,"$1,");
input=input.replace(/T/g,"10,").replace(/J/g,"11,").replace(/Q/g,"12,").replace(/K/g,"13,").replace(/A/g,"14,");
var arr=input.trim().split("\n");
while(true){
   var str=arr.shift();
   if(str=="#")break;
   var n=arr.shift().split(" ");
   var e=arr.shift().split(" ");
   var s=arr.shift().split(" ");
   var w=arr.shift().split(" ");
   var first=0;
   var ns=0;
   var ew=0;
   for(var i=0;i<13;i++){
      var card=[];
      card[0]=n[i].split(",");
      card[1]=e[i].split(",");
      card[2]=s[i].split(",");
      card[3]=w[i].split(",");
      var r=card[first][1];
      var plus=(r==str)?15:0;
      var score=(card[first][0]-0)+plus;
      card.forEach(function(v,index){
         var plus=(v[1]==str)?15:0;
         if(r==v[1] || str==v[1]){
            if(score<=(v[0]-0)+plus){
               first=index;
               score=(v[0]-0)+plus;
            }  
         }
      });
      if(first==0 || first==2)ns++;
      else ew++;
   }
   var ans=(ns>ew)?"NS "+(ns-6):"EW "+(ew-6);
   console.log(ans);
}

Measured memory_bytes: 17140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int vacation = Integer.parseInt(sc.next());
		int homeworkNum = Integer.parseInt(sc.next());
		for(int i=0;i<homeworkNum;i++) {
			int days = Integer.parseInt(sc.next());
			vacation-=days;
		}
		if(vacation<0) {
			System.out.println(-1);
		}else {
			System.out.println(vacation);
		}
	}

}


Measured memory_bytes: 41608
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    ng=s.count("g")
    np=len(s)-ng
    print((ng-np)//2)
    

main()


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

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");

        int H = Integer.parseInt(input[0]);
        int W = Integer.parseInt(input[1]);

        String[] grid = new String[H];

        for(int i=0; i<H; i++) {
            grid[i] = br.readLine();
        }

        System.out.println(getWays(grid, H, W));
    }

    private static int getWays(String[] grid, int H, int W) {
        int[][] ways = new int[H][W];

        for(int i=0; i<W; i++) {
            if(grid[0].charAt(i) == '#') {
                break;
            }

            ways[0][i] = 1;
        }

        for(int i=0; i<H; i++) {
            if(grid[i].charAt(0) == '#') {
                break;
            }

            ways[i][0] = 1;
        }

        for(int i=1; i<H; i++) {
            for(int j=1; j<W; j++) {
                if(grid[i].charAt(j) != '#') {
                    ways[i][j] = ((ways[i - 1][j] % MOD) + (ways[i][j - 1] % MOD)) % MOD;
                }
            }
        }

        return ways[H-1][W-1];
    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int show = 1;
  int i;
  for (i = 0; i < n; i++) {
    if (show < k) {
      show *= 2;
    } else {
      show += k;
    }
  }
  cout << show << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int trace(int a[], int N){
    int i;
    for (i = 0; i < N; i++) {
        if (i>0)
            printf(" ");
        printf("%d", a[i]);

    }
    printf("\n");
}
int main(){
    int a,b,c,d;
    int i;
    scanf("%d", &a);
    int array[a];
    for(i=0;i<a;i++){
        scanf("%d", &array[i]);
    }
    trace(array,a);
    for(b=1; b<a; b++) {
        c = array[b];
        d = b - 1;
        while (d >= 0 && array[d] > c) {
            array[d + 1] = array[d];
            d--;
        }//
        array[d + 1] = c;
        trace(array, a);
    }
    return 0;
}

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

int A, B;

int main() {
  cin>>A>>B;
  if(A>=13){
    cout<<B<<"\n";
  }
  else if(A>=6 && A<=12){
    int C = B/2;
    cout<<C<<"\n";
  }
  else if(A<=5){
    cout<<0<<"\n";
  }
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))

diff = 10**10
sum1 = sum(L)
l_sum = 0
ans = 10**10

for i in range(n-1):
    l_sum+=L[i]
    diff = abs(l_sum- sum1 + l_sum)
    ans = min(ans,diff)
    
print(ans)

Measured memory_bytes: 31644
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = Console.ReadLine();
            if (s[0] == s[1] && s[1] == s[2])
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");



            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

bool seen[100005];

int main(){
    int n, m; cin >> n >> m;
    int p[n], num[n];
    rep(i, n){
        int x; cin >> x; x--;
        p[i] = x;
        num[x] = i;
    }

    vector<int> to[100005];
    rep(i, m){
        int x, y; cin >> x >> y;
        x--; y--;
        to[x].push_back(y);
        to[y].push_back(x);
    }

    int res = 0;
    rep(i, n){
        if(seen[i]) continue;
        set<int> con;

        queue<int> q;
        q.push(i);
        while(!q.empty()){
            int x = q.front(); q.pop();
            seen[x] = true;
            con.insert(x);
            for(int& y : to[x]){
                if(!seen[y]) q.push(y);
            }
        }

        auto itr = con.begin();
        while(itr != con.end()){
            int x = *itr;
            if(con.find(num[x]) != con.end()) res++;
            itr++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
int sow[7368791+10]={0};
int main(){
	int m,n;
	while(cin >> m >> n,m){
		for(int i=0;i<=7368791+10;i++)
			sow[i]=0;
		n--;
		while(1){
			for(int i=1;m*i<=7368791+10;i++)
				sow[m*i]=1;
			while(1){
				m++;
				if(sow[m]==0)
					break;
			}
			if(n==0){
				cout << m << endl;
				break;
			}
			n--;
		}
	}
    return 0;
}

Measured memory_bytes: 31764
#include <iostream>
using namespace std;
int main(void) {
	// Your code here!
	int N;
	cin >> N;

	if (N < 357) {
		cout << "0" << endl;
		return 0;
	}
	int nCount = 0;
	for (int i = 357; i <= N;) {
		bool b3, b5, b7;
		b3 = b5 = b7 = false;
		int nNum = i;
		while (nNum != 0) {
			int n = nNum % 10;
			if (!(n == 3 || n == 5 || n == 7)) {
				b3 = b5 = b7 = false;
				break;
			}
			else if (n == 3)
				b3 = true;
			else if (n == 5)
				b5 = true;
			else if (n == 7)
				b7 = true;
			nNum /= 10;
		}
		if (b3&&b5&&b7)
			nCount++;
		if (i % 10 == 7) {
			if (i % 100 / 10 == 7) {
				if (i % 1000 / 100 == 7) {
					if (i % 10000 / 1000 == 7) {
						if (i % 100000 / 10000 == 7) {
							if (i % 1000000 / 100000 == 7) {
								if (i % 10000000 / 1000000 == 7) {
									i += 5000000;
								}
								else {
									if (i / 1000000 == 0)i += 2000000;
									else i += 1000000;
								}
								i += 500000;
							}
							else {
								if (i / 100000 == 0)i += 200000;
								else i += 100000;
							}
							i += 50000;
						}
						else {
							if (i / 10000 == 0)i += 20000;
							else i += 10000;
						}
						i += 5000;
					}
					else {
						if (i / 1000 == 0)i += 2000;
						else i += 1000;
					}
					i += 500;
				}
				else i += 100;
				i += 50;
			}
			else i += 10;
			i += 6;
		}
		else i += 2;
	}
	cout << nCount << endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int L = sc.nextInt();
		
		int intArray[] = new int[N];

		int max = 999999999;
		int max_i = 0;
		for(int i = 0 ;i < N;i++){
			intArray[i] = L + (i + 1) - 1;
			if(max > Math.abs(intArray[i])){
				max = Math.abs(intArray[i]);
				max_i = i;
			}
		}
		int min = 0;
		int sum = 0;
		for(int i = 0 ;i < N;i++){
			if(max_i != i ){
				sum += intArray[i];
			}
		}

//		for(int i = 0 ;i < N;i++){
//			int sum = 0;
//			for(int j = 0 ;j < N;j++){
//				if(i != j){
//					sum += intArray[j];
//				}
//			}
//			if(min < Math.abs(max - sum)){
//				min = sum;
//			}
//		}

		System.out.println(sum);


	    
   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 21716
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,alice=0,bob=0;

int main(){
    cin>>N;
    int a[N];
    rep(i,N){
        cin>>a[i];
    }
    sort(a,a+N,greater<int>());
    rep(i,N){
        if(i%2==0){
            alice+=a[i];
        }else{
            bob+=a[i];
        }
    }
    out(alice-bob);
}


Measured memory_bytes: 256
num=gets.to_i
(1..num).each do |i|
  if i%3==0
    print " #{i}"
  elsif i%10==3
    print " #{i}"
  else
    k=i
    while k/10 > 0
      k = k/10
      if k%10==3
        print " #{i}"
        break
      end
    end
  end
end
puts

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

using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  if(a>b)
  {
      cout <<"a > b" << endl;
  }
  else if(a<b)
  {
      cout << "a < b" << endl;
  }
  else if(a=b)
  {
      cout << "a == b" << endl;
  }
  return(0);

}


Measured memory_bytes: 3092