akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def bubble_sort(A):
    for i in range(len(A)):
        for x in range(len(A)-1, i, -1):
            if A[x][1] < A[x-1][1]:
                A[x], A[x-1] = A[x-1], A[x]

def selection_sort(A):
    for i in range(len(A)):
        min_val = A[i][1]
        for x in range(i, len(A)):
            if A[x][1] < min_val:
                min_val = A[x][1]
                min_index = x
        if min_val < A[i][1]:
            A[min_index], A[i] = A[i], A[min_index]

def check_stable(srt_list, org_list):
    prev_val = None
    prev_pos = -1
    for card in srt_list:
        cur_pos = org_list.index(card)
        # print(card, cur_pos)
        if card[1] == prev_val:
            if cur_pos < prev_pos:
                print('Not stable')
                return
        prev_val = card[1]
        prev_pos = cur_pos

    print('Stable')


n = int(sys.stdin.readline())
org_list = sys.stdin.readline().split()
_list1 = org_list[:]
_list2 = org_list[:]

bubble_sort(_list1)
selection_sort(_list2)

print(' '.join(_list1))
check_stable(_list1, org_list)
print(' '.join(_list2))
check_stable(_list2, org_list)



Measured memory_bytes: 5616
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


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

    ll p[N];
    rep(i, N){
        cin >> p[i];
    }
    sort(p, p + N);

    ll ans = 0;
    rep(i, K){
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(long long*)a - *(long long*)b;
}

int min_comp(int min, int a)
{

}
int max_comp(int max, int a)
{
  if(max>a)    return max;
  else    return a;
}

int double_num(int num, int time)
{
if(time>=1){
    time = time - 1;
    num = num * 2;
    num = double_num(num, time);
     return num;
  }
if(time<=0) return num;
 }

