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

public class Main {

    static int n;
    static int[][] g;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int m = sc.nextInt();
        g = buildGraph(sc, n, m);
        boolean[] used = new boolean[n];
        int ans = dfs(used, 0);

        System.out.println(ans);
        sc.close();
    }

    private static int dfs(boolean[] used, int v) {
        int ret = 0;
        boolean[] used2 = new boolean[n];
        for(int i = 0; i < n; i++) used2[i] = used[i];
        used2[v] = true;
        for(int next: g[v]){
            if(!used2[next]) ret += dfs(used2, next);
        }
        boolean allUsed = true;
        for(int i = 0; i < n; i++) if(!used2[i]) allUsed = false;
        if(allUsed) ret++;
        return ret;
    }

    public static int[][] buildGraph(Scanner sc, int n, int m){
        int[][] graph = new int[n][];
        int[][] edges = new int[m][2];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() -1;
            int b = sc.nextInt() -1;
            edges[i][0] = a;
            edges[i][1] = b;
            deg[a]++;
            deg[b]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            graph[a][--deg[a]] = b;
            graph[b][--deg[b]] = a;
        }

        return graph;
    }

}

Measured memory_bytes: 24508
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    vector<string> words(4);
    words = {"dream", "dreamer", "erase", "eraser"};
    for(int i = 0; i < 4; i++){
        reverse(words.at(i).begin(), words.at(i).end());
    }
    bool check1 = true;
    for(int i = 0; i < S.size();){
        bool check2 = false;
        for(int j = 0; j < 4; j++){
            string t = words.at(j);
            if(S.substr(i, t.size()) == t){
                check2 = true;
                i += t.size();
            }
        }
        if(!check2){
            check1 = false;
            break;
        }
    }
    if(check1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

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

int n, m;
vector<P> edges(0);
vector<vector<bool>> graph(100, vector<bool>(100, false));
bool visited[100];

void dfs(int pos)
{
    visited[pos] = true;
    for(int i = 1; i <= n; i++)
    {
        if(graph[pos][i] && !visited[i])
        {
            dfs(i);
        }
    }
}

int main()
{
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        edges.emplace_back(P(a, b));
        graph[a][b] = graph[b][a] = true;
    }
    
    int res = 0;
    for(auto x : edges)
    {
        int a = x.first, b = x.second;
        graph[a][b] = graph[b][a] = false;
        rep(i, n + 1) visited[i] = false;
        dfs(1);
        for(int i = 1; i <= n; i++)
        {
            if(!visited[i])
            {
                res++;
                break;
            }
        }
        graph[a][b] = graph[b][a] = true;
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  int n, m, x;

  while (cin >> n >> m >> x) {
    int l = 0;
    int r = 0;
    for (int i = 0; i < m; i++) {
      int y;
      cin >> y;
      if (y < x) {
        l++;
      } else {
        r++;
      }
    }

    cout << min(l, r) << endl;
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())
    kushi = list(map(int, input().split()))
    kushi.sort()

    total = 0
    for i in range(n):
        total += kushi[i*2]
    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
N, M = map(int, input().split())
H = list(map(int, input().split()))
good = [0]*N

for i in range(M):
    A, B =map(int, input().split())
    if H[A-1] < H[B-1]:
        good[A-1] = 1
    elif H[A-1] == H[B-1]:
        good[A-1] = 1
        good[B-1] = 1
    else:
        good[B-1] = 1

print(good.count(0))

Measured memory_bytes: 19980
#include <iostream>

using namespace std;

int main()
{
    int n,d;
    cin>>n>>d;
    int i=d+1,count=0;
    while((i-d)<=n)
    {
        count++;
        i+= 2*d + 1;
    }
    cout<<count<<endl;
    return 0;
}


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

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

    int n;
    cin >> n;
    vector<double> X(n), Y(n);
    for(int i = 0; i < n; i++){
        cin >> X[i] >> Y[i];
    }

    vector<int> I(n);
    for(int i = 0; i < n; i++){
        I[i] = i;
    }

    sort(I.begin(), I.end());

    double ans = 0;
    do {
        double bx = X[I[0]], by = Y[I[0]];
        double cost = 0;
        for(int i = 1; i < n; i++){
            double dx = (bx - X[I[i]]);
            double dy = (by - Y[I[i]]);
            cost += sqrt((dx * dx) + (dy * dy));
            bx = X[I[i]];
            by = Y[I[i]];
        }
        ans += cost;
    }while(next_permutation(I.begin(), I.end()));

    double m = 1;
    for(int i = 1; i <= n; i++){
        m *= i;
    }

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

    return 0;
}

Measured memory_bytes: 256
S = input()

from itertools import combinations

s = int(S)
for l in range(1, len(S)):
    for c in combinations(range(1, len(S)), l):
        c = sorted(c)
        n = [int(S[lower:upper]) for lower, upper in zip([0] + c, c + [len(S)])]
        s += sum(n)

print(s)


Measured memory_bytes: 3060
K = input()
K_int = int(K)
digit = len(K)
D = int(input())
MOD = 10**9 + 7

# dp[d][r][i] : (d+1)桁目の数がiで、それまでの桁の数の和をDで割ったときの余りがrとなる組合せ
dp = [[[0]*10 for r in range(D)] for d in range(digit)]

for i in range(10):
  dp[0][i%D][i] += 1

for d in range(1, digit):
  for r in range(D):
    s = sum(dp[d-1][r])
    for i in range(10):
      dp[d][(r+i)%D][i] += s
      dp[d][(r+i)%D][i] %= MOD

ans = 0
r = 0
for _d, k in enumerate(K, 1):
  d = digit - _d
  k = int(k)
  if _d == 1:
    for i in range(1, k):
      ans += dp[d][0][i]
      ans %= MOD
  else:
    for i in range(1, 10):
      ans += dp[d][0][i]
      ans %= MOD
    
    for i in range(k):
      ans += dp[d][r][i]
      ans %= MOD
  
  r = (r-k)%D

e = 0
for i in K:
  e += int(i)
  e %= D

if e % D == 0:
  ans += 1
  ans %= MOD

print(ans)

Measured memory_bytes: 174812
import java.util.*

fun main (args : Array<String>){
    val scanner = Scanner(System.`in`)
    val O = scanner.next()
    val E = scanner.next()
    var string = ""
    for(i in O.indices){
        string += O[i]
        string += E.getOrElse(i) { ' ' }
    }
     println(string)
}

Measured memory_bytes: 31516
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int N, K; readf("%d %d\n", &N, &K);
    auto C = new int[N],
         R = new int[N];
    foreach (i; 0 .. N) {
        readf("%d %d\n", &C[i], &R[i]);
    }
    //R.writeln;
    //C.writeln;
    auto g = new int[][N];
    foreach (i; 0 .. K) {
        int A, B; 
        readf("%d %d\n", &A, &B);
        A--; B--;
        g[A] ~= B;
        g[B] ~= A;
    }

    auto G = new int[][N];
    foreach (i; 0 .. N) {
        struct S { int x, k; }
        DList!S Q; Q.insert(S(i, R[i]));
        auto used = new bool[N];
        used[i] = true;
        foreach (j; g[i]) {
            if (used[j]) continue;
            used[j] = true;
            G[i] ~= j;
            Q.insert(S(j, R[i] - 1));
        }
        while (!Q.empty) {
            S n = Q.front; Q.removeFront;
            if (n.k == 0) continue;
            foreach (j; g[n.x]) {
                if (used[j]) continue;
                G[i] ~= j;
                used[j] = true;
                Q.insert(S(j, n.k - 1));
            }
        }
    }

    struct T { int v, w; }
    BinaryHeap!(Array!T, "a.w > b.w") PQ; PQ.insert(T(0, 0));
    auto d = new int[N];
    d[] = int.max; d[0] = 0;
    auto used = new bool[N];
    used[0] = true;
    while (!PQ.empty) {
        T n = PQ.front; PQ.removeFront;
        foreach (v; G[n.v]) {
            if (used[v]) continue;
            int nw = n.w + C[n.v];
            if (nw < d[v]) {
                d[v] = nw;
                PQ.insert(T(v, nw));
            }
        }
    }

    d[N - 1].writeln;

    /*
    foreach (i; 0 .. N) {
        writeln(i + 1, " ", G[i].map!"a + 1");
    }
    */
}

