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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		while (n != 0) {
			double sum = 0;
			List<Integer> vals = new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				vals.add(a);
				sum += a;
			}
			double ave = sum/n;
			sum = 0;
			for (int i = 0; i < n; i++) {
				sum += (vals.get(i) - ave)*(vals.get(i) - ave);
			}
			double a = sum/n;
			a = Math.sqrt(a);
			System.out.println(String.format("%.5f", a));
			n = sc.nextInt();
		}
	}
}



Measured memory_bytes: 31760
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

n = readInt()
a = readIntN()

ret = 0
for v in a:
    while (v % 2) == 0:
        ret += 1
        v /= 2
print(ret)

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

using namespace std;

typedef long long ll;
typedef long double ld;

int n;
int arr[100];
int dp[100005];
set<int> moves;

int mex(set<int> sett)
{
  for(int i = 0;;i++)
    if(sett.find(i) == sett.end())
      return i;
}

int solve(int have)
{
  int &ans = dp[have];
  if(ans != -1)
    return ans;
  set<int> moves;
  for(int i = 0; i < n; i++)
    if(have - arr[i] >= 0)
      moves.insert(solve(have - arr[i]));
  return ans = mex(moves);
}

int main()
{
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int k;
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  memset(dp, -1, sizeof(dp));
  int a = solve(k);
  if(a == 0)
    cout << "Second";
  else
    cout << "First";
  return 0;
}


Measured memory_bytes: 19456
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	bool exist[52] = {false};
	for (int i = 0; i < n; ++i)
	{
		char c;
		int num;
		cin >> c >> num;
		--num;
		if (c == 'S')
		{
			exist[num] = true;
		}
		else if (c == 'H')
		{
			exist[13 + num] = true;
		}
		else if (c == 'C')
		{
			exist[26 + num] = true;
		}
		else if (c == 'D')
		{
			exist[39 + num] = true;
		}
	}
	for (int i = 0; i < 52; ++i)
	{
		if (exist[i] == false)
		{
			if (i / 13 == 0)
			{
				cout << "S " << i + 1 << endl;
			}
			else if (i / 13 == 1)
			{
				cout << "H " << i % 13 + 1 << endl;
			}
			else if (i / 13 == 2)
			{
				cout << "C " << i % 13 + 1 << endl;
			}
			else if (i / 13 == 3)
			{
				cout << "D " << i % 13 + 1 << endl;
			}
		}
	}
}

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

Measured memory_bytes: 1160
#!/usr/bin/env python
# -*- coding: utf-8 -*-

_MIN = -1000000
_MAX = 1000000

K, X = map(int, input().split())


candidate_min = max(X - K + 1, _MIN)
candidate_max = min(X + K - 1, _MAX)