int main()
{
  //int A, B, C, X, Y;
//  int m[101]={};
  long long min=0;
  int A, B, C, K;
  long long x[100001]={};
  long long v[100001]={};
  int i,j;
  long long cnt=0;
  long long max=0;
  long long ca=0;
  int point_a=1;
  int point_b=1;
  int point_c=1;
  
//    int k=0;

  scanf("%d %d %d %d", &A ,&B, &C, &K);
  //printf("%d\n", A);
 if(A>B){  max = A; point_a=0;} 
 else { max = B; point_b=0;}
 if(max<C){  max = C; point_c=0;point_a=1;point_b=1;}

 printf("%d\n", (A * point_a) + (B * point_b) + (C * point_c) +  double_num(max, K)); 
return 0;
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2
const int CMOD = 1e9 + 7;
int power_mod(int x, int y){
    int ans = 1;
    while(y > 0){
        if(y%2==1){
            ans *= x;
            ans %= CMOD;
        }
        x *= x;
        x %= CMOD;
        y /= 2;
    }
    ans = (ans%CMOD);
    return (ans<0?ans+CMOD:ans);
}

void ssolve(std::istream& in, std::ostream& out){
    int k; s(k);
    int curr = 7;
    f(i, 1,k + 1){
        if(curr%k==0){
            p(i);
            return;
        }
        curr = (curr * 10) + 7;
        curr %= k;
    }
    p(-1);
    return;
}

class CRepseptEditorial {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CRepseptEditorial solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3632
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = a % 10
B = b % 10
C = c % 10
D = d % 10
E = e % 10

S = []
sum = 0
if A != 0:
  S.append(A)
if B != 0:
  S.append(B)
if C != 0:
  S.append(C)
if D != 0:
  S.append(D)
if E != 0:
  S.append(E)
if len(S) == 0:
  sum = a + b + c + d + e
else:
  sum = (a //10 + b //10 + c //10 + d //10 + e //10)*10 + 10*(len(S) - 1) +min(S)
print(sum)


Measured memory_bytes: 12388
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;
int main(void) {
	int i,j,k=0;
	int x, y,z=0;
	int e = 0;
	cin >> x; cin >> y;
	for (i = 0; i <= x; i++) {
		z = y;
		k = 0;
		
		for (j = x-i; j >0; j--) {
			if (z >= 4) {
				z -= 4;
				k++;
			}
		}
		if (i != 0) {
			for (j = 0; j < i; j++) {
				if (z >= 2) {
					z -= 2;
					k++;
				}
			}
		}
		if ((z == 0)&&(x==k)) {
			cout << "Yes";
			e = 1;
			break;
		}
		
	}
	if (e != 1) {
		cout << "No";
	}
	
	return 0;
}

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

void dfs(int k, vector<int> &a, vector<int> &b){
  //2倍したときの値がnより大きければa[k-1]と同じ値を入れれば良い
  if(2 * k > n){
    b[k-1] = a[k-1];
    return;
  }
  int d = n / k;
  int g = k * d;
  int num = 0;
  //kを2倍、3倍あるいはhoge倍したときのb[hogek-1]の値を加算し
  //その加算した値とa[k-1]との偶奇が一致していれば0一致していなければ1
  while(g > k){
    num += b[g-1];
    g -= k;
  }
  if(a[k-1] == num % 2){
    b[k - 1] = 0;
  }else{
    b[k - 1] = 1;
  }
  return;
}

int main() {
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> b(n);
  vector<int> ans;
  int ans_count = 0;
  for (int i = n - 1; i >= 0; i--){
    dfs(i + 1, a, b);
  }
  int d = 0;
  rep(i, n){
    if (b[i] > 0){
      ans.push_back(i + 1);
    }
    //前から決めていくことで必ず決定できる。
    //if(b[i] % 2 != a[i]){
    //  cout << -1 << endl;
    //  return 0;
    //}
  }
  if(ans.size() == 0){
    cout << 0 << endl;
  }else {
    cout << ans.size() << endl;
    rep(i,ans.size()){
      cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");
    }
  }
}

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

int main() {
    int K, N; cin >> K >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    int max_diff = 0; 
    for (int i = 1; i < N; i++)
    {
        max_diff = max(max_diff, v[i]-v[i-1]);
    }
    max_diff = max(max_diff, K-v[N-1]+v[0]);
    cout << K - max_diff << endl;
}

Measured memory_bytes: 1024
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll nCm(ll n, ll m){
    if (m == 0 || m == n)
        return (1);
    else if (m == 1)
        return (n);
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    char x, y;
    cin >> x >> y;

    if(x < y){
        cout << '<' << endl;
    } else if(x > y){
        cout << '>' << endl;
    } else {
        cout << '=' << endl;
    }
}

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

int main(){
  int n;
  long long int res=0;
  vector<int> a;
  
  cin >> n;
  
  for(int i=0;i<n;i++){
    int _a;
    cin >> _a;
    a.push_back(_a);
  }
  
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      res+=a[i]*a[j];
    }
  }
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    string S;
    cin >> S;
    int s=S.size(),ans=1;
    vector<int> count(s+1);
    count[0]=0;
    rep(i,s){
        count[i+1]=count[i];
        if (S[i]=='1'){
            count[i+1]++;
        }
    }
    rep(i,s){
        int c=count[s-i]-count[i];
        if (c==s-2*i||c==0){
            ans=s-i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 896
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

struct UnionFind {
    int* parent;
    int N;
    UnionFind(int N) : N(N) {
        parent = new int[N];
        fill(parent, parent + N, -1);
    }
    ~UnionFind() {
        delete[] parent;
    }
    int root(int x) {
        if (parent[x] == -1) return x;
        return parent[x] = root(parent[x]);
    }
    bool query(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x); 
        y = root(y);
        if (x != y) {
            parent[x] = y;
        }
    }
};

int N;
#define L 100
double x[L], y[L], z[L], r[L];
bool input() {
    cin >> N;
    if (N == 0) return false;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> z[i] >> r[i];
    }
    return true;
}

const double INF = 1e20;
struct Kruskal {
    struct Edge {
        int from, to;
        double cost;
        Edge(int from, int to, double cost) : from(from), to(to), cost(cost) {}
        bool operator<(const Edge& e) const {
            return cost < e.cost;
        }
    };
    vector<Edge> G;
    Kruskal() {
        G.clear();
    }
    void addEdge(int from, int to, double cost) {
        G.push_back(Edge(from, to, cost));
    }
    double solve() {
        UnionFind uf(N);
        sort(whole(G));
        double Ret = 0;
        for (int i = 0; i < G.size(); i++) {
            if (!uf.query(G[i].from, G[i].to)) {
                uf.merge(G[i].from, G[i].to);
                Ret += G[i].cost;
            }
        }
        return Ret;
    }
};

#define POW2(x) ((x) * (x))
double Dist(int a, int b) {
    return sqrt(POW2(x[a] - x[b]) + POW2(y[a] - y[b]) + POW2(z[a] - z[b])) - (r[a] + r[b]);
}

void solve() {
    Kruskal K;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            K.addEdge(i, j, max(0.0, Dist(i, j)));
        }
    }
    printf("%.3lf\n", K.solve());
}

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

Measured memory_bytes: 1632
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 200005;
const i64 INF = 1e18;
const int MOD = 323232323;

int a[N], dp[N];