Measured memory_bytes: 88040
#include <iostream>
#include <vector>
#include <unordered_map>
#include <utility>
#include <algorithm>

using namespace std;

void outputNum(long num) {
  if (num < 0) cout << "000000";
  else if (num < 10) cout << "00000" << num;
  else if (num < 100) cout << "0000" << num;
  else if (num < 1000) cout << "000" << num;
  else if (num < 10000) cout << "00" << num;
  else if (num < 100000) cout << "0" << num;
  else cout << num;
}

int main(void) {
  long N, M; // N: 県の数, M: 市の数
  cin >> N >> M;

  unordered_map< long, vector< long > > data;
  vector< pair< long, long > > memo;

  for (long i = 0; i < M; i++) {
    long P, Y;
    cin >> P >> Y;
    data[P].push_back(Y);
    memo.push_back(make_pair(P, Y));
  }

  for (auto it = data.begin(); it != data.end(); ++it) {
    sort(it->second.begin(), it->second.end());
/*
    cout << it->first << " : ";
    for (auto x : it->second) {
      cout << x << ", ";
    }
    cout << endl;
*/
  }

  for (auto it : memo) {
    long P = it.first;
    long Y = it.second;

/*
    cout << "P = " << P << ", Y = " << Y << endl;

    cout << P << " : ";
    for (auto x : data[P]) {
      cout << x << ", ";
    }
    cout << endl;
*/

    auto lower = lower_bound(data[P].begin(), data[P].end(), Y);
//    cout << "lower: " << lower - data[P].begin() << endl;
    outputNum(P);
    outputNum(lower - data[P].begin() + 1);
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 11800
import java.util.*;

public class Main {
	public static void main( String[] args ) {
		
		Scanner sc = new Scanner( System.in );
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int cnt = 0;
		
		for (int a = 0; a < A + 1; a++ ) {
			
			for ( int b = 0; b < B + 1; b++ ) {
				
				for ( int c = 0; c < C + 1; c++ ) {
					
					if (500 * a + 100 * b + 50 * c == X ) {
						cnt += 1;
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

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

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

    sort(a, a + 3);
    if (a[0] == a[1] && a[1] == a[2]) {
        cout << "1" << endl;
    } else if (a[0] == a[1] || a[1] == a[2]) {
        cout << "2" << endl;
    } else {
        cout << "3" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int A, B, C, K;
    std::cin >> A >> B >> C >> K;

    if (K < A) {
        std::cout << K << std::endl;
        return 0;
    }

    K -= A;

    if (K < B) {
        std::cout << A << std::endl;
        return 0;
    }

    K -= B;

    std::cout << A - K << std::endl;
}


Measured memory_bytes: 3652
N = int(input())
H = list(map(int, input().split()))

dp = [0] * (N+1)
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp[i] = min(dp[i-2]+abs(H[i-2]-H[i],), dp[i-1]+abs(H[i-1]-H[i]))

print(dp[N-1])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[10000];
int T[10000];
int main(){
    int N, K;
    cin >> N >> K;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    sort(A, A+N);
    int right = N-1;
    int left = N-1;
    ll sum = A[N-1];
    while(1){
        if(sum >= K){
            sum -= A[right];
            T[right]++;
            right--;
        }
        else{
            ll tmps = sum;
            for(int i = left-1; i >= 0; i--){
                tmps += A[i];
                if(tmps < K) break;
                T[i]++;
                tmps -= A[i];
            }
            left--;
            if(left < 0) break;
            sum += A[left];
        }
    }


    for(int i = 1; i < N; i++){
        T[i] += T[i-1]; 
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(!T[i]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, K, C := getInt(), getInt(), getInt()
	s := []byte(getString())

	a := make([][]int, 2)
	sum := [2]int{0, 0}
	for ri := 0; ri < 2; ri++ {
		a[ri] = make([]int, N)
		c := 0
		cnt := 1
		for i := 0; i < N; i++ {
			// out(i, c, s[i])
			if c <= 0 && s[i] == 'o' {
				a[ri][i] = cnt
				cnt++
				c = C + 1
			}
			c--
		}
		sum[ri] = cnt - 1
		for i := 0; i < N/2; i++ {
			s[i], s[N-1-i] = s[N-1-i], s[i]
		}
	}

	// out(a[0])

	for i := 0; i < N/2; i++ {
		j := N - 1 - i
		a[1][i], a[1][j] = a[1][j], a[1][i]
	}

	// out(a[1])
	// out(sum)
	if sum[0] > K && sum[1] > K {
		return
	}

	for i := 0; i < N; i++ {
		if a[0][i] == 0 || a[1][i] == 0 {
			continue
		} else {
			out(i + 1)
		}
	}

}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main(void){
   int D,G;
   cin>>D>>G;
   vector<int> p(D),c(D);
   for(int i=0;i<D;i++){
      cin>>p[i]>>c[i];
   }
   int ans=10000;
   for(int i=0;i<(1<<D);i++){
      int sum=0;
      int cnt=0;
      int incomp=-1;
      for(int j=0;j<D;j++){
         if(i&(1<<j)){
            sum+=100*(j+1)*p[j]+c[j];
            cnt+=p[j];
         }else{
            incomp=j;
         }
      }
      if(sum<G){
         int sum_rest=G-sum;
         double rest=(double)sum_rest/(double)(100*(incomp+1));
         if(ceil(rest)>=p[incomp]) continue;
         cnt+=ceil(rest);
      }
      ans=min(ans,cnt);
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
    string S=Console.ReadLine();
     int ans=0;
     int x=0;
      for(int i=0;i<N;i++){
        if(S.Substring(i,1)=="I"){
          x++;
        }else{
          x--;
        }if(x>ans){
          ans=x;
        }
      }
      Console.WriteLine(ans);
  
    }
    
  }

}


Measured memory_bytes: 27136
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("ouut.txt","w",stdout);
  #endif
}

int main()
{
  fast_io
  go();
  int n;cin>>n;
  vi a(n),b(n);
  string aa="",bb="";
  for0(i,n)
  {
    cin>>a[i];
    aa+=a[i];
  }
  for0(i,n)
  {
    cin>>b[i];
    bb+=b[i];
  }
  if(aa==bb)
    cout << "0" <<"\n";
  else if(aa<bb)
  {
    int c=0;
    while(1)
    {
      if(aa==bb)
        break;
      next_permutation(aa.begin(),aa.end());
      c++;
    }
    cout << c <<"\n";
  }
  else
  {
    int c=0;
    while(1)
    {
      if(aa==bb)
        break;
      next_permutation(bb.begin(),bb.end());
      c++;
    }
    cout << c <<"\n";
  }

}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
char s[3001];
char t[3001];
int n, m;
int dp[3001][3001];
int solve(int i, int j) {
    //cout <<i<< " " << j << endl;
    if(i == -1 || j == -1)
        return 0;
    int &ans = dp[i][j];
    if(ans != -1) return ans;
    if(s[i-1] == t[j-1])
        return ans = 1 + solve(i-1, j-1);
    return ans = max(solve(i-1, j), solve(i,j-1));
}
vector<char> ans;
void print(int i,int j, int cur) {
    if(cur == 0) return;
    if(i > 0) {
        if(j > 0) {    
            if(dp[i][j-1] == dp[i][j])
                print(i,j-1,cur);
            else if(dp[i-1][j] == dp[i][j])
                print(i-1,j,cur);
            else if(dp[i-1][j-1] + 1 == dp[i][j])
                ans.push_back(s[i-1]), print(i-1,j-1,cur-1);
        }
        else {
            if(dp[i-1][j] == dp[i][j])
                print(i-1,j,cur);
        }
    }
    else {
        if(j > 0) {    
            if(dp[i][j-1] == dp[i][j])
                print(i,j-1,cur);
        }    
    }  
}
int main(int argc, char const *argv[]) {
    scanf("%s", s);
    scanf("%s", t);
    n = strlen(s);
    m = strlen(t);
    for(int i=0;i<=n;++i)
    for(int j=0;j<=m;++j)
        dp[i][j] = -1;
    for(int j=0;j<=m;++j)
        dp[0][j] = 0;
    for(int j=0;j<=n;++j)
        dp[j][0] = 0;
    
    int k = solve(n, m);
    
    print(n, m, k);
    reverse(ans.begin(), ans.end());
    for(int i=0;i<ans.size();++i)
        putchar(ans[i]);
    putchar(10);
    return 0;
}

Measured memory_bytes: 39040
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	fastio
	string s;
	cin>>s;
	cout<<s[0]<<s.size()-2<<s[s.size()-1];
	return 0;
}

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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<int> B;
    for(int i = 0; i + 1 < N; ++i) {
        B.push_back(A[i + 1] - A[i]);
    }
    int res = 1;
    ll pre = -inf<ll>;
    for(int i = 0; i < N - 1; ++i) {
        if(pre != -inf<ll> && 1LL * B[i] * pre < 0) {
            res++;
            pre = -inf<ll>;
        } else {
            if(B[i] != 0) {
                pre = B[i];
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1276
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cassert>
#include <numeric>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef long long ll;
typedef double lf;
typedef long double llf;
typedef pair<int,int> pii;
typedef vector<int> vec;
#define fi first
#define se second
/* */
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)
#define forEach(i, s) for(auto i=begin(s);i!=end(s);i++)
#define for_each_n(i, s, n) for(auto i=begin(s),_5=next(i,n);i!=_5;i++)
#define pb push_back
#define mp make_pair

/* special */
#define Mem(x) memset(x,0,sizeof(x))
#define GET_MACRO(_0,_1,_2,_3,_NAME,...) _NAME
/* */
#define rep(...)  GET_MACRO(_0,##__VA_ARGS__,rep3,rep2,rep1,rep0)(__VA_ARGS__)
	#define rep3(i,a,b) for(int i=(a);i<(b);++i)
	#define rep2(i,a) for(int i=0;i<(a);++i)
	#define rep1(a) rep2(_,a)
	#define rep0()	while(1)
#define callOnce if([]{static int i=-1;i++;return !i;}())


/* input */
namespace my{
	#define out(x) cout<<(x)<<endl
	inline int in(int &x) {return scanf("%d",&x);}
	inline int in(double &x) {return scanf("%lf",&x);}
	inline int in(ll &x) {return scanf("%lld",&x);}
	inline int in(int &x,int &y) {return scanf("%d %d",&x,&y);}
	inline int in(int &x,int &y,int &z) {return scanf("%d %d %d",&x,&y,&z);}
	inline int in(char s[]) {return scanf("%s",s);}
	inline int in(char &c) {return scanf("%c",&c);}
}

using namespace my;

/* debug */
#ifndef ONLINE_JUDGE
	#define D0()
	#define D1(x) {cout<<" ";cout.width(5);cout<<(x);}
	#define D2(x,y) {D1(x)D1(y)}
	#define D3(x,y,z) {D2(x,y)D1(z)}
	#define Dset(...) for(auto i : __VA_ARGS__ ) D1(i) //std::size()
	#define Darr1(x,fir) for(auto _7 = begin(x),_6=next(begin(x),fir);_7!=_6;++_7) D1(*_7)
	#define Darr2(x,fir,sec) for(auto _8=begin(x),_9=next(begin(x),fir);_8!=_9;++_8){ Darr1((*_8),sec)D()}
	#define D(...) {cout<<#__VA_ARGS__<<" ";GET_MACRO(_0,##__VA_ARGS__,D3,D2,D1,D0)(__VA_ARGS__);cout<<endl;}
	#define Da(...)  {cout<<#__VA_ARGS__;D()GET_MACRO(""##__VA_ARGS__,UNUSED,Darr2,Darr1,Dset)(__VA_ARGS__)D()}
#endif // ONLINE_JUDGE

// template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
#define pow2(X) (1<<(X))
#define gcd __gcd
#define lcm(a,b) ((a)/gcd(a,b)*(b))
ll mod=1e9+7;
inline ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x3f3f3f3f;//0x3f
const int NINF=0xcfcfcfcf;//0xcf
const int maxn=1e5+10;
int N,t,K,H,W,p,y,v;
int x[maxn];


int main(){

	cin>>N>>K;
	rep(i,N) in(x[i]);

	int ans=INF;
	rep(i,N-K +1){
		ans=min({ans,
			abs(x[i])+x[i+K-1]-x[i],
			abs(x[i+K-1])+x[i+K-1]-x[i]
		});
	}
	printf("%d",ans);
	
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	sum := 0.0
	for i := 0; i < N; i++ {
		var num float64
		fmt.Scan(&num)
		sum += 1 / num
	}

	fmt.Println(1.0 / sum)
}


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

int main(void)
{
	int n, tmp;
	
	while (scanf("%d", &n), n){
		vector <int> t, h;
		for (int i = 0; i < n; i++){
			scanf("%d", &tmp);
			t.push_back(tmp);
		}
		sort(t.begin(), t.end());
		int a = 0;
		for (int i = 1; i <= (2 * n); i++){
			if (i == t[a]) a++;
			else h.push_back(i);
		}
		sort(h.begin(), h.end());
		
		int b = t[0], tc = 1, hc = 0;
		bool pass = false;
		t[0] = 0;
		while (1){
			pass = false;
			for (int i = 0; i < n; i++){
				if (b < h[i]){
					b = h[i];
					hc++;
					h[i] = 0;
					pass = true;
					break;
				}
			}
			if (hc == n) break;
			if (!pass) {
				b = 0;
			}
			pass = false;
			for (int i = 0; i < n; i++){
				if (b < t[i]){
					b = t[i];
					tc++;
					t[i] = 0;
					pass = true;
					break;
				}
			}
			if (tc == n) break;
			if (!pass) {
				b = 0;
			}
		}
		int sumt = 0, sumh = 0;
		
		for (int i = 0; i < n; i++){
			if (h[i] != 0){
				sumt++;
			}
			if (t[i] != 0){
				sumh++;
			}
		}
		
		printf("%d\n%d\n", sumt, sumh);
	}
	
	return 0;
}

Measured memory_bytes: 0
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize
    }
    let ans = if k % 2 == 1 {
        (n / k).pow(3)
    } else {
        let x = n / k;
        let y = (n + (k / 2)) / k;
        x.pow(3) + y.pow(3)
    };
    println!("{}", ans);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 10 ;
int p[maxn], a[maxn], b[maxn], pos[maxn] ;
int main() {
	int n ;
	scanf("%d", &n) ;
	for (int i = 1; i <= n; i ++) {
		scanf("%d", &p[i]) ;
		pos[p[i]] = i ;
	}
	a[1] = 1 ;
	for (int i = 2; i <= n; i ++) {
		if (pos[i] > pos[i - 1]) a[i] = a[i - 1] + pos[i] - pos[i - 1] + 1 ;
		else a[i] = a[i - 1] + 1 ;
	}
	b[n] = 1 ;
	for (int i = n - 1; i >= 1; i --) {
		if (pos[i] > pos[i + 1]) b[i] = b[i + 1] + pos[i] - pos[i + 1] + 1 ;
		else b[i] = b[i + 1] + 1 ;
	}
	for (int i = 1; i <= n; i ++) printf("%d ", a[i]) ;
	puts("") ;
	for (int i = 1; i <= n; i ++) printf("%d ", b[i]) ;
	puts("") ;
	return 0 ;
}

Measured memory_bytes: 4128
#include<bits/stdc++.h>
#define endl "\n"
#define PI acos(-1)
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const n = 50005;

int main()
{
    BMW_GTR;

    string s;
    cin >> s;

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

    cout << s;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  vector<int> dis(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 1; i < N; i++) {
    dis[i-1] = A[i] - A[i - 1];
  }
  dis[N - 1] = K - A[N - 1] + A[0];
  int sum = accumulate(dis.begin(), dis.end(), 0);
  vector<int>::iterator iter = max_element(dis.begin(), dis.end());
  size_t index = distance(dis.begin(), iter);
  cout << sum - dis[index] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,k,u[N],v[N];
vector<int> g[N];
int dfs(int x, int f, int d) {
	int ans = d<0;
	for (int y:g[x]) if (y!=f) ans += dfs(y,x,d-1);
	return ans;
}
int main() {
	scanf("%d%d", &n, &k);
	REP(i,2,n) {
		scanf("%d%d",u+i,v+i);
		g[u[i]].pb(v[i]);
		g[v[i]].pb(u[i]);
	}
	int ans = n;
	if (k&1) {
		REP(i,2,n) ans=min(ans,dfs(u[i],v[i],k/2)+dfs(v[i],u[i],k/2));
	}
	else {
		REP(i,1,n) ans=min(ans,dfs(i,0,k/2));
	}
	printf("%d\n", ans);
}









Measured memory_bytes: 27008
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define sz(x) x.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
template <class T> inline T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}
template <class T> inline T lcm(T a, T b) {return a / gcd(a,b) * b;}

signed main()
{
//	freopen("THREEPRIMES.inp", "r", stdin); freopen("THREEPRIMES.out", "w", stdout);
	fastio();

	int n; cin >> n;
	vi a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(all(a)), sort(all(b));
    if (n % 2 == 0) {
        cout << (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1;
    }
    else {
        cout << b[n / 2] - a[n / 2] + 1;
    }
}


Measured memory_bytes: 4768
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 100002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, A[CMax], B[CMax], C[CMax], res;

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

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> A[i];
        if (i == 0) B[i] = A[i];
        else B[i] = gcd(B[i-1], A[i]);
    }

    for (int i = n-1; i >= 0; i--) {
        if (i == n-1) C[i] = A[i];
        else C[i] = gcd(C[i+1], A[i]);
    }


    int tRes;
    for (int i = 0; i < n; i++) {
        if (i == 0) tRes = C[i+1];
        else if (i == n-1) tRes = B[i-1];
        else tRes = gcd(B[i-1], C[i+1]);
        res = max(res, tRes);
    }

    cout << res;

    cout << endl;

    return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, a, b, c = LI()
L = IR(n)


def recur(ai, bi, ci, i):
    if i == n:
        return abs(a - ai) + abs(b -bi) + abs(c - ci) - 30 if ai > 0 and bi > 0 and ci > 0 else INF
    l1 = recur(ai + L[i], bi, ci, i+1) + 10
    l2 = recur(ai, bi + L[i], ci, i+1) + 10
    l3 = recur(ai, bi, ci + L[i], i+1) + 10
    l4 = recur(ai, bi, ci, i+1)
    return min(l1, l2, l3, l4)



print(recur(0, 0, 0, 0))

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

int main()
{
	int n,a,test[1000010];
	cin>>n;
	for(int h=1; h<=n; h++)
	{
		cin>>a;
		test[a]=h;
	}
	for(int h=1; h<=n; h++)
		cout<<test[h]<<' ';
	cout<<endl;
}


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

int main() { 
  int A, B;
  cin >> A >> B;
  
  if (A <= 5)
    cout << 0 << endl;
  else if (A <= 12) 
    cout << B/2 << endl;
  else
    cout << B << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int row= in.nextInt();
		int col= in.nextInt();
		int n= in.nextInt();
		int [] a= new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i]= in.nextInt();
		}
		int [][] g= new int[row][col];
		int y= 0;
		int x=0;
		boolean rev= false;
		for (int i = 0; i < a.length; i++) {
			int color= (i+1);
			int num= a[i];
			while(num-->0){
				g[y][x]= color;
				if(rev){
					y--;
				}
				else{
					y++;
				}
				if(y==row){
					x++;
					rev= !rev;
					y--;
				}
				if(y==-1){
					x++;
					y++;
					rev= !rev;
				}
			}
		}
		for (int i = 0; i < row; i++) {
			for (int j = 0; j < col; j++) {
				System.out.print(g[i][j]+" ");
			}
			System.out.println();
		}
		
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

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

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



Measured memory_bytes: 25556
#include <iostream>
#include<algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include<map>
#include<set>
#include<stack>
#include<sstream>
#define endl '\n'
#define debug(x) cout<<"This is "<<x<<'\n'
#define INF 0x3f3f3f3f
#define DOF 0x7f7f7f7f
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int maxn=2e6+10;
ll a[maxn],k=0;
void dfs(ll i){
    if(i>1e10)
        return ;
    a[k]=i;
    ++k;
    for(int j=0;j<=9;++j){
        if(abs(i%10-j)<=1)
            dfs(i*10+j);
    }

}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=9;++i) dfs(i);
    sort(a,a+k);
//    nth_element(a,a+n-1,a+k+1);
    cout<<a[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	int i;
	for(i=0;i<s.length();i++)
	{
		if(i&1)
		{
			if(s[i]=='L'||s[i]=='U'||s[i]=='D')
				continue;
			else
			{
				cout<<"No\n";
				return 0;
			}
		}
		else
		{
			if(s[i]=='R'||s[i]=='U'||s[i]=='D')
				continue;
			else
			{
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes\n";
}

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

dp=[0]*n
if p_input[0]==1:
    dp[0]=1
for i in range(1,n):
    if p_input[i]==i+1:
        dp[i]=dp[i-1]+1
        dp[i-1]=0
ans=0
for i in range(n):
    if dp[i]%2==0:
        ans+=dp[i]//2
    else:
        ans+=dp[i]//2+1
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[32];
int main(){
	scanf("%s", s);
	s[3] = '\0';
	printf("%s\n", s);
}


Measured memory_bytes: 3688
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

VI a;
int N;
int main(){
    cin>>N; 
    REP(i,N){
        // int aa;
        // int bb;
        // cin>>aa
        int aa;
        cin>>aa;
        a.push_back(aa);
    }
   SORT(a);
   int first=a[0];
   long sum=0;
   for(int i=1;i<N;i++){
        sum+=a[i]-first;
        first=a[i];
   }

   cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double dp[3005][3005];
signed main() {
    int N;
    cin >> N;
    vector<double>p(N);
    for(int i = 0; i < N; i++) {
        cin >> p[i];
    }
    dp[0][0] = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= i; j++) {
            if(dp[i][j]) {
                dp[i+1][j+1] += dp[i][j]*p[i];
                dp[i+1][j] += dp[i][j]*(1-p[i]);
            }
        }
    }
    double ans = 0;
    for(int i = N/2+1; i <= N; i++) {
        ans+=dp[N][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 44216
#include<cstdio>
#include<cstring>
#include<set>
#include<iostream>
using namespace std;


set<int> *p;
set<int> l;
int *m,k;

set<int>::iterator it,its;

int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		m=new int[n];
		p=new set<int>[n];
		for(int i=0;i<n;i++){
			cin>>m[i];
			int q;
			for(int j=0;j<m[i];j++){
				cin>>q;
				p[i].insert(q);
			}
		}
		cin>>k;
		int q;
		for(int j=0;j<k;j++){
			cin>>q;
			l.insert(q);
		}
		int cnt=0;
		for(int i=0;i<n;i++){
			its=p[i].begin();
			for(it=l.begin();it!=l.end();it++){
				for(;its!=p[i].end();its++){
					if((*it)<=(*its)) break;
				}
				if((*it)!=(*its)) break;
			}
			if(it==l.end()){
				if(cnt){
					cnt=-1;
					break;
				}
				cnt=i+1;
			}
		}
		if(!cnt) cnt=-1;
		cout<<cnt<<endl;
		delete []p;
		delete []m;
		l.clear();
	}
	return 0;
}

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

int main(int argc, char *argv[])
{
  string n;
  
  cin >> n;

  for (int i = 0; i < n.size(); i++) {
    if (n[i]=='0'&&n[i+1]=='U') {
      cout << "nn";
      i++;;
    }
    else {
      switch (n[i]) {
      case '0': cout << 'w'; break;
      case '1': break;
      case '2': cout << 'k'; break;
      case '3': cout << 's'; break;
      case '4': cout << 't'; break;
      case '5': cout << 'n'; break;
      case '6': cout << 'h'; break;
      case '7': cout << 'm'; break;
      case '8': cout << 'y'; break;
      case '9': cout << 'r'; break;
      }
      i++;
      switch (n[i]) {
      case 'T': cout << 'a'; break;
      case 'L': cout << 'i'; break;
      case 'U': cout << 'u'; break;
      case 'R': cout << 'e'; break;
      case 'D': cout << 'o'; break;
      }
    }
  }
  cout << endl;
    
  return 0;
}



Measured memory_bytes: 3244
s = input()
n = len(s)
ans = 0
for bit in range(2**(n-1)):
    f = s[0]
    for i in range(n-1):
        if ((bit >> i) & 1):
            f += "+"
        f += s[i+1]
    ans += sum(list(map(int,f.split("+"))))
print(ans)

Measured memory_bytes: 3060
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const long long Maxn=1e5;
typedef long long ll;

int a[105];

int main(){
	int n,m,x,y;
	scanf("%d %d %d",&n,&m,&x);
	for(int i=1;i<=m;i++){
		scanf("%d",&y);
		a[y]=1;
	}
	int sum=0,sud=0;
	for(int i=0;i<=x;i++) sum+=a[i];
	for(int i=x;i<=n;i++) sud+=a[i];
	sum=min(sum,sud);
	printf("%d\n",sum);
	}

Measured memory_bytes: 256
import java.util.*;

import java.math.*; 
public class Main {
     Scanner sc = new Scanner(System.in);
	
	
	void run(){ // kokonikaku
	 long n=sc.nextLong();
		
		 long a[] = new long[5];
		for(int i=0;i<5;i++){
			a[i]=sc.nextLong();
		}
		
		
		int it=-1;
		long mi=100000000000000000L;
		for(int i=0;i<5;i++){
			if(mi>a[i]){
				mi=a[i];
				it=i;
			}
		}
		
		long ans=n;
		
		ans/=mi;
		if(n%mi>0)ans++;
		ans--;
		
			System.out.println(ans+5);
		
		
		
    
	}

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

Measured memory_bytes: 22740
#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>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int X, N;
    cin >> X >> N;
    set<int> ps;
    for (int i=0; i<N; ++i) {
        int t;
        cin >> t;
        ps.insert(t);
    }

    P res = make_pair(INT_MAX, INT_MAX);
    
    for (int i=0; i<=101; ++i) {
        if (ps.count(i)) continue;
        if (make_pair(abs(i - X), i) < res) {
            res = make_pair(abs(i - X), i);
        }
    }
    cout << res.second << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <algorithm>

int nya(std::vector<int> const& a) {
  int t = 0;
  for (auto ai: a) {
    t = (t + 9) / 10 * 10;
    t += ai;
  }
  return t;
}

int main() {
  std::vector<int> a(5);
  for (auto& ai: a) scanf("%d", &ai);

  std::sort(a.begin(), a.end());
  int res = 1e9;
  do {
    res = std::min(res, nya(a));
  } while (std::next_permutation(a.begin(), a.end()));

  printf("%d\n", res);
}


Measured memory_bytes: 256
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include <bits/stdc++.h>

using namespace std;

void solve()
{
    long long k, r = 0;
    cin >> k;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); ++i)
        if (s[i] == 'R')
            ++r;
    long long ans = 0;
    for (int i = 0; i < s.length() && r > 0; ++i)
    {
        if (s[i] == 'W')
            ++ans;
        --r;
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3760
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int h,w;
    while(cin>>h>>w && h){
        vector<vector<int>> v(h,vector<int>(w));
        rep(i,0,h)rep(j,0,w)cin>>v[i][j];
        int ans=0;
        for(int i=0;i<(1<<h);i++){
            //cout<<"i"<<i<<endl;
            int s=0;
            for(int p=0;p<w;p++){
                int sum=0;
                for(int q=0;q<h;q++){
                    //cout<<"pq"<<p<<" "<<q<<endl;
                    //cout<<(i>>q &1)<<" ";
                    if(i>>q & 1){
                        if(v[q][p]==1){sum++;}
                    
                    }
                    else {
                        if(v[q][p]==0){sum++;}
                        
                    }
                }
               // cout<<" sum: "<<sum<<endl;
                if(sum==0)s+=h;
                else if(sum*2>=h)s+=sum;
                else s+=(h-sum);
            }
            //  cout<<s<<endl;
            //  cout<<endl;
            ans=max(ans,s);
        }
        cout<<ans<<endl;
    }
    
}


/*
14
1 0
1 1
1 2
2 1
0 0
0 1
0 2
0 3
3 3
4
5
6
7
8
*/



Measured memory_bytes: 3296