akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	var (
		err error
	)
	if sc.Scan() {
		_, err = strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}
	}

	list := []string{}
	if sc.Scan() {
		list = strings.Split(sc.Text(), " ")
	}

	checks := [][]string{}
	for i := range list {
		iv := strings.TrimLeftFunc(list[i], func(r rune) bool {
			return unicode.IsUpper(r)
		})
		if err != nil {
			panic(err)
		}

		exist := false
		for _, check := range checks {
			for _, c := range check {
				if strings.Contains(c, iv) {
					exist = true
					break
				}
			}
			if exist {
				break
			}
		}
		if exist {
			continue
		}

		check := []string{list[i]}
		for j := i + 1; j < len(list); j++ {
			if strings.Contains(list[j], iv) {
				check = append(check, list[j])
			}
		}
		if len(check) > 1 {
			checks = append(checks, check)
		}
	}

	listForBubble := make([]string, len(list))
	copy(listForBubble, list)

	listForSelect := make([]string, len(list))
	copy(listForSelect, list)

	sortedBubble := bubbleSort(listForBubble)
	sb := ""
	for _, ss := range sortedBubble {
		sb = sb + ss + " "
	}
	sb = strings.TrimRight(sb, " ")
	fmt.Println(sb)
	isStable(checks, sortedBubble)

	sortedSelect := selectionSort(listForSelect)
	ss := ""
	for _, sss := range sortedSelect {
		ss = ss + sss + " "
	}
	ss = strings.TrimRight(ss, " ")
	fmt.Println(ss)
	isStable(checks, sortedSelect)
}

func bubbleSort(list []string) []string {
	for i := 0; i < len(list); i++ {
		for j := len(list) - 1; j > i; j-- {
			pre, err := strconv.Atoi(strings.TrimLeftFunc(list[j-1], func(r rune) bool {
				return unicode.IsUpper(r)
			}))
			if err != nil {
				panic(err)
			}

			crr, err := strconv.Atoi(strings.TrimLeftFunc(list[j], func(r rune) bool {
				return unicode.IsUpper(r)
			}))
			if err != nil {
				panic(err)
			}

			if pre > crr {
				tmp := list[j-1]
				list[j-1] = list[j]
				list[j] = tmp
			}
		}
	}

	return list
}

func selectionSort(list []string) []string {
	for i := 0; i < len(list); i++ {
		min := i
		for j := i; j < len(list); j++ {
			minv, err := strconv.Atoi(strings.TrimLeftFunc(list[min], func(r rune) bool {
				return unicode.IsUpper(r)
			}))
			if err != nil {
				panic(err)
			}

			jv, err := strconv.Atoi(strings.TrimLeftFunc(list[j], func(r rune) bool {
				return unicode.IsUpper(r)
			}))
			if err != nil {
				panic(err)
			}

			if jv < minv {
				min = j
			}
		}
		//if i != min {
		tmp := list[i]
		list[i] = list[min]
		list[min] = tmp
		//}
	}
	return list
}

func isStable(checks [][]string, target []string) {
	for _, check := range checks {
		pre := -1
		for _, c := range check {
			for i, t := range target {
				if strings.Contains(t, c) {
					if pre > i {
						fmt.Println("Not stable")
						return
					}
					pre = i
					break
				}
			}
		}
	}
	fmt.Println("Stable")
}



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

#define ll long long
#define ull unsigned long long

using namespace std;

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


	if ( (X == 3) || (X == 5) || (X == 7) ){
	cout << "YES" << "\n";
	} else {	
	cout << "NO" << "\n";
	}
	

	return 0;
}


Measured memory_bytes: 256
a = int(input()) 
b = int(input()) 
c = int(input()) 
x = int(input()) 
flag = 0

for n in range(a+1):
  for m in range(b+1):
    for l in range(c+1):
      if 500*n+100*m+50*l==x:
        flag += 1