int main ()
{
    int n, ma = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        dp[a[i]] = dp[a[i] - 1] + 1;
        ma = max(ma, dp[a[i]]);
    }
    printf("%d\n", n - ma);
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int i, j;
    int p[8], q[8];
    for(i = 0; i < n; i++){scanf("%d", &p[i]);}
    for(i = 0; i < n; i++){scanf("%d", &q[i]);}
    for(i = 0; i < n; i++){p[i]--; q[i]--;}
    
    int a_temp[8];

    for(i = 0; i < n; i++){
        a_temp[i] = i;
    }
    int cnt = 1;
    int a, b;
    int flag_a = 0, flag_b = 0;
    int flag;
    int go_next;
    while(1){
        for(i = 0; i < n; i++){
            if(a_temp[i] != p[i]){
                break;
            }
            if(i == n - 1){
                a = cnt;
                flag_a = 1;
            }
        }

        for(i = 0; i < n; i++){
            if(a_temp[i] != q[i]){
                break;
            }
            if(i == n - 1){
                b = cnt;
                flag_b = 1;
            }
        }
        
        if(flag_a == 1 && flag_b == 1){
            break;
        }

        go_next = 0;
        //a_tempを1つ進める処理を書く
        do{
            a_temp[n - 1] += 1;
            for(i = 1; i < n; i++){
                if(a_temp[n - i] == n){
                    a_temp[n - i] = 0;
                    a_temp[n - i - 1]++;
                }
            }
            for(i = 0; i < n; i++){
                flag = 0;
                for(j = 0; j < n; j++){
                    if(a_temp[j] == i){
                        flag = 1;
                        break;
                    }
                }
                if(flag == 0){
                    break;
                }
                if(i == n - 1){
                    go_next = 1;
                }
            }
        }while(go_next == 0);
        cnt++;
    }
    printf("%d\n", a > b ? a - b : b - a);
    
    return 0;

}

Measured memory_bytes: 1732
import math

N, K = map(int, input().split(" "))
# A = list(map(minus_one, list(map(int, input().split(" ")))))

doubling_table = [list(map(lambda n: n - 1, list(map(int, input().split(" ")))))]
for i in range(0,int(math.log2(K))):
    doubling_table.append([doubling_table[i][doubling_table[i][j]] for j in range(0,N)])
#     next_table = [doubling_table[i][doubling_table[i][j]] for j in range(0,N)]
#     doubling_table.append(next_table)
# print(doubling_table)

city = 0
for i in range(int(math.log2(K)), -1, -1):
    if K >= 2 ** i:
        K, city = K - 2 ** i, doubling_table[i][city] 
#         city = doubling_table[i][city]
        
print(city + 1)

Measured memory_bytes: 217032
import sys

lineNumber = 0

#for line in ["3 6 9 7 5"]:
for line in sys.stdin.readlines():
    lineNumber += 1

    # get data
    List = map(int, line.strip().split(" "))

    List.sort()

    print "%d %d %d %d %d" % (List[4], List[3], List[2], List[1], List[0])

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