print(" ".join(map(str, range(candidate_min, candidate_max + 1))))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int n,m;
    cin >> n >> m;
    cout << (n-1) * (m-1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define pi pair<int,int>
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define VEC() vector<ll int>v
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
   ll int n,a,b;
   cin>>n>>a>>b;
   if(a*b>=n)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 3616
N, A, B = map(int, input().split())
ans = 0

for i in range(0, N+1, 10):
    for j in range(10):
        temp = str(i + j)
        if (int(temp) > N):
            break

        sum = 0
        for k in range(len(temp)):
            sum += int(temp[k])
        if (A <= sum) and (sum <= B):
            ans += int(temp)
        elif (B < sum):
            break

print(ans)


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

 using namespace std;
 int main() {
   string S;
   cin >> S;
   if (S.at(5) == '1') cout << "TBD" << endl;
   else if (S.at(6) - '0' >= 5) cout << "TBD" << endl;
   else cout << "Heisei" << endl;
 }


Measured memory_bytes: 256
/**
 *   author: Shubham Srivastava
 *   created: 18 August 2019  17:41:20
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;cin>>n;
    vector <int> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr.begin(),arr.end());
    double val = (arr[0] + arr[1])/2.0;
    double sum = val;
    for(int i=2;i<n;i++){
        sum = (val + arr[i])/2;
        val = sum;
    }
    cout<<sum;
return 0;
}

Measured memory_bytes: 256
program sum_of_divisors
  implicit none
  integer :: n, i
  integer(8) :: x = 0, y
  read(*,*) n
  do i = 1, n
    y = n / i
    x = x + y * (y + 1) / 2 * i
  end do
  write(*,'(i0)') x
end program sum_of_divisors

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

public class Main {
  private static boolean solve(int n, int m, int[][] abs) {
    int[] counts = new int[n + 1];
    for (int[] ab : abs) {
      int a = ab[0];
      int b = ab[1];
      counts[a]++;
      counts[b]++;
    }
    
    for (int count : counts) {
      if (count % 2 == 1) {
        return false;
      }
    }
    return true;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int m = reader.nextInt();
    int[][] abs = reader.nextInt(m, 2);
    out.println(solve(n, m, abs) ? "YES" : "NO");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 46156
#include <iostream>
#include <vector>
using namespace std;
#define ff(i,s,n) for(int i=s;i<n;i++)
#define fr(i,s,n) for(int i=n-1;i>=s;i--)
#define llu long long int


int main() {
	int n;
	cin>>n;
	vector<int> v(n);
	ff(i,0,n){
		cin>>v[i];
	}
	
	llu max=v[0],stool=0;
	
	ff(i,1,n){
		if(v[i]>max){
			max=v[i];
			continue;
		}
		stool+=max-v[i];
	}
	cout<<stool;
}

//1
//7 2
//3 5 4 5 1 1 1


Measured memory_bytes: 3576
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let n: usize;
    input!(n);
    let mut v: Vec<usize> = Vec::new();
    for _ in 0..n {
        let buf:usize;
        input!(buf);
        v.push(buf - 1);
    }
    println!("{}", search(&v, 0, 1));
}

fn search(v: &Vec<usize>, next: usize, count: usize) -> isize {
    if count > v.len() {
        return -1;
    }
    if v[next] == 1 {
        return count as isize;
    }
    search(v, v[next], count + 1)
}

Measured memory_bytes: 4352
n, m = map(int, input().split())
ac = 0
wa = 0
cnt = [0]*n

for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    elif s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
print(ac, wa)

Measured memory_bytes: 3828
N = int(input())
S = input()

cnt = 0
for i in range(1000):
    c = list(str(i).zfill(3).strip())
    f = 0
    for j in range(N):
        if S[j] == c[f]:
            f += 1
        if f == 3:
            break
    if f == 3:
        cnt += 1
        
print(cnt)        

Measured memory_bytes: 41308
package main

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

var graph [2*1e5 + 1][]int

func main() {
	var N, Q int
	N, Q = ReadInt(), ReadInt()
	ans := make([]int, N+1)

	for i := 1; i < N; i++ {
		var a, b int
		a, b = ReadInt(), ReadInt()
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	for q := 0; q < Q; q++ {
		var p, x int
		p, x = ReadInt(), ReadInt()
		ans[p] += x
	}

	dfs(1, -1, ans)
	for i := 1; i <= N; i++ {
		fmt.Printf("%d ", ans[i])
	}
}

func dfs(v int, p int, ans []int) {
	for _, t := range graph[v] {
		if t == p {
			continue
		}
		ans[t] += ans[v]
		dfs(t, v, ans)
	}
}

func Println(xs ...int) {
	vs := make([]interface{}, len(xs))
	for i := 0; i < len(xs); i++ {
		vs[i] = xs[i]
	}
	fmt.Println(vs...)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}

// func ReadInt() (i int) { Scan(&i); return }
//
// func ReadInts(n int) []int {
// 	xs := make([]int, n)
// 	for i := 0; i < n; i++ {
// 		Scan(&xs[i])
// 	}
// 	return xs
// }
//
// func ReadLine() string {
// 	var s string
// 	for {
// 		l, isPrefix, err := reader.ReadLine()
// 		if err != nil {
// 			panic(err)
// 		}
// 		s += string(l)
// 		if !isPrefix {
// 			return s
// 		}
// 	}
// }
//

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
	char b;
	cin >> b;

	if (b == 'A')
		cout << "T" << endl;
	else if (b == 'C')
		cout << "G" << endl;
	else if (b == 'G')
		cout << "C" << endl;
	else if (b == 'T')
		cout << "A" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; string s; cin >> n >> s;
    ll res = 0;
    for(ll i=1;i<n;i++){
        if(s[i] == 'E') res++;
    }
    ll mn = res;
    for(ll i=1;i<n;i++){
        if(s[i] == 'E') --mn;
        if(s[i-1] == 'W') ++mn;
        res = min(res, mn);
    }
    cout << res;
    cout << endl;
    return 0;
}



Measured memory_bytes: 720
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		  try(Scanner sc = new Scanner(System.in)) {
			  while(sc.hasNext()) {
				  String line=sc.nextLine();
				  String[] tokens=line.split("[,. ]");
				  int count=0;
				  for(String t:tokens) {
					  if(t.length()>=3 && t.length()<=6) {
						  if(count>0)System.out.print(" ");
						  System.out.printf("%s", t);
						  count++;
					  }
				  }
				  System.out.printf("\n");
			  }
		}
	}
}



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

using namespace std;

int n, k;

int main()
{
    cin >> n >> k;

    int mn = n + 1, pn;
    int i;
    for(i = 1; i <= n; i ++)
    {
        int nr;
        cin >> nr;
        if(nr < mn)
        {
            mn = nr;
            pn = i;
        }
    }

    int rez = n + 2;
    for(i = 1; i + k - 1 <= n; i ++)
    {
        if(i <= pn && i + k - 1 >= pn)
        {
            int cr = 1;
            int st = i;
            while(st > 1)
            {
                cr ++;
                st -= (k - 1);
            }

            st = i + k - 1;
            while(st < n)
            {
                cr ++;
                st += (k - 1);
            }

            rez = min(rez, cr);
        }
    }

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 256
/*
	author : SAMRAT DE
	username : Alucard_01
	NIT Durgapur
*/

/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>*/
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define pi(x,y) pair<x,y>
#define mpp(x,y) map<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pf push_front
#define indexof order_of_key
#define valueat find_by_order
#define myds tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

using namespace std;
//using namespace __gnu_pbds;

int32_t main()
{
	fastio;
	//best of luck don't loose hope man	
		
	ll n;
	cin>>n;
	--n;
	ll ans;
	if(n%2==0){
		ans=n/2;
		ans*=(n+1);
	}
	else{
		ans=(n+1)/2;
		ans*=n;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
 
int main() {
    int n,k,c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> l(n+1),r(n+1);
    int prev=-(n+1),cnt=0;
    rep(i,n) {
        if (i-prev>c && s[i]=='o') {
            l[++cnt]=i;
            prev=i;
        }
    }
    prev=n+n+1,cnt=k+1;
    invrep(i,n) {
        if (prev-i>c && s[i]=='o') {
            if (cnt>1) r[--cnt]=i;
            prev=i;
        }
    }
    repr(i,1,k+1) {
        if (l[i]==r[i]) cout << l[i]+1 << endl;
    } 

}

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

int main (){
    int n,a,b,c,d;
    int cost_a, cost_c;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);

    if(n%a == 0){
        cost_a = n/a * b;
    }else{
        cost_a = (n/a+1) * b;
    }

    if(n%c == 0){
        cost_c = n/c * d;
    } else {
        cost_c = (n/c+1) * d;
    }

    printf("%d\n", min(cost_a,cost_c));
    return 0;
}


Measured memory_bytes: 2740
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin =new Scanner(System.in);
        String weather []={"Sunny","Cloudy", "Rainy"} ;
       // Vector v=new Vector();
        //String []w=new String [3];
        String today=cin.next();
        for(int i=0;i<2;i++){
            if(today.equals(weather[i])){
                System.out.println(weather[i+1]);
            }
        }
        if(weather[2].equals(today))
            System.out.println("Sunny");
        cin.close();
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt(),c=nxt();
    if(c>=a&&c<=b)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  long v;
  long sum=0;
  for(int i=0;i<n;i++){
    scanf("%ld",&v);
    sum+=v;
  }
  printf("%ld\n",sum/n);
  return 0;
}



Measured memory_bytes: 1992
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<numeric>
#include<sstream>
#include<cmath>
using namespace std;
long long int mod = 1e9;

int main(){
  int n; cin >> n;
  int ans = 0;
  vector<int> v(n);
  vector<int> c(n);
  for(int i=0; i<n; i++) cin >> v[i];
  for(int i=0; i<n; i++) cin >> c[i];
  for(int i=0; i<n; i++) {
    ans += max(0, v[i]-c[i]);
  }
  cout << ans << endl;

  return 0;
}




// EOF


Measured memory_bytes: 256
import scala.io.StdIn._
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val s = sc.next
  var ans =0
  for(i <- 0 to 3){
    if(s.charAt(i)=='+'){
     ans+=1
    }
    else{
      ans-=1
    }
  }
  println(ans)
}

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

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