print(flag)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi p(n);
	rep(i, n) cin >> p[i];
	int mn = 1e9, ans = 0;
	rep(i, n){
		mn = min(mn, p[i]);
		if(p[i] <= mn) ans++;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main()
{
	string str;
	int m,h;

	while(cin >> str){
		if(str == "-")
			break;
		cin >> m;

		for(int n = 0 ; n < m ; ++n){
			cin >> h;

			string str_sub[2];
			str_sub[0] = str.substr(0,h);
			str_sub[1] = str.substr(h,str.length()-1);
			str = str_sub[1] + str_sub[0];
		}

		cout << str << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] hps = new int[n];
		for(int i=0; i<n; i++) {
			hps[i] = sc.nextInt();
		}
		sc.close();
		
		int ans = hit(hps[0], hps[1]);
		for(int i=2; i<n; i++) {
			ans = hit(ans, hps[i]);
			if(ans == 1 )
				break;
		}
		
		System.out.println(ans);
	}
	
	static int hit(int a, int b) {
		if(a == b)
			return a;
		
		if( Math.min(a, b) == 0)
			return Math.max(a, b);
		
		return(hit( Math.max(a, b) % Math.min(a, b), Math.min(a, b) ) );
	}
}

Measured memory_bytes: 50316
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int gcd(int a, int b){
	int temp1 = a, temp2 = b;
	if (temp1 < temp2){
		int temp;
		temp = temp1;
		temp1 = temp2;
		temp2 = temp;
	}
	if(temp2 == 0) return temp1;
	return gcd(temp2, temp1%temp2);
}