int main(void)
{
    long x = 0;
    long sum = 100;
    long money = 100;
    int year = 0;

    scanf("%ld",&x);

    while(x > sum){
        sum = money * 1.01;
        year++;
        money = sum;
    }
    printf("%d\n",year);

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans +=  a[i] - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		String s=sc.next();
		if(s.length()>k)
		{
			for(int i=0;i<k;i++)
			{
				System.out.print(s.charAt(i));
			}
			System.out.print("...");
		}
		else
		{
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 35748
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >> N;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    ll ans = 0;
    for(int i = 0; i < N; i++)
    {
        ans += a[i] - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 

*/
//================== INPUT ========================
int N,H;
vector<pii> A;
vector<pii> B;
//=================================================
void input()
{
    cin>>N>>H;
    A = vector<pii> (N);
    B = vector<pii> (N);
    rep(i,N){
        cin>>A[i].first>>A[i].second;
        B[i] = A[i];
    }
}

//=================================================
void solve()
{
    sort(A.rbegin(),A.rend());
    // A[0] : 残しておきたい
    pii strongest_a = A[0];
    //A.erase(A.begin());
    sort(A.begin(),A.end(), [](const pii &a, const pii &b) {return a.second > b.second;});

    // for (auto x: A){
    //     cout<<x.first<<" " << x.second<<endl;
    // }

    int ans = 0;
    int Aind = 0;
    int damage = 0;
    for (ans = 0; ; ++ans){
        if (damage >= H) break;
        if ((A.size() - Aind) && (strongest_a.first < A[Aind].second)) {
            damage += A[Aind].second;
            ++Aind;
        }
        else break;
    }
    
    if (damage < H){
        ans += ((H-damage - 1)/strongest_a.first) + 1;
    }
    cout<<ans<<endl;


    

    

}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3328
/*
 * ex 9-2
 * kamecha
 */
#include <stdio.h>
#include <stdlib.h>

#define SIZE (100000+10)

//スタックを単方向リストで実装
typedef struct node{
    char elem;
    struct node *next;
}node;

void push(node **first, char elem){
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}

//stackの一番上の値を取得
char top(node **first){
    if(*first == NULL)   exit(1);
    return (*first)->elem;
}

//debug用print関数
void debug_print(node **first){
    node *ptr = *first;
    while(ptr != NULL){
        printf("|%c| => ", ptr->elem);
        ptr = ptr->next;
    }
    puts("NULL");
}

int main(void){
    node *first = NULL;
    char str[SIZE];
    int ans = 0;
    scanf("%s", str);
    //下から順に取り除いていく
    for(int i = 0; str[i] != '\0'; i++){
        if(first == NULL){
            push(&first, str[i]);
        }else if(top(&first) == str[i]){
            push(&first, str[i]);
        }else{
            pop(&first);
            ans += 2;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

typedef long long ll; 

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

int main()
{
    ll n, a;
    
    cin >> n;
    
    cin >> a;
    
    int res = a;
    
    --n;
    
    while(n--)
    {
        cin >> a;
        res = gcd(res, a);
    }
    
    cout << res;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int D()
{
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
const int N=2e5+9;

int arr[N],frq[N];
int main(){

ll all=llD();
ll n=llD();
while(n-->0)
{
    ll b=llD();
    all-=b;
}
(all>=0)?printf("%d",all):puts("-1");

}
/**
bool ok(int val){
  int cntm=0,cntp=0;
  for(int i=0;i<n-val;i++)
  {
      cntm=0;cntp=0;
      for(int j=i;j<val;j++)
      {
      (arr[j]==1)?cntp++:cntm++;
      }
      if(cntp==cntm)
        break;
  }
  return cntp==cntm;
}
int binarySearch(){
  int low = 0, med, hi =n;
  while(low<hi){
    med = (low+hi+1)>>1;
    cout<<med<<" "<<hi<<" "<<low<<endl;
    if(ok(med))  low = med;
    else  hi = med-1;
  }
  return low;
}*/



/**
  int power1(int b, int p){               //O(p)
    if(!p)  return 1;
    return b*power1(b, p-1);
  }
  int power2(int b, int p){               //O(Log(p))
    if(!p)  return 1;
    int ret = power2(b, p/2);
    return (p&1 ? ret*ret*b : ret*ret);
  }
   int mul(int a, int b, int m){
      return (a%m * b%m) % m;
  }

*/


/**
void seive()
{
    bitset<N>iscomp;
    iscomp[0]=iscomp[1]=1;
    for(long long i=2; i<=N; ++i)
    {
        if(!iscomp[i])
        {
            a.push_back(i);
            for(long long j=i*i; j<=N; j+=i)
                iscomp[j]=1;
        }
    }
}
3
abc
abc
*/

    /**


    */


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 1e9+7;//998244353;
const LL LLINF = 1e18+7;
const int N=1e5+8;

int main()
{
    _boost;
    int n;
    cin>>n;
    vector<LD> ps(n);
    for(int i=0;i<n;i++)cin>>ps[i];
    vector<vector<LD>> dp(n+1,vector<LD>(n+1,0));
    dp[0][0]=1;
    LD wyn=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i+j>n)continue;
            if(i>0)
            {
                dp[i][j]+=ps[i+j-1]*dp[i-1][j];
            }
            if(j>0)
            {
                dp[i][j]+=(1-ps[i+j-1])*dp[i][j-1];
            }
            if(i+j==n &&i>j)wyn+=dp[i][j];
        }
    }
    cout<<setprecision(20)<<wyn;

}




Measured memory_bytes: 141056
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

// define eps
double EPS = 1e-10;

// Point2D & Vector2D
struct Point2D { 
	double x, y;
	Point2D (double a=0, double b=0) : x(a), y(b) {}
};
typedef Point2D Vector2D;

// Point2D's and Vector2D's operator
Point2D operator + (Point2D a, Point2D b) { return Point2D(a.x + b.x, a.y + b.y); }
Point2D operator - (Point2D a, Point2D b) { return Point2D(a.x - b.x, a.y - b.y); }
Point2D operator * (Point2D a, double d) { return Point2D(a.x * d, a.y * d); }
Point2D operator / (Point2D a, double d) { return Point2D(a.x / d, a.y / d); }

bool operator < (const Point2D& a, const Point2D& b) { return a.x != b.x ? a.x < b.x : a.y < b.y; }
bool operator > (const Point2D& a, const Point2D& b) { return b.x != a.x ? b.x < a.x : b.y < a.y; }
bool operator == (const Point2D& a, const Point2D& b) { return fabs(a.x-b.x)<EPS && fabs(a.y-b.y)<EPS; }

// basic function
double norm(Point2D a) { return a.x*a.x + a.y*a.y; }
double dot2D(const Vector2D& a, const Vector2D& b) { return a.x * b.x + a.y * b.y; }
double cross2D(const Vector2D& a, const Vector2D& b) { return a.x*b.y - a.y*b.x; }
double dist2D(const Point2D& a, const Point2D& b) { return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); }

bool is_vertical(const Vector2D& a, const Vector2D& b) { return fabs(dot2D(a, b))<EPS; }
bool is_parrallel(const Vector2D& a, const Vector2D& b) { return fabs(cross2D(a, b))<EPS; }

 
int main(){
    Point2D A, B, C, D;
    
    while (cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y>>D.x>>D.y) {
  		Vector2D AB = B - A; Vector2D CD = D - C;
  		if (is_vertical(AB, CD)) cout << "YES" << endl;
  		else cout << "NO" << endl;
    }  
 
    return 0;
}

Measured memory_bytes: 1216
local ffi = require("ffi")
local C = ffi.C
ffi.cdef[[
long long atoll(const char*);
]]

local function lltonumber(str)
  return C.atoll(str)
end

local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, 60 do
  t[i] = {}
end
do
  local j = 0
  for w in s:gmatch("%d+") do
    j = j + 1
    local v = lltonumber(w)
    for k = 1, 60 do
      t[k][j] = v % 2LL == 1LL
      v = v / 2LL
    end
  end
end
local flag = {}
for i = 1, 60 do
  flag[i] = 1
end
local pow2 = {}
pow2[1] = 1LL
for i = 2, 61 do
  pow2[i] = pow2[i - 1] * 2LL
end
local ret = 0LL

local tasks = {}
for ib = 60, 1, -1 do
  local right = false
  local cnt = 0
  local tib = t[ib]
  for i = 1, n do
    if tib[i] then
      cnt = cnt + 1
      right = i
      tasks[cnt] = i
    end
  end
  if flag[ib] == 1 then
    if cnt == 0 then
      -- nothing
    elseif cnt % 2 == 1 then
      ret = ret + pow2[ib]
    else
      ret = ret + pow2[ib + 1]
      for ic = ib - 1, 1, -1 do
        if t[ic][right] then
          flag[ic] = 1 - flag[ic]
          for i = 1, cnt do
            local z = tasks[i]
            t[ic][z] = not t[ic][z]
          end
        end
      end
    end
  else--flag[ib] == 0
    if cnt == 0 then
      ret = ret + pow2[ib + 1]
      -- nothing
    elseif cnt % 2 == 1 then
      ret = ret + pow2[ib]
    else
      ret = ret + pow2[ib + 1]
      for ic = ib - 1, 1, -1 do
        if t[ic][right] then
          for i = 1, cnt do
            local z = tasks[i]
            t[ic][z] = not t[ic][z]
          end
        end
      end
    end
  end
end
ret = tostring(ret):gsub("LL", "")
print(ret)


Measured memory_bytes: 135744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);

int N, M, K;

bool ok(){
	for(int i = 0; i <= N; i++)
		for(int j = 0; j <= M; j++){
			int area = (N - i) * (M - j) + i * j;
			if(area == K) return true;
		}
	return false;
}

int main() {
	cin >> N >> M >> K;
	cout << (ok() ? "Yes" : "No") << endl;
}

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

int main(void) 
{
    int i,sum;
    scanf("%d",&i);
    int V[i],C[i],S[i];
    for(int j = 0;j < i;j++)
    {
        scanf("%d",&V[j]);
    }
    for(int h = 0;h < i;h++)
    {
        scanf("%d",&C[h]);
    }
    for(int k = 0;k < i;k++)
    {
        S[k] = V[k] - C[k];
    }
    sum = 0;
    for(int l = 0;l < i;l++)
    {
        if(S[l] > 0)
        {
            sum = sum + S[l];
        }
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

typedef long long ll;

void solve() {
	int x;
	cin >> x;
	if(x >= 30)
	cout << "Yes";
	else
	cout << "No";
}

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

	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 100005
using namespace std;
int n,k,a[MN];
long long ans,s[MN],ss[MN];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),s[i]=s[i-1]+a[i],ss[i]=ss[i-1]+max(a[i],0);
	for(int i=0;i<=n-k;i++)ans=max(ans,ss[n]-ss[i+k]+ss[i]+max(0LL,s[i+k]-s[i]));
	printf("%lld\n",ans);
}



Measured memory_bytes: 2176
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		LinkedList<Integer> list = new LinkedList<Integer>();

		for (int i=0; i<n; i++) {
			String str = br.readLine();

			if (str.startsWith("insert")) {
				list.addFirst(Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}else if (str.equals("deleteFirst")) {
				list.pollFirst();
			}else if (str.equals("deleteLast")){
				list.pollLast();
			}else {
				list.remove((Integer)Integer.parseInt(str.substring(str.indexOf(" ")+1)));
			}
		}

		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		StringBuilder sb = new StringBuilder();
		sb.append(list.poll());
		for (Integer s : list) {
			sb.append(" ");
			sb.append(s);
		}
		bw.write(sb.toString());
		bw.newLine();
		bw.close();

		br.close();
	}
}



Measured memory_bytes: 137576
#include <iostream>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin, (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) {
    rep(i, a) {
      cout << b;
    }
  }
  else {
    rep(i, b) {
      cout << a;
    }
  }
}


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