const int N = 3002;
const ll INF = 1000000000000;

string a, b, ans;
int dp[N][N];

int go(int pa, int pb){
  if(pa == -1 || pb == -1) return 0;
  if(dp[pa][pb] != -1) return dp[pa][pb];
  if(a[pa] == b[pb]) return dp[pa][pb] = 1 + go(pa - 1, pb - 1);
  return dp[pa][pb] = max(go(pa - 1, pb), go(pa, pb - 1));
}

void get(int pa, int pb){ //cout << pa << " " << pb << " " << dp[pa][pb] << endl;
  if(pa == -1 || pb == -1) return;
  else if(a[pa] == b[pb]){
    ans += a[pa];
    get(pa - 1, pb - 1);
    return;
  }
  else if(pa == 0 and pb == 0) return;
  else if(pa == 0) get(pa, pb - 1);
  else if(pb == 0) get(pa - 1, pb);
  else if(dp[pa - 1][pb] >= dp[pa][pb - 1]) get(pa - 1, pb);
  else get(pa, pb - 1);
}

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

  cin >> a >> b;
  memset(dp, -1, sizeof dp);
  go(a.size() - 1, b.size() - 1);
  get(a.size() - 1, b.size() - 1);
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


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

const int MAX = 200010;
const unsigned long long INF = 1ULL << 63;