int main(){
	int p, q, m;
	cin >> p >> q;
	m = q/gcd(p,q);
	if(m == 1){
		cout << 1 << endl;
		return 0;
	}
	int temp = m, ans = 1;
	if(temp%2 == 0){
		ans *= 2;
		while(temp % 2 == 0){
			temp = temp/2;
			if(temp == 1) break;
		}
	}
	for(int i = 3;i<=m; i+=2){
		if(temp%i == 0){
			ans *= i;
			while(temp % i == 0){
				temp = temp/i;
				if(temp == 1) break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3112
/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <iostream>
#include <cstdio>
#include <limits>
#include <cstdlib>
#include <utility>
#include <iterator>
#include <bitset>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra


#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

list<int> tab;

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(false); cin.tie(NULL);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		tab.pb(x);
	}
	
	tab.sort();
	tab.reverse();
	
	int alice = 0;
	int bob = 0;
	int licznik = 0;
	
	for(auto it : tab){
		if(licznik % 2 == 0){
			alice += it;
			licznik++;
		}
		else{
			bob += it;
			licznik++;
		}
	}
	
	int wynik = alice - bob;
	if(wynik < 0){
		wynik *= (-1);
	}
	cout << wynik << endl;
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
"use strict"
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const S = input.slice(1,N+1);
  const M = Number(input.slice(N+1)[0]);
  const T = input.slice(N+2)

  const blue = {};
  const red = {};
  for(let i=0; i<N; i++){
    if(typeof blue[S[i]] === 'undefined'){
      blue[S[i]] = 1;
    } else {
      blue[S[i]] = blue[S[i]] + 1;
    }
  }
  for(let i=0; i<M; i++){
    if(typeof red[T[i]] === 'undefined'){
      red[T[i]] = 1;
    } else {
      red[T[i]] = red[T[i]] + 1;
    }
  }

  let ret = 0;
  for(let key in blue){
    let p = 0;
    if(red[key]){
      p = blue[key] - red[key];
    } else {
      p = blue[key];
    }
    if(ret < p) ret = p;
  }
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  ll n, k; cin >> n >> k;
  int res = 0;
  while(n){
    res++;
    n /= k;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

const int nmax = 40;
const int abmax = 10;

int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax*abmax + 1][nmax*abmax + 1];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, ma, mb; cin >> n >> ma >> mb;
	rep(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0; i <= n; i++) {
		for (int ca = 0; ca <= nmax * abmax; ca++) {
			for (int cb = 0; cb <= nmax * abmax; cb++) {
				dp[i][ca][cb] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	rep(i, n) {
		for (int ca = 0; ca <= nmax * abmax; ca++) {
			for (int cb = 0; cb <= nmax * abmax; cb++) {
				if (dp[i][ca][cb] == INF)continue;
				chmin(dp[i + 1][ca][cb], dp[i][ca][cb]);
				chmin(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}
	int ans = INF;
	for (int ca = 1; ca <= nmax * abmax; ca++) {
		for (int cb = 1; cb <= nmax * abmax; cb++) {
			if (ca*mb == cb * ma) {
				chmin(ans, dp[n][ca][cb]);
			}
		}
	}
	if (ans == INF)ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 51712
import java.util.*

fun main(args: Array<String>) {
  val forecast = readLine()!!.split("").filter { it != "" }.toList()
  val actual = readLine()!!.split("").filter { it != "" }.toList();
  var match = 0
  
  forecast.forEachIndexed {i,e ->
    if (e == actual.get(i)) {
      match++
    }
  }
  println(match)
}


Measured memory_bytes: 37900
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;


// 回答写経です
int main(){
    int h;
    cin >> h;
    int w;
    cin >> w;
    vs a(h);
    rep(i,0,h) cin >> a[i];
    
// 縦と横の正誤をチェックするための配列を作る
    vb row(h, false);
    vb col(w, false);
    rep(i,0,h){
      rep(j,0,w){
        // その行に1つでも#があればその行は出力しても良い
        if(a[i][j] == '#') {
          row[i] = true;
          col[j] = true;
        }
      }
    }

    // 出力
    rep(i,0,h){
      if(row[i]){
        rep(j,0,w){
          if(col[j]){
            cout << a[i][j];
          }
        }
        cout << endl;
      }
    }

    return 0;
    
  }



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


int main(){
    long long N,K,count=0;
    cin>>N>>K;
    vector<long long>H(N);
    if(N<K){
        cout<<0;
        return 0;
    }
    rep(i,N){
        cin>>H[i];
    }
    sort(H.begin(),H.end(),greater<long long>());
    rep(i,K){
        H[i]=0;
    }
    rep(i,N){
        count+=H[i];
    }
    cout<<count;
}

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

int main() {
  int n;
  cin>>n;
  if(n==1 ||n==2 ||n==3 ||n==5||n==6||n==9||n==10|n==13||n==17)
    cout <<"No" <<endl;
  else
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    d:isize,
    }
    println!("{}",min(a,b)+min(c,d))
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,x,y,max,min=0;
	cin >>a>>b>>c>>x>>y;
	max=x*2;
	if (x<y)
	max=y*2;
	for (int i=0;i<=max;i=i+2)
	{
		int sum,numa,numb;
		numa=x-i/2;
		if (numa<0)
		numa=0;
		numb=y-i/2;
		if (numb<0)
		numb=0;
		sum=i*c+a*numa+b*numb;
		if (sum<min||min==0)
		min=sum;
	}
	cout<<min;
	return 0;
} 

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from heapq import heappop, heappush

n, *a = map(int, read().split())
a_rev = list(map(lambda x: int(x) * (-1), a[::-1]))


def get_sum_list(a):
    h = []
    res = []
    cnt = 0
    for i, aa in enumerate(a[:2 * n]):
        heappush(h, aa)
        cnt += aa
        if i >= n:
            cnt -= heappop(h)
        if i >= n - 1:
            res.append(cnt)
    return res


left = get_sum_list(a)
right = get_sum_list(a_rev)
ans = -float('inf')
for i in range(n + 1):
    memo = left[i] + right[n - i]
    if ans < memo:
        ans = memo
print(ans)


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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] s = str.split(" ",0);
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			int c = Integer.parseInt(s[2]);
			if(c >= a && b >=c) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 19668
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	int N;
	cin >> N;
	
	if(N < 1000){
		cout << "ABC" << endl;
	}else{
		cout << "ABD" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 764
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1)
	{
		cerr << name << " = " << arg1 << endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args)
	{
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
		__f(comma+1, args...);
	}
#else
#define debug(...)
#endif

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

#define FAST_IO std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

// priority_queue<ll, vector<ll>, less<ll>>pq;     // Max Heap
// priority_queue<ll, vector<ll>, greater<ll>>pq;  // Min Heap

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth (1 based indexing) smallest: " << *A.find_by_order(k - 1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

int main()
{
	FAST_IO;

    ll k, n, ans = 0;
    cin >> k >> n;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n-1;i++) ans = max(ans, abs(a[i] - a[i+1]));
    ans = max(ans, k + a[0] - a[n - 1]);
    cout << k - ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
 
map<string, int> atoms_map;
string::const_iterator iter;
string::const_iterator end;
 
void consume(char expected) {
  if(*iter == expected) {
    //cout << *iter;
    iter ++;
    return;
  }
  assert(false);
}
 
bool ifconsume(char expected) {
  if(*iter == expected) {
    consume(expected);
    return true;
  }
  else {
    return false;
  }
}
 
string parse_atom() {
  bool first = 0;
  string work;
  for(;iter<end;) {
    if(!first && isupper(*iter)) {
      work += *iter;
      consume(*iter);
      first = 1;
    }
    else if(first && islower(*iter)) {
      work += *iter;
      consume(*iter);
    }
    else {
      break;
    }
  }
  return work;
}
 
int get_digits() {
   
  if(!isdigit(*iter)) return 1;
   
  int ret;
  ret = *iter - '0';
  consume(*iter);
   
  if(!isdigit(*iter)) {
    return ret;
  }
  else {
    ret *= 10; ret += *iter - '0';
    consume(*iter);
  }
  return ret;
}
 
int parse() {
   
  int ret = 0;
  for(;iter<end;) {
    if(ifconsume('(')) {
      // ( ... ) parsing
      int anum = parse();
      if(anum == -1) return -1;
      consume(')');
       
      //cout << "anum: " << anum << endl;
       
      anum *= get_digits();
      ret += anum;
 
      //cout << "mol: " <<  ret << endl;
    }
 
    else if(isalpha(*iter)) {
      // atom parsing
      string r = parse_atom();
      //cout << endl << "r: " << r << endl;
       
      map<string, int>::iterator it = atoms_map.find(r);
      if(it == atoms_map.end()) {
    return -1;
      }
       
      //cout << "number: " << it -> second << endl;
       
      int num = it -> second;
      num *= get_digits(); 
      ret += num;
    }
    else if(*iter == ')') {
      return ret;
    }
    else {
      assert(false);
    }
       
  }
   
  return ret;
}
 
int main() {
   
  while(1) {
    string s; cin >> s;
    if(s == "END_OF_FIRST_PART") break;
    int x; cin >> x;
    atoms_map[s] = x;
  }
  while(1) {
    string s; cin >> s;
    if(s == "0") return 0;
     
    iter = s.begin(), end = s.end();
     
    int ans = parse();
    if(ans == -1) {
      cout << "UNKNOWN\n";
    }
    else {
      cout << ans << endl;
    }
     
  }
   
  return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] cards = new int[n];

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

        int aliceScore = 0;
        int bobScore = 0;

        sortDesc(cards);

        for(int j = 0; j < n; j++){
            if(j % 2 == 0){
                aliceScore += cards[j];
            } else {
                bobScore += cards[j];
            }
        }
        System.out.println(aliceScore - bobScore);
        sc.close();
    }

    private static void sortDesc(int[] array){
        int len = array.length;
        for(int i = 1; i < len; i++){
            int tgt = array[i];
            for(int j = i-1; j >= 0; j--){
                if(tgt > array[j]){
                    array[j + 1] = array[j];
                    array[j] = tgt;
                } else {
                    break;
                }
            }
        }
    }

}


Measured memory_bytes: 23636
data = [str(i+1)*4 for i in range(9)]
while True:
    n = raw_input()
    if n == '0000': 
        break
    elif n in data:
        print 'NA'
        continue
    c = 0
    while n != '6174':
        L = int(''.join(sorted(list(n), key=int, reverse=True)))
        S = int(''.join(sorted(list(n), key=int)))
        n = str(L-S).zfill(4)
        c += 1
    else:
        print c

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,h,w,a,b,c,d,x,y;
string str;

signed main(){

  cin >> x >> y;
  if(x%y==0) cout << -1 fin;
  else{
    int t=x+x;
    while(true){
      if(t%y!=0)
        break;
      t+=x;
    }
    cout << t fin;
  }

  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi A(N), B(N); REP(i, N) cin >> A[i] >> B[i];

    vector<pii> c;
    REP(i, N) c.push_back(pii(A[i], B[i]));

    sort(c.begin(), c.end());
  
    int ans = c[N-1].first + c[N-1].second;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>

int main()
{
    int a;
    int b = 0;
    while(1)
    {
        b++;
        scanf("%d",&a);
        if(a==0) break;
        printf("Case %d: %d\n",b,a);
        a = 0;
    }
    return 0;
}

Measured memory_bytes: 1028
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt();
    let R = new Array(N);
    let B = new Array(N);
    for (let r = 0; r < N; r++) R[r] = [cin.getInt(), cin.getInt()];
    for (let b = 0; b < N; b++) B[b] = [cin.getInt(), cin.getInt()];
    B.sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);
    R.sort((a, b) => a[0] == b[0] ? b[1] - a[1] : a[0] - b[0]);
    let ans = 0;
    for (let b = 0; b < N; b++) {
        let rr = undefined, maxY = Number.MIN_SAFE_INTEGER;
        for (let r = 0; r < N; r++) {
            if (R[r] == undefined) continue;
            if (R[r][0] < B[b][0] && R[r][1] < B[b][1]) {
                if (maxY < R[r][1]) rr = r, maxY = R[r][1];
            }
        }
        if (rr != undefined) {
            R[rr] = undefined;
            ans++;
        }
    }
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

if (x == 'a' || x== 'i' || x== 'u' || x== 'e' || x== 'o' ) {
    cout << "vowel" << endl;
}

else {
   cout << "consonant" << endl;
}
}


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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    vector<int> V(N);
    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }

    vector<int> C(N);
    for (int j = 0; j < N; ++j) {
        cin >> C[j];
    }

    int ans = 0;

    for (int bit = 0; bit < (1 << N); ++bit) {
        int sum_x = 0;
        int sum_y = 0;

        for (int k = 0; k < N; ++k) {
            if (bit & (1 << k)) {
                sum_x += V[k];
                sum_y += C[k];
            }
        }

        ans = max(ans, sum_x - sum_y);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            
            
            int daysBeforeMonth[] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
            String weekday[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};

            while ((line = br.readLine()) != null) {
	            String splitedLine[] = line.split(" ");
	            if(splitedLine[0].equals("0")){
	            	break;
	            }
	            
	            int daysInYear = daysBeforeMonth[Integer.valueOf(splitedLine[0]) - 1] + Integer.valueOf(splitedLine[1]);
	            
	            System.out.println(weekday[daysInYear % 7]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}



Measured memory_bytes: 24124
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll ac=0,wa=0,tle=0,re=0;
    rep(i,0,n){
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
    return 0;  
}

Measured memory_bytes: 3660
#include<stdio.h>


int main(){
  char ball,buf[4],i;
  ball='A';
  i=0;
  while(fgets(buf,4,stdin)!=NULL){
    if(buf[0]==ball){
      ball=buf[2];
    }else if(buf[2]==ball){
      ball=buf[0];
    }
  }
  printf("%c\n",ball);
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k;
int ind;
int a;
int ass(int k,int sumlen)
{
    int ans=(sumlen/(k-1));
    if ((sumlen%(k-1))>0) ans++;
    return ans;
}
int main()
{
    cin>>n>>k;
    for (int i=1; i<=n; ++i)
    {
        cin>>a;
        if (a==1) ind=i;
    }
    int ans=2000000;
    for (int i=ind-k+1; i<=ind; ++i)
    {
        int ta=1;
        int start=i;
        if (start<1) continue;
        int e=i+k-1;
        if (e>n) continue;
        ta+=ass(k,start-1-1+1)+ass(k,n-(e+1)+1);
        if (ta<ans) ans=ta;
    }
    cout<<ans<<endl;


    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 2000000
int h, a[MAX + 1];
void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;
	if (l <= h&&a[l] > a[i])largest = l;
	else largest = i;
	if (r <= h&&a[r] > a[largest])largest = r;
	if (largest != i) {
		swap(a[i], a[largest]);
		maxHeapify(largest);
	}
}
int main() {
	cin >> h;
	for (int i = 1; i <= h; i++)cin >> a[i];
	for (int i = h / 2; i >= 1; i--)maxHeapify(i);
	for (int i = 1; i <= h; i++) {
		cout << " " << a[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 5032
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,ans=0;
  cin>>N;
  int A[N],B[N],C[N];
  REP(i,N) cin>>A[i];
  REP(i,N){
    cin>>B[i];
    ans+=B[i];
  }
  REP(i,N-1) cin>>C[i];
  
  for(int i=0; i<N-1; ++i){
    if(A[i+1]-A[i]==1) ans+=C[A[i]-1];
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vu64 S;
map<u64, u64> m;

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

    int N, K;
    u64 A;
    cin >> N >> K;

    S.resize(N + 1, 0);
    rep (i, N)
    {
        cin >> A;
        S[i + 1] = A + S[i];
    }

    rep (i, N + 1)
    {
        S[i] = (S[i] - i) % K;
    }

    u64 ans = 0;
    for (int j = 1; j <= N; ++j)
    {
        if (j == 1)
        {
            for (int i = j - K + 1; i < j; ++i)
            {
                if (i < 0) continue;
                ++m[S[i]];
            }
        }
        else
        {
            if (j - K >= 0) --m[S[j - K]];
            ++m[S[j - 1]];
        }
        ans += m[S[j]];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 14336
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = list(map(int, input().split()))
# s = input()

H1, M1, H2, M2, K = list(map(int, input().split()))

t1 = H1*60 + M1
t2 = H2*60 + M2

t = t2-t1
ans = max(0, t-K)
print(ans)


Measured memory_bytes: 9184
alldeck = [f'{mark} {num + 1}' for mark in 'SHCD' for num in range(13)]
count = int(input())
deck = set(input() for _ in range(count))
nokori = set(alldeck) - deck
[print(card) for card in sorted(nokori, key=lambda c: alldeck.index(c))]



Measured memory_bytes: 5616
using System;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {


            //テンプレート
            //// 整数の入力
            //int a = int.Parse(Console.ReadLine());
            //// スペース区切りの整数の入力
            //string[] input = Console.ReadLine().Split(' ');
            //int b = int.Parse(input[0]);
            //int c = int.Parse(input[1]);
            //// 文字列の入力
            //string s = Console.ReadLine();
            ////出力
            //Console.WriteLine(a + b + c + " " + s);


            string input = Console.ReadLine();
            char[] inputs = input.ToCharArray();

            int change_color = 0;
            char preview_color = '5';


            foreach (var color in inputs)
            {
                char current_color = color;

                if (color == preview_color)
                {
                    change_color++;

                    

                    if (preview_color == '0')
                        current_color = '1';
                    else
                        current_color = '0';


                }

                preview_color = current_color;
            }

            Console.WriteLine(change_color);
            Console.ReadLine();




        }

    }
}

Measured memory_bytes: 13536
using System;
class Program
 {
   static void Main(string[] args)
   {
     string[] HW;
     HW = Console.ReadLine().Split(' ');
     int H,W;
     H = int.Parse(HW[0]);
     W = int.Parse(HW[1]);

     string[] A =  new string[H];
     int[]HFlag = new int[H];
     int[]WFlag = new int[W];
     

     for(int i = 0 ; i < H ;i++)
     {
       A[i] = Console.ReadLine();       
     }
     
     for(int i = 0 ; i < H ;i++)
     {
       for(int j = 0 ; j < W ;j++)
       {
        if(A[i][j] == '#')
        {
          HFlag[i] = 1;
        } 
       }
     }

     for(int i = 0 ; i < W ;i++)
     {
       for(int j = 0 ; j < H ;j++)
       {
        if(A[j][i] == '#')
        {
          WFlag[i] = 1;
        } 
       }
     }
     
     for(int i = 0 ; i < H ;i++)
     {
       for(int j = 0 ; j < W ;j++)
       {
         if(WFlag[j]==1 && HFlag[i]==1)
         {
           Console.Write(A[i][j]);
         }
       }
       if(HFlag[i]==1){
        Console.Write('\n');
       }
     
     }
     

        
   }
 }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    Vi x(5);
    int ans=0;
    rep(i,5){
        cin>>x[i];
        if(x[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }

    cout<<ans<<endl;
}

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

#define rep(i,n) for(int i=0; i<n; ++i)
#define repl(i, s, n) for(int i=s; i<=n; ++i)
#define max(a,b) (a>b?a:b)
#define N 103
#define INF 1000000007

int mat[N][N] = {{0}};
int sum[N][N] = {{0}};

int main() {
	int n, ans=-INF;
	cin >> n;
	rep(i, n) {
		int tmp = 0;
		rep(j, n) {
			cin >> mat[i][j];
			tmp += mat[i][j];
			sum[i+1][j+1] = tmp + sum[i][j+1];
		}
	}
	
	repl(x1, 1, n) repl(y1, 1, n) {
		repl(x0, 0, x1) repl(y0, 0, y1) {
			if(x1==x0 && y1==y0) continue;
			int s = sum[y1][x1] - (x0!=x1 ? sum[y1][x0] : 0) - (y0!=y1 ? sum[y0][x1] : 0) + sum[y0][x0];
			ans = max(ans, s);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1244
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		int k = sc.nextInt();
		
		int a = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
		
		if (a < 0) a = 0;
		System.out.println(a);
	}
}

Measured memory_bytes: 35776
n, m = map(int, input().split())
INF = 10 ** 20
edgeList = []
dist = [[INF] * n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    dist[a][b] = dist[b][a] = c
    edgeList.append((a, b, c))

for k in range(n):
    for i in range(n):
        for j in range(n):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

print(sum([dist[a][b] < c for a, b, c in edgeList]))


Measured memory_bytes: 3444
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(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;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=2000023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    v.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    ll pre[n+1]={0};
    adj[0].pb(0);
    ll zeros[n+10]={0};
    zeros[0]=1;
    for(int i=1;i<=n;i++)
    {
        pre[i]=(pre[i-1]^v[i]);
        adj[pre[i]].pb(i);
        zeros[i]=zeros[i-1];
        if(pre[i]==0)
            zeros[i]++;
    }
    if(pre[n]!=0)
    {
        ll x=pre[n];
        ll dp[n+1][2];
        memset(dp,0,sizeof(dp));
        dp[0][0]=1;
        dp[0][1]=0;
        for(int i=1;i<=n;i++)
        {
            if(pre[i]!=0)
                dp[i][0]=dp[i-1][0];
            else
                dp[i][0]=dp[i-1][0]+dp[i-1][1];
            if(pre[i]!=x)
                dp[i][1]=dp[i-1][1];
            else
                dp[i][1]=dp[i-1][0]+dp[i-1][1];
            dp[i][0]%=mod;
            dp[i][1]%=mod;
        }
        cout<<dp[n][0]<<'\n';
    }
    else
    {
        ll allzeros=adj[0].size();
        ll ans=0;
        ans+=power(2,allzeros-2);
        vl x;
        rep(i,n+1)
        {
            x.pb(pre[i]);
        }
        vis[0]=1;
        for(auto res:x)
        {
            if(vis[res])
                continue;
            vis[res]=1;
            ll a=1,b=0;
            for(int i=0;i<adj[res].size()-1;i++)
            {
                b+=a;
                b%=mod;
                ll cont=zeros[adj[res][i+1]]-zeros[adj[res][i]];
                a+=(b*cont);
                a%=mod;
            }
            b+=a;
            b%=mod;
            ans+=b;
            ans%=mod;
        }
        cout<<ans<<'\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 77508
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll attack(ll x) {
	if (x == 1) return 1;
	else return 1 + attack(x / 2) * 2;
}
int main()
{
	ll H; cin >> H;
	cout << attack(H) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
 int n,k;
  cin >> n >> k;
 vector<int>nmin;
 for(int i = 0; i < n; i++){
  int a;
   cin >> a;
   nmin.push_back(a);
 }
sort(nmin.begin(),nmin.end());
  int ans = 0;
  for(int i = 0; i < k; i++){
    ans+=nmin[i];
  }
  cout << ans << endl;
  
}

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

#define INF 1e+9

int N,W;
int w[101],v[101];
int memo[110][11000];

int knapsack(int i, int j){
	  if(j < 0) return -INF; // ??????????¶?????????????
	  if(i == N) return 0;   // ????????????????????????
	  if(memo[i][j] != -1) return memo[i][j]; //???????¨??????????

	  int ans= 0;
	  ans = max(knapsack(i+1,j), knapsack(i+1, j-w[i]) + v[i]);

	  memo[i][j] = ans;
	  return ans;
}

int main(){
	  cin >> N >> W;
	  for(int i=0; i<N; i++) cin >> v[i] >> w[i];
	  memset(memo,-1,sizeof(memo));
	  cout << knapsack(0,W) << endl;
}

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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define FILE_IO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define trav(e, x) for (auto &e : x)
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define int long long
using namespace std;
typedef pair<int, int> ii;

const int N = 3001;
int a[N];
int dp[N][N][2];

int f(int i, int j, int k) {
    if (i > j) return 0;
    if (dp[i][j][k] > -1) return dp[i][j][k];
    int ans;
    if (k == 1) ans = max(f(i + 1, j, 0) + a[i], f(i, j - 1, 0) + a[j]);
    else ans = min(f(i + 1, j, 1), f(i, j - 1, 1));
    return dp[i][j][k] = ans;
}

signed main() {
    FAST_IO;
    //FILE_IO;

    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j][0] = dp[i][j][1] = -1;
    int x = f(0, n - 1, 1);
    int y = sum - x;
    cout << x - y;
}


Measured memory_bytes: 144564