int main(){

  int a,b,c;
  cin>>a>>b>>c;
  if(a<b){
    if(a<c){
      if(b<c){
        cout<<a<<" "<<b<<" "<<c<<endl;
      }else{
        cout<<a<<" "<<c<<" "<<b<<endl;
      }
    }else{
      cout<<c<<" "<<a<<" "<<b<<endl;
    }
  }else{
    if(b<c){
      if(a<c){
        cout<<b<<" "<<a<<" "<<c<<endl;
      }else{
        cout<<b<<" "<<c<<" "<<a<<endl;
      }
    }else{
      cout<<c<<" "<<b<<" "<<a<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
int main()
{
	int n;
	long long num[90];
	num[0]=2;
	num[1]=1;
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		num[i]=num[i-2]+num[i-1];
	}
	printf("%lld\n",num[n]);
	return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
a = list(map(int, input().split()))
v = []
currMin = a[0]
for i in range(1, n):
  v.append((currMin, a[i]))
  currMin = min(currMin, a[i])

v = sorted(v, key=lambda x: x[1] - x[0], reverse=True)
cnt = 0
for i in range(len(v)):
  if v[i][1] - v[i][0] == v[0][1] - v[0][0]:
    cnt += 1
print(cnt)


Measured memory_bytes: 19796
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val count = Array(4) {0}
    repeat(3) {
        count[sc.nextInt() - 1]++
        count[sc.nextInt() - 1]++
    }
    var isNo = false
    var oddCount = 0
    for (x in count) {
        if (x == 0) {
            isNo = true
            break
        }
        if (x % 2 == 1) {
            oddCount++
        }
    }
    if (isNo || oddCount != 0 && oddCount != 2) {
        println("NO")
    } else {
        println("YES")
    }
}

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


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

#define MAX_H (100)
#define MAX_W (100)
#define MAX_N (MAX_H * MAX_W)

int main(int argc, char *argv[]) {
  // read inputs
  int H, W, N, as[MAX_N];
  scanf("%d %d %d", &H, &W, &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // an optimal solution : circle towards the center
  const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
  int css[MAX_H][MAX_W], dir = 0, cnt = 0;
  int i = 0, j = 0, k = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      css[i][j] = -1;
    }
  }
  css[0][0] = k + 1;
  cnt++;
  while (k < N) {
    const int i_nxt = i + di[dir], j_nxt = j + dj[dir];
    // if current color is finished, move to the next color
    if (cnt >= as[k]) {
      cnt = 0;
      k++;
    }
    // try coloring the next cell
    if (i_nxt >= 0 && i_nxt < H && j_nxt >= 0 && j_nxt < W &&
        css[i_nxt][j_nxt] < 0) {
      css[i_nxt][j_nxt] = k + 1;
      cnt++;
      i = i_nxt;
      j = j_nxt;
    } else {
      dir = (dir + 1) % 4;
    }
  }

  // print the solution
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      printf("%d ", css[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] v = new double[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextDouble();
        }
        Arrays.sort(v);
        for (int i = 0; i < n - 1; i++) {
            v[i + 1] = (v[i] + v[i + 1]) / 2d;
        }
        System.out.println(v[n - 1]);
        sc.close();
    }
}


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

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

    int ans;
    if((a==1 && b==2) || (a==2 && b==1)) ans = 3;
    else if((a==2 && b==3) || (a==3 && b==2)) ans = 1;
    else if((a==1 && b==3) || (a==3 && b==1)) ans = 2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=100000+5;
struct P
{
    ll m;
    ll h;
}a[N];
ll a1[N],a2[N];
bool cmp(const P &p1,const P &p2)
{
    return p1.m<p2.m;
}
int main()
{
    int n;
    ll x;
    scanf("%d%lld",&n,&x);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&a[i].m,&a[i].h);
    }
    sort(a+1,a+n+1,cmp);
    ll _max=0,sum;
    sum=0;
    a1[0]=0;
    a2[n+1]=0;
    for(int i=1;i<=n;i++)
    {
        sum+=a[i].h;
        a1[i]=max(a1[i-1],sum-a[i].m);
    }
    sum=0;
    for(int i=n;i>=1;i--)
    {
        sum+=a[i].h;
        a2[i]=max(a2[i+1],sum-(x-a[i].m));
    }
    sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=a[i].h;
        _max=max(sum+a2[i+1]-2*a[i].m,_max);
    }
    sum=0;
    for(int i=n;i>=1;i--)
    {
        sum+=a[i].h;
        _max=max(sum+a1[i-1]-2*(x-a[i].m),_max);
    }
    printf("%lld\n",max(_max,max(a1[n],a2[1])));
    
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/