int main() {
	unsigned long long N, X;
	unsigned long long x[MAX];
	unsigned long long sum[MAX] = { 0 };
	unsigned long long ans = INF;

	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		sum[i + 1] = x[i] + sum[i];
	}

	for (int i = 1; i <= N; i++) {
		int pos = N - i;
		unsigned long long s = (sum[pos + i] - sum[pos]) * 5;
		unsigned long long c = 5;

		while (pos >= i) {
			s += (sum[pos] - sum[pos - i]) * c;
			c += 2;
			pos -= i;
		}

		if (pos != 0)s += sum[pos] * c;
		s += X * i + X * N;

		ans = min(ans, s);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"



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


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




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

#define ll long long int
#define ld long double
#define u128 __int128 
#define ff first
#define ss second
#define pb push_back
#define PI 3.141592653589793

#define MOD 1000000007
#define N 100100
#define M 1000010

int n, m;
int a[N];

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, c - a + b); 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n), y(n);
    vector<int> xary, yary; 
    rep(i, n) {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());

    ll ans = (ll)(xary[n-1] - xary[0])*(yary[n-1] - yary[0]);  //最大の長方形で初期化
    rep(xi, n) {  //長方形の左辺のx座標の添え字
        for(int xj = xi + 1; xj < n; xj++) {  //長方形の右辺のx座標の添え字
            rep(yi, n) {  //長方形の下辺のy座標の添え字
                for(int yj = yi + 1; yj < n; yj++) {  //長方形の上辺のy座標の添え字

                    int num = 0;  //長方形に含まれる点の個数
                    ll lx = xary[xi];  //長方形の左辺のx座標
                    ll rx = xary[xj];  //長方形の右辺のx座標
                    ll by = yary[yi];  //長方形の下辺のx座標
                    ll uy = yary[yj];  //長方形の上辺のx座標

                    rep(i, n) {
                        //長方形に(x[i], y[i])が含まれていたらnumを1増やす
                        if(lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy) {
                            num++;
                        }
                    }

                    //長方形にk点以上含まれていたら
                    if(k <= num) {
                        //ansに長方形の最小の面積が入る
                        ans = min(ans, (ll)(rx - lx)*(uy - by));
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

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

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

int main(void)
{
    int n;
    cin >> n;
    
    v_int a(n);
    cin >> a;

    int ans = 0;
    irep(i, n) {
        if(i%2 == 0&&a[i]%2!=0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
/*atcoder*/


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
//static const int INF = (1 << 21);

vector<bool> visited(8);
vector<vector<bool>> perm(8, vector<bool>(8));
int N;
int dfs(int x, int N){
    bool all_visited = true;
    for(int i = 0; i < N; i++){
        if(visited.at(i) == false){
            all_visited = false;
        }
    }
    if(all_visited){
        return 1;
    }
    
    int ret = 0;
    
    for(int i = 0; i < N; i++){
        if(perm.at(x).at(i) == false) continue;
        if(visited.at(i)) continue;
        
        visited.at(i) = true;
        ret += dfs(i, N);
        visited.at(i) = false;
    }
    
    return ret;
}

int main(void){
    // Your code here!
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int x,y;
        cin >> x >> y;
        perm.at(x-1).at(y-1) = 1;
        perm.at(y-1).at(x-1) = 1;
    }
    
    visited.at(0) = true;
    cout << dfs(0, N) << endl;
}


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

bool IsPrime(int x) {
  if (x < 2) return false;
  if (x == 2) return true;
  if (x % 2 == 0) return false;

  for (int i = 2; i < x-1; i++) {
    if (x % i == 0) {
      return false;
    }
  }

  return true;
}

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

  while(!IsPrime(X)) {
    X++;
  }

  cout << X << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  ll a = 0;
  for (ll i = 1; ; i++) {
    a += n;
    if (a%360 == 0) {
      cout << i << '\n';
      return 0;
    }
  }
}

Measured memory_bytes: 3648
n,a,b = map(int,input().split())
mod = 10**9+7

def comb(N,x):
  numerator = 1
  for i in range(N-x+1,N+1):
    numerator = numerator *i%mod
  denominator = 1
  for j in range(1,x+1):
    denominator = denominator *j%mod
  d = pow(denominator,mod-2,mod)
  return (numerator*d)%mod
al = pow(2,n,mod)-1
ac =comb(n,a)
bc =comb(n,b)
print((al-ac-bc)%mod)

Measured memory_bytes: 3064
a, b, c, x = [int(input()) for _ in range(4)]
ans = 0

aa = 0
while aa<=a:
  bb = 0
  while bb<=b:
    cc = 0
    while cc<=c:
      if aa * 500 + bb * 100 + cc * 50 == x:
        ans += 1
      cc += 1
    bb += 1
  aa += 1

print(ans)

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

typedef long long ll;

ll n;
vector<ll> v(5);

int main(){
    cin >> n;

    for (int i = 0; i < 5; i++ ){
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    if (n % v[0] != 0){
        cout << (ll)(n / v[0]) + 5LL<< endl;
    } else {
        cout << (ll)(n/v[0]) + 4LL << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int a[101];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  int minx = 100000000;
  int minsum = 100000000;
  for (int i = 1; i < 100; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (a[j]-i) * (a[j] - i);
    }
    if (sum < minsum) {
      minsum = sum;
      minx = i;
    }
  }
  printf("%d", minsum);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
  long long x;
  long long k;
  long long dist;
  cin>>x>>k>>dist;
  x=llabs(x);
  
  if(x/dist>=k){
    cout<<x-dist*k<<endl;
    return(0);
  }

  k-=x/dist;
  x%=dist;
  k%=2;
  if(k==1){
    x=llabs(x-dist);
  }
  cout<<x<<endl;
  return(0);
}

Measured memory_bytes: 3632
y,m,z,e;main(k){
	for(;m=1e7,scanf("%d",&e),e;){
		for(z=0;(k=z*z*z)<=e;z++){
			y=sqrt(e-k);
			k=y+z+e-y*y-k;
			if(m>k)m=k;
		}
		printf("%d\n",m);
	}
	return 0;
}

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

using namespace std;
int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  double n, m, d;
  cin >> n >> m >> d;

  double ans = (n * 2 - d * 2) / (n * n) * (m - 1);

  if (d == 0) {
    ans /= 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from math import gcd
from functools import reduce

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

n=int(input())
ap=list(map(int,input().split()))
amin=min(ap)
amax=max(ap)

if amax==1:
    print("pairwise coprime")
    sys.exit()

if reduce(gcd,ap)!=1:
    print("not coprime")
    sys.exit()
    
if n>=78500 :
    print("setwise coprime")
    sys.exit()

aa=[0]*(amax+1)
for ai in ap:
    aa[ai]+=1
    
for pp in range(2,amax+1):
    psum=sum(aa[pp: :pp])
#    print("pp:",pp,psum)
    if psum>=2:
            print("setwise coprime")
            sys.exit()
## max_13.txt ... max_16.txt : "setwise coprime"
print("pairwise coprime")
   


Measured memory_bytes: 186944
#include<iostream>
using namespace std;
int main(){
    int h,w,i,j;
    for(;;){
    cin>>h>>w;
    if(h==0)exit(0);
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if((i+j)%2){cout<<".";}else{cout<<"#";}
        }
        cout<<endl;
    }
    cout<<endl;
}
return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    ll g[4];
    for(int i=0;i<4;i++){
        cin >> g[i];
        g[i]--;
    }
    string s[h];    
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    vector<vector<ll> > dis(h, vector<ll> (w, INF));
    multiset<pair<ll, pair<ll, ll> > > q;
    q.insert({0LL, {g[0], g[1]}});
    ll dy[4] = {0, 0, -1, 1};
    ll dx[4] = {-1, 1, 0, 0};
    while(!q.empty()){
        auto itr = q.begin();

        ll y = itr->second.first;
        ll x = itr->second.second;
        ll d = itr->first;
        q.erase(itr);
        if(d > dis[y][x]) continue;
        for(int k=0;k<4;k++){
            ll nowy = y + dy[k];
            ll nowx = x + dx[k];
            if(nowy < 0 || nowy >= h || nowx < 0 || nowx >= w || s[nowy][nowx] == '#') continue;
            if(dis[nowy][nowx] > d){
                dis[nowy][nowx] = d;
                q.insert({d, {nowy, nowx}});
            } 
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                ll nowy = y + i;
                ll nowx = x + j;
                if(nowy < 0 || nowy >= h || nowx < 0 || nowx >= w || s[nowy][nowx] == '#') continue;
                if(dis[nowy][nowx] > d + 1){
                    dis[nowy][nowx] = d + 1;
                    q.insert({d + 1, {nowy, nowx}});
                }
            }
        }
    }
    ll ans = dis[g[2]][g[3]];
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int n, t;
V<P> food;
int memo[3030][3030];

int dp(int i, int j) {
	if (i < 0 || j < 0)return -INF;
	if (memo[i][j])return memo[i][j];
	if (i == 0 || j == 0)return 0;
	int res;
	res = max(dp(i - 1, j), dp(i - 1, j - food[i - 1].first) + food[i - 1].second);
	memo[i][j] = res;
	return res;
}

int main() {
	
	cin >> n >> t;
	food.resize(n);
	rep(i, n)cin >> food[i].first >> food[i].second;
	sort(all(food));
	int ans = 0;
	rep(i, n)ans = max(ans, dp(i, t - 1) + food[i].second);
	cout << ans << endl;

}

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

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

int main(void)
{
  int n, d[100];
  cin >> n;
  FOR(i, n) cin >> d[i];
  sort(d, d + n, greater<int>());

  int ans = 0;
  FOR(i, n)
  {
    if (i == n-1 || d[i] != d[i+1])
    {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
while 1:
    m = int(input())
    if m == 0:
        break

    result = []
    for _ in range(m):
        datas = list(map(int, input().split()))
        student = datas.pop(0)

        score = 0
        frame = 1
        while 1:
            if frame == 10:
                while datas != []:
                    score += datas.pop(0)
                break

            first = datas.pop(0)
            if first == 10:
                score += 10 + datas[0] + datas[1]
            else:
                second = datas.pop(0)
                if first + second == 10:
                    score += 10 + datas[0]
                else:
                    score += first + second
            frame += 1

        result.append([student, score])

    result.sort()
    result = sorted(result, reverse=True, key=lambda x: x[1])
    for res in result:
        print(res[0], res[1])



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

using namespace std;

const int N = 1e5 + 5;
vector< pair< int, int>> conn[N];
int a[N], b[N];
bitset< N> seen;
int out[N], direction[N]; // 0 == a -> b, 1 == b -> a

void dfs(int u, int prt) {
    seen[u] = true;

    int index = -1;
    for (const auto& p : conn[u]){
        if (p.first == prt) {
            index = p.second;
            continue;
        }
        if (seen[p.first]) continue;
        dfs(p.first, u);
    }

    if (out[u] & 1) {
        out[a[index]] --;
        out[b[index]] ++;
        direction[index] = 1;
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    if (m & 1) return !printf("-1");
    
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &a[i], &b[i]);
        conn[a[i]].emplace_back(b[i], i);
        conn[b[i]].emplace_back(a[i], i);
        out[a[i]] ++;
    }

    dfs(1, 1);
    for (int i = 0; i < m; ++i) {
        if (direction[i] == 0) printf("%d %d\n", a[i], b[i]);
        else printf("%d %d\n", b[i], a[i]);
    }
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s >> k;
    set<string> str;
    rep(i, 0, s.size()) {
        for (int j = i + 1; j <= s.size(), j <= i + k; ++j)  {
            string sub = s.substr(i, j - i);
            str.insert(sub);
        }
    }
    int cnt = 1;
    for (auto itr = str.begin(); itr != str.end(); ++itr) {
        if (cnt == k) {
            cout << *itr << endl;
            break;
        }
        cnt++;
    }
    return 0;
}


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

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

                int N = scan.nextInt();
                int K = scan.nextInt();

                int[] p = new int[N];

                for (int i = 0; i < N; i++) {
                	p[i] = scan.nextInt();
                }

                Arrays.sort(p);

                int output = 0;

                for ( int j = 0; j < K; j++) {
                	output += p[j];
                }

                System.out.println(output);

                scan.close();

        }

}

Measured memory_bytes: 38868
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static final int PIN_LENGTH = 3;
    static int n = 0;
    static char[] s = null;

    public static void main(String[] args) {
        n = sc.nextInt();
        s = sc.next().toCharArray();

        long ans = 0;
        for(int i = 0; i <= 999; ++i) {
            char[] digits = generatePinForm(i);
            if(canMakeArgPin(digits)) ++ans;
        }

        System.out.println(ans);        
    }

    static char[] generatePinForm(int num) {
        StringBuilder sb = new StringBuilder();
        String numStr = String.valueOf(num);
        int numOfZero = PIN_LENGTH - numStr.length();
        for(int i = 0; i < numOfZero; ++i) {
            sb.append(0);
        }
        sb.append(numStr);
        return sb.toString().toCharArray();
    }

    static boolean canMakeArgPin(char[] digits) {
        int digitsIndex = 0;
        for(int i = 0; i < n; ++i) {
            if(s[i] == digits[digitsIndex]) ++digitsIndex;
            if(digitsIndex == PIN_LENGTH) return true;
        }
        return false;
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const long long INF = 1e8;
using namespace std;

const int MAX_N = 200105;

//[1, n]
long long bit[MAX_N + 1] = {0};

long long sum(long long i){
	i++;
	long long s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(long long i, long long x){
	i++;
	while(i <= MAX_N){
		bit[i] += x;
		//bit[i] = max(bit[i], x);
		i += i & - i;
	}
}

int main(){
	long long n, k;
	cin >> n >> k;

	vector<long long> a(n);
	vector<pair<long long,int>> v(n), cp(n);
	long long cur = 0;
	rep(i,n){
		cin >> a[i];
		a[i] -= k;
		cur += a[i];
		v[i] = make_pair(cur,i);
	}
	cp = v;
	sort(all(v));

	long long q = 0;
	long long ans = 0;
	rep(i,n){
			//show(distance(v.begin(), lower_bound(all(v), make_pair(q, -1))))
			long long dis = distance(v.begin(), lower_bound(all(v), make_pair(q, -1)));
			ans += n - dis;
			q += a[i];
			//show(dis)
			if(dis != 0) ans -= sum(n) - sum(dis - 1);
			else ans -= sum(n);
			add(distance(v.begin(), lower_bound(all(v), cp[i])), 1);
			//show(distance(v.begin(), lower_bound(all(v), cp[i])))
	}
	cout << ans << endl;
}


Measured memory_bytes: 9600
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

ll aa[N];

int main() {ikarus_101

    ll n,m,i,j,k,x;


    ll a,b;

    cin>>n>>a>>b;

    rep1(i,n) cin>>aa[i];

    ll tt = 0;
    for(i=1;i<n;i++) {
        tt += (((aa[i+1]-aa[i]) * a) > b ? b : (aa[i+1]-aa[i]) * a);
    }

    cout << tt << endl;


















    return 0;
}


Measured memory_bytes: 4404