int main() {
  int n,k;
  cin >> n>>k;
  int price;
  int tmp;
  vector<int> min(k,1000);
  //int min[3]={1000, 1000,1000};
  
  rep(i,n){
    cin >> price;
    if(price<min[k-1]) min[k-1]=price;
    for(int l=k-1;l>0;l--){
      if(min[l]<min[l-1]){
        tmp = min[l];
        min[l]=min[l-1];
        min[l-1]=tmp;
      }
    }
  }
  int sum=0;
  rep(i,k){
    sum+=min[i];
  }
  cout << sum;
  return 0;
}


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

using namespace std;

using ll = long long;

template<int N>
struct Prime {
    bool is_p[N + 1]; // 素数表

    constexpr Prime() : is_p() {
        for (int i = 2; i <= N; ++i) is_p[i] = true;
        is_p[0] = is_p[1] = false;
        for (long long i = 2; i <= N; ++i) {
            if (is_p[i])
                for (long long j = i * i; j <= N; j += i)
                    is_p[j] = false;
        }
    }
    constexpr bool operator[](const int idx) const { return is_p[idx]; }
};

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

    const int MAX_N = 55555;
    Prime<MAX_N> p;

    int n;

    cin >> n;
    for (int i = 2; n && i <= MAX_N; ++i) {
        if (p[i] && (i % 5) == 1) {
            --n;
            cout << i << (n == 0 ? '\n' : ' ');
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int N = 40;

int h, w, s, u[N][N], a[N][N], total;

void input()
{
    memset(u, 0, sizeof(u));
    memset(a, 0, sizeof(a));

    rep(i, h) rep(j, w) {
        cin >> u[i][j];
        a[i + 1][j + 1] = a[i + 1][j] + a[i][j + 1] - a[i][j] + u[i][j];
    }
    total = a[h][w];
}

inline int acc(int x, int y, int xx, int yy)
{
    return a[yy][xx] - a[y][xx] - a[yy][x] + a[y][x];
}

typedef pair<int, int> pii;

pii f(pii a, pii b)
{
    return mp(a.first + b.first, min(a.second, b.second));
}

pii mem[N][N][N][N];

pii recur(int x, int y, int xx, int yy)
{
    pii& ret = mem[x][y][xx][yy];
    if (ret.first >= 0) return ret;

    int part = acc(x, y, xx, yy);
    if (total - part > s) return mp(-1, -1);

    ret = mp(1, s - (total - part));
    repi(mx, x + 1, xx) {
        pii tmp = f(recur(x, y, mx, yy), recur(mx, y, xx, yy));
        ret = max(ret, tmp);
    }
    repi(my, y + 1, yy) {
        pii tmp = f(recur(x, y, xx, my), recur(x, my, xx, yy));
        ret = max(ret, tmp);
    }
    return ret;
}

void solve()
{
    memset(mem, -1, sizeof(mem));

    pii ans = recur(0, 0, w, h);
    cout << ans.first << ' ' << ans.second << endl;
}

int main()
{
    while (cin >> h >> w >> s and h) {
        input();
        solve();
    }

    return 0;
}

Measured memory_bytes: 21188
import java.util.Scanner;

public class Main {

	// define variables & initialize
	private static int cnt = 0;	// how many bubbleSort is used
	
	// sort method :: sort given array using insertion Sort
	public static void sort(int[] _A, int _n) {
		int flg = 1;
		while (flg != 0) {
			flg = 0;
			for (int i = _n - 1; i >= 1; --i) {
				if (_A[i] < _A[i - 1]) {
					_A[i] = _A[i] ^ _A[i - 1];
					_A[i - 1] = _A[i] ^ _A[i - 1];
					_A[i] = _A[i] ^ _A[i - 1];
					flg = 1;
					++cnt;
				}
			}
		}
		
	}
	
	// print method :: print array
	public static void print(int[] _A) {
		for (int i = 0; i < _A.length; ++i) {
			System.out.print(_A[i]);
			if (i != _A.length - 1)
				System.out.print(" ");
		}
		System.out.println();
	}
	
	// get method :: get cnt (how many bubbleSort was used)
	public static int get() {
		return cnt;
	}
public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		////////////////////////////////////
		int n = 0;
		int[] A;
		
		n = sc.nextInt();
		A = new int[n];
		
		for (int i = 0; i < n; ++i) {
			A[i] = sc.nextInt();
		}
		
		sort(A, n);
		print(A);
		System.out.println(get());
		
		////////////////////////////////////
		sc.close();
	}



}

Measured memory_bytes: 26452
n=gets.chop.to_i
array=[]
for i in 0..n do
 a=gets.to_i
 array[i]=a
end
max=0
index=0
for i in 0..n-1 do
 if array[i]>max
   max=array[i]
   index=i
   end
 end
 max2=max
for j in 0..n-1 do
 if j==index
 max=0
 for k in 0..n-1 do
  if k!=j
  if array[k]>max
    max=array[k]
    end
   end
  end
  
  end
  puts max
  if j==index
      max=max2
  end
end


Measured memory_bytes: 5192
import java.util.*;

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

      int cnt=0;

      int n = sc.nextInt();
      int[] a = new int[n];

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

      for(int i=0;i<n-2;i++){
        if(a[i]<a[i+1] && a[i+1]<a[i+2]){
          cnt++;
        }
        else if(a[i]>a[i+1] && a[i+1]>a[i+2]){
          cnt++;
        }
      }

      System.out.println(cnt);

    }
}


Measured memory_bytes: 23124
#coding:utf-8

N = int(input())

L = [int(y) for y in input().split()]

ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            Lon = [L[i],L[j],L[k]]
            Lon.sort()
            L1 = Lon[0]
            L2 = Lon[1]
            L3 = Lon[2]
            if(L1 != L2 and L2 != L3 and L3 != L1)and(L1 + L2 > L3)and(abs(L1 - L2) < L3):
                ans += 1

print("{}".format(ans))

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> ii;

char str[55];
map<string, int> mymap[20];

int main(){
    int n;
    ll ans = 0;
    scanf("%d %s", &n, &str);

    for (int bit = 0; bit < (1<<n); bit++){
        string cur;
        int cnt = 0;
        for (int j = 0; j < n; j++)
            if ((1<<j) & bit)
                cur.pb(str[j]), cnt++;
        for (int j = n-1; j >= 0; j--)
            if (!((1<<j)&bit))
                cur.pb(str[j]);

        mymap[cnt][cur]++;
    }

    for (int bit = 0; bit < (1<<n); bit++){
        string cur;
        int cnt = 0;
        for (int j = n-1; j >= 0; j--)
            if (!((1<<j)&bit))
                cur.pb(str[j+n]), cnt++;
        for (int j = 0; j < n; j++)
            if ((1<<j) & bit)
                cur.pb(str[j+n]);

        if (mymap[cnt].count(cur))
            ans += mymap[cnt][cur];
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 37120
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  int t[n+1], x[n+1], y[n+1];
  t[0] = 0; x[0] = 0; y[0] = 0;
  for (int i=1; i<n+1; i++) scanf("%d%d%d", t+i, x+i, y+i);
  bool canTrip = true;
  for (int i=0; i<n; i++) {
    int time = t[i+1] - t[i];
    int dist = x[i+1] + y[i+1] - x[i] - y[i];
    if (time < dist || (time - dist)%2 != 0) {
      canTrip = false;
      break;
    }
  }
  if (canTrip) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	long long a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	if((a[0]%2 == 0) || (a[1]%2 == 0) || (a[2]%2 == 0))cout << 0 << endl;
	else cout << a[0] * a[1] << endl;
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<double>x(n);
	vector<string>u(n);
	double sum = 0;
	rep(i, n) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY") {
			sum += x[i];
		}
		else {
			sum += x[i] * 380000;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
n,k=list(map(int,input().split()))
a=[0]+ list(map(int,input().split()))

visited=[1]

for i in range(n):
  next=a[visited[-1]]
  visited.append(next)
  
loop_end=n
loop_start=n-1
while visited[loop_start]!=visited[loop_end]:
  loop_start-=1
period=loop_end-loop_start
#print(visited) 
#print("p:",period)
#print("(k-n)%period:",(k-n)%period)

if k<n+1:
  print(visited[k])
  exit()
else:
  print(visited[n-period+(k-n)%period])

Measured memory_bytes: 32364
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

int kuraiwa(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

bool kaibun(int n) {
	int a[5];
	for (int i = 0; i < 5; i++) {
		a[i] = n % 10;
		n /= 10;
	}
	if (a[0] == a[4] && a[1] == a[3]) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int n;
	cin >> n;
	int max = 1;
	int x = pow(n, 0.5);
	int tmp;
	rep(i, x + 1){
		if (i < 2){
			continue;
		}
		tmp = i;
		do{
			if (max < tmp){
				max = tmp;
			}
			tmp *= i;
		} while (tmp <= n);
	}
	cout << max << endl;
	return 0;
}


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

namespace AOJ1_4_C
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i > 0; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                string ope = str[1];
                int b = int.Parse(str[2]);

                int Answer;
                if (ope == "+")
                {
                    Answer = a + b;
                }
                else if (ope == "-")
                {
                    Answer = a - b;
                }
                else if (ope == "*")
                {
                    Answer = a * b;
                }
                else if (ope == "/")
                {
                    Answer = a / b;
                }
                else if (ope == "?")
                {
                    break;
                }
                else
                {
                    break;
                }
                Console.WriteLine(Answer);
            }
        }
    }
}



Measured memory_bytes: 15948