akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

int N, M, X;
vector<int> C;
vector<vector<int>> A;
vector<int> cal;
int rtn = INF;
bool onceTrue = false;

bool isExceed_X(vector<int>& a) {
    for (int i = 0; i < a.size(); i++) {
        if (a[i] < X) {
            return false;
        }
    }
    onceTrue = true;
    return true;
}

void dfs(int depth, int sumPrice, vector<int>& cal) {
    if (depth == N+1) return;
    dfs(depth+1, sumPrice, cal);
    for (int i = 0; i < M; i++) {
        cal[i] += A[depth][i];
    }
    dfs(depth+1, sumPrice+C[depth], cal);
    if (isExceed_X(cal)) {
        rtn = min(rtn, sumPrice+C[depth]);
    }
    for (int i = 0; i < M; i++) {
        cal[i] -= A[depth][i];
    }
}

int main() {
    cin >> N >> M >> X;
    C.resize(N+1);
    cal.resize(M);
    A.resize(N+1, vector<int>(M));
    for (int i = 1; i <= N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    dfs(0, 0, cal);

    if (!onceTrue) {
        cout << "-1\n";
    } else {
        cout << rtn << endl;
    }
}

Measured memory_bytes: 3200
package main

import (
	"fmt"
	"math"
)

func main() {

	var N, L int
	fmt.Scanf("%d %d", &N, &L)

	var sum int = 0
	var min int = 100000
	var number int
	for i := 1; i <= N; i++ {
		sum += L + i - 1
		if min >= int(math.Abs(float64(L)+float64(i)-1)) {
			min = int(math.Abs(float64(L) + float64(i) - 1))
			number = L + i - 1
		}
	}

	fmt.Println(sum - number)
}


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

int main(){
	int d; cin >> d;
	if(d == 22)cout << "Christmas Eve Eve Eve" << endl;
	else if(d == 23)cout << "Christmas Eve Eve" << endl;
	else if(d == 24)cout << "Christmas Eve" << endl;
	else cout << "Christmas" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        if (K >= N) {
            System.out.println(N * X);
        } else {
            System.out.println(K * X + (N - K) * Y);
        }
    }
}


Measured memory_bytes: 22868
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
	int N,X; cin >> N >> X;
	vector<int> m(N);
	int sum = 0;
	rep(i,N){
		cin >> m[i];
		sum += m[i];
	}
	sort(m.begin(),m.end());
	int ans = N;
	X -= sum;
	ans += X/m[0];
	cout << ans << endl;

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, M = MI()
    V = [[] for _ in range(N)]
    E = []
    for i in range(M):
        a, b = MI1()
        V[a].append(b)
        V[b].append(a)
        E.append((a, b))

    ans = 0
    for a, b in E:
        used = [0] * N
        flag = True
        q = deque([a])
        used[a] = 1
        while q:
            cur = q.popleft()

            for nv in V[cur]:
                if (a, b) == (cur, nv) or (a, b) == (nv, cur):
                    continue

                if used[nv]:
                    continue

                if nv == b:
                    flag = False
                    q = []
                    break

                q.append(nv)
                used[nv] = 1
            # print(a, b, q)

        if flag:
            ans += 1
    print(ans)

if __name__ == '__main__':
    solve()



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

int main(void){

    string S;
    cin >> S;

    int hug = 0;
    int cntR = S.length()-1;

    for(int cntL=0; cntL < cntR; cntL++, cntR--){
        if(S[cntL]!=S[cntR])hug++;
    }

    cout << hug << endl;

    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;

  int s = L, e = L + N - 1;
  int ans = (s + e) * N / 2;
  if (s > 0)
    ans -= s;
  if (e < 0)
    ans -= e;

  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= a <= 12:
    print('MMYY')
elif 1 <= b <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

void main()
{
    int n = readln().strip().to!int;
    int[] a = readln().strip().split().map!(e=>e.to!int).array;

    int next = 1;
    int broken = 0;

    foreach (elem; a)
    {
        if (elem != next)
            broken++;
        else
            next++;
    }

    if (broken == n)
        broken = -1;

    writefln("%d", broken);
}


Measured memory_bytes: 11408
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int a, b;
  cin >> a >> b;
  bool check = false;
  for (int i = 1; i < 5000; i++)
  {
    int t8 = i * 0.08;
    int t10 = i * 0.1;
    if (t8 == a && t10 == b)
    {
      cout << i << "\n";
      check = true;
      break;
    }
  }
  if (!check)
  {
    cout << -1 << "\n";
  }
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long sum = 0;
            for (int i = 1; i <= n; i++)
            {
                for (int j = 0; j <= n; j++)
                {
                    for (int k = 0; k <= n; k++)
                    {
                        sum += GCD(i, j, k);
                    }
                }
            }
            Console.WriteLine(sum);
        }

        static long GCD(int a, int b, int c)
        {
            int min = Math.Min(Math.Min(a, b), c);

            for (int i = min; i >= 1 ; i--)
            {
                if (a % i == 0 && b % i == 0 && c % i == 0)
                {
                    return i;
                }
            }
            return 0;
        }
    }
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n, x;

ll ans;

ll calc(ll cur_x, ll cur_length) {
  ll part = cur_length / cur_x;
  if (cur_length % cur_x == 0) { // just returned start point
    return (part * 2 - 1) * cur_x;
  }
  else { // did not return, spray more detailed ray
    ll next_x = cur_length % cur_x;
    ll next_length = cur_x;
    return (part * 2) * cur_x + calc(next_x, next_length);
  }
}

int main(void) {
  // Here your code !
  scanf("%lld %lld\n", &n, &x);

  if (n % 2 == 0) {
    if (x == (n / 2)) {
      ans = 3 * x;
    }
    else {
      ll cur_x = x;
      ll cur_length = n - x;
      ans = cur_x + cur_length + calc(cur_x, cur_length);
    }
  }
  else {
    ll cur_x = x;
    ll cur_length = n - x;
    ans = cur_x + cur_length + calc(cur_x, cur_length);
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++)cin >> d[i];
 sort(ALL(d));
  cout << (d[n/2] - d[n/2 - 1]);
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll e;
    while(cin >> e,e){
        ll m=e;
        for(int y=0;y*y<=e;y++){
            for(int z=0;z*z*z+y*y<=e;z++){
                m=min(m,y+z+(e-y*y-z*z*z));
            }
        }
        cout << m << endl;
    }
}



Measured memory_bytes: 3096
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int a, b;
    while (scanf("%d %d", &a, &b), 0 != a && 0 != b)
    {
        for (size_t i = 0; i < a; i++)
        {
            for (size_t j = 0; j < b; j++)
            {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2072
#include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, a;
P s, t, u, v;
priority_queue<P> que1, que2;
map<ll, ll> mp1, mp2;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++){
        cin >> a;
        if (i % 2 == 0){
            mp1[a]++;
        } else {
            mp2[a]++;
        }
    }
    for (auto itr = mp1.begin(); itr != mp1.end(); itr++){
        que1.push(P(itr->second, itr->first));
    }
    for (auto itr = mp2.begin(); itr != mp2.end(); itr++){
        que2.push(P(itr->second, itr->first));
    }
    s = que1.top(), t = que2.top();
    if (s.second != t.second){
        cout << n - s.first - t.first << endl;
    } else {
        if (mp1.size() == 1 && mp2.size() == 1){
            cout << n / 2 << endl;
        } else if (mp1.size() == 1){
            que2.pop(); u = que2.top();
            cout << n / 2 - u.first << endl;
        } else if (mp2.size() == 1){
            que1.pop(); v = que1.top();
            cout << n / 2 - v.first << endl;
        } else {
            que2.pop(); u = que2.top();
            que1.pop(); v = que1.top();
            cout << min(n - s.first - u.first, n - t.first - v.first) << endl;
        }
    }
}


Measured memory_bytes: 8824
import math
def arg(x,y):
  if x==0:
    if y>0:
      return math.pi/2
    else:
      return 3*math.pi/2
  else:
    if x>0:
      return math.atan(y/x)
    else:
      return math.atan(y/x)+math.pi
n=int(input())
A=[]
for i in range(n):
  x,y=map(int,input().split())
  if x==0 and y==0:
    continue
  A.append([arg(x,y),x,y])
  A.append([arg(x,y)+2*math.pi,x,y])
A=sorted(A)
n=len(A)//2
ans=0
for i in range(n):#始点
  for j in range(1,n+1):#連続数
    X=0
    Y=0
    for k in range(i,i+j):
      X=X+A[k][1]
      Y=Y+A[k][2]
    d=(X**2+Y**2)**(1/2)
    if d>ans:
      ans=d
print(ans)

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll LINF = 1e18;


typedef struct num {
    string str;
    int kind;
} Num;

Num num(string str, int kind) {
    Num a = {str, kind};
    return a;
}

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

    vector<vector<Num>> a(10);
    a[0].push_back(num("a", 1));

    rep(i, 1, 10) {
        for (auto b : a[i - 1]) {
            rep(j, b.kind + 1) {
                if (j < b.kind)
                    a[i].push_back(num(b.str + (char)('a' + j), b.kind));
                else
                    a[i].push_back(num(b.str + (char)('a' + j), b.kind + 1));
            }
        }
    }

    for (auto b : a[n - 1])
        cout << b.str << endl;

    return 0;
}


Measured memory_bytes: 10736
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

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

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

  ll n;
  std::cin>>n;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];

  std::vector<ll> cnt(n,0),used(n,0);

  ll ans=1,max=0;

  rep(i,0,n){
    if(a[i]!=0){
      if(cnt[a[i]-1]==0){
        std::cout<<0<<"\n";
        return 0;
      }
      ans=(ans*cnt[a[i]-1])%MOD;
      cnt[a[i]-1]--;
      used[a[i]-1]++;
    }
    cnt[a[i]]++;
    chmax(max,cnt[a[i]]);
  }

  rep(i,0,n)if(cnt[i]+used[i]>3){std::cout<<0<<"\n";return 0;}

  std::cout<<(((max==1)?3:6)*ans)%MOD<<"\n";

  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e2+5;

int x[10],y[10];
bool vis[10];
double ans = 0;

inline double dis(int u,int v){
	return sqrt((double)(x[v]-x[u])*(x[v]-x[u])+(double)(y[v]-y[u])*(y[v]-y[u]));
}

void dfs(int step,int now,int n,double sum){
	if(step == n){
		ans += sum;
		return ;
	}
	
	for(int i = 1;i <= n;++i){
		if(!vis[i]){
			vis[i] = 1;
			dfs(step+1,i,n,sum+dis(now,i));
			vis[i] = 0;
		}
	} 
	return ;
}

int main()
{
    int n;
    memset(vis,0,sizeof(vis));
    scanf("%d",&n);
    for(int i = 1;i <= n;++i) scanf("%d%d",&x[i],&y[i]);
    
    ans = 0;
    for(int i = 1;i <= n;++i){
    	vis[i] = 1;
		dfs(1,i,n,0);
		vis[i] = 0;
	}
    
    int k = 1;
    for(int i = 1;i <= n;++i) k *= i;
    printf("%.10lf\n",ans/(double)k);
    return 0;
} 

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

int main() {
string s,t;
cin>>s>>t;
int size=s.size();

for(int i=1;i<=size;i++){
  string tmp = s.substr(size-i,i)+s.substr(0,size-i);
  //cout<<tmp<<endl;
  if(tmp==t){
    cout<<"Yes"<<endl;
    return 0;
  }
}
cout<<"No"<<endl;
}


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

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    vector<int> d1(n),d2(n);
    rep(i,n) cin >> d1[i] >> d2[i];
    bool ok = false;
    rep(i,n-2){
        if(d1[i] == d2[i] && d1[i+1] == d2[i+1] && d1[i+2] == d2[i+2]) ok = true;
    }
    cout << (ok?"Yes":"No") << endl;
}



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

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if (A == B && A != C) print(YES);
    else if (B == C && B != A) print(YES);
    else if (C == A && C != B) print(YES);
    else print(NO);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var cnt = new int[n+1];
            for (var x = 1; x <= 100; x++)
            {
                for (var y = 1; y <= 100; y++)
                {
                    for (var z = 1; z <= 100; z++)
                    {
                        var ans = Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2) + (x * y) + (y * z) + (z * x);
                        if (ans <= n)
                        {
                            cnt[(int)ans]++;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            for (var i = 1; i <= n; i++)
            {
                Console.WriteLine(cnt[i]);
            }
        }
    }
}


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

int main(){
  int n,d,x;
  cin >> n >> d >> x;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    x+=(d-1)/a+1;
  }
  cout << x << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

struct edge{int to;ll cap;int rev;};

int MAX_V=20050;
int tmp1,tmp2;

vector<vector<edge>> g(MAX_V);//グラフの隣接リスト表現
vin level(MAX_V);//distance form s
vin iter(MAX_V);//どこまで調べたか

void add_edge(int from,int to,ll cap=(ll)inf){
    tmp1=g[to].size();tmp2=g[from].size();
    g[from].push_back((edge){to,cap,tmp1});//g[to]のg[to].size()番目にfromが入っている
    g[to].push_back((edge){from,0,tmp2});//g[from]のg[from].size()-1番目にtoが入っている
}

void bfs(int s){
    fill(all(level),-1);
    queue<int> q;
    q.push(s);
    level[s]=0;
    while(q.size()){
        int v=q.front();q.pop();
        for(auto& e:g[v]){
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                q.push(e.to);
            }
        }
    }
}

//増加パスをdfsで探す
//v:今見てる頂点 t:終点 f:流量
int dfs(int v,int t,ll f){
    if(v==t)return f;
    for(int& i=iter[v];i<(int)g[v].size();i++){
        edge& e=g[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s,int t){
    ll flow=(ll)0;
    ll f;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        fill(all(iter),0);
        while((f=dfs(s,t,inf))>0)flow+=f;
    }
}

int main(){
    int h,w;cin>>h>>w;
    vstr S(h);
    rep(i,h)cin>>S[i];
    //各マスinとoutを2つ用意
    //(i,j)のinは2(i*w+j)で, outは2(i*w+j)+1で表される
    int s=2*h*w;//s→ヤギ
    int t=s+1;//追加したグリッドのマス(ゴール)→t
    int tmp;
    rep(i,h)rep(j,w){
        tmp=2*(i*w+j);
        if(S[i][j]=='X'){
            if(i==0||i==h-1||j==0||j==w-1){
                cout<<-1<<endl;
                return 0;
            }
            add_edge(tmp,tmp+1);
            add_edge(s,tmp+1);
        }
        else add_edge(tmp,tmp+1,(ll)1);
        if(i>0)add_edge(tmp+1,tmp-2*w);
        if(i<h-1)add_edge(tmp+1,tmp+2*w);
        if(j>0)add_edge(tmp+1,tmp-2);
        if(j<w-1)add_edge(tmp+1,tmp+2);
        if(i==0||i==h-1||j==0||j==w-1)add_edge(tmp+1,t);
    }
    cout<<max_flow(s,t)<<endl;
}

Measured memory_bytes: 7604
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ans=0,ans2=0;
    cin>>n;
    while(n>=10){
        ans+=n%10;
        ans2+=9;
        n/=10;
    }
    ans+=n;
    ans2+=n-1;
    cout<<max(ans,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 3636
let kVMax = 100_000
let n = Scanf.scanf " %d" @@ (+) 0
let vs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let css = Array.make_matrix 2 (kVMax + 1) 0
let _ =
  if n = 2 then (Printf.printf "%d\n" @@ if vs.(0) = vs.(1) then 1 else 0; exit 0);
  for i = 0 to n - 1 do
    css.(i land 1).(vs.(i)) <- css.(i land 1).(vs.(i)) + 1
  done;
  let max_v, max_c = [|0; 0|], [|0; 0|] in
  for i = 1 to kVMax do
    for j = 0 to 1 do if css.(j).(i) > max_c.(j) then (max_c.(j) <- css.(j).(i); max_v.(j) <- i) done
  done;
  for i = 0 to 1 do Array.sort (fun x y -> y - x) css.(i) done;
  Printf.printf "%d\n" @@ if max_v.(0) <> max_v.(1) then n - max_c.(0) - max_c.(1)
    else n - max (max_c.(0) + css.(1).(1)) (css.(0).(1) + max_c.(1))

Measured memory_bytes: 7040
#include <iostream>
#include <algorithm>

using namespace std;

bool binary_search(int *m, int n, int x) {
    int l = 0, r = n;
    while (l < r) {
        int i = (l + r) / 2;
        if (m[i] == x)
            return true;
        else if (m[i] < x)
            l = i+1;
        else 
            r = i;
    }
    return false;
}

int main() {
    int n;  cin >> n;
    int *l = new int[n];
    for (int i = 0; i < n; i++)
        cin >> l[i];

    sort(l, l+n, greater<int>());

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if (l[i] < l[j] + l[k])
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

l = ['dream', 'dreamer', 'erase', 'eraser']

ans = 'YES'

while(len(S) > 4):
    a = S[-5:]
    if a == 'dream' or a == 'erase':
        S = S[:-5]
        continue
    a = S[-6:]
    if a == 'eraser':
        S = S[:-6]
        continue
    a = S[-7:]
    if a == 'dreamer':
        S = S[:-7]
        continue
    ans = 'NO'
    break

print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>

int main(){
  char a[200],b[200];
  int s,h,i;

  while(1){
    scanf("%s",a);
    if(strcmp(a,"-")==0)
      break;

    strcpy(b,a);

    scanf("%d",&s);

    for(i=0;i<s;i++){
      scanf("%d",&h);
      strcpy(a,&b[h]);
      strncpy(&a[strlen(a)],b,h);
      strcpy(b,a);
    }
    printf("%s\n",a);
  }


  return 0;
}

Measured memory_bytes: 1776
#include <iostream>
using namespace std;
int main(){
    int m,f,r,s;
    while (1){
        cin >> m >> f >> r;
        s = m + f;
        if(m==-1 && f==-1 && r==-1) break;
        else if(m==-1 || f==-1) cout << "F" <<endl;
        else if(s>=80) cout << "A" <<endl;
        else if(s>=65) cout << "B" <<endl;
        else if(s>=50) cout << "C" <<endl;
        else if(s>=30 && r>=50) cout << "C" <<endl;
        else if(s>=30) cout << "D" <<endl;
        else cout << "F" <<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int n; cin >> n;
	
	vector<double> x(n);
	vector<string> u(n);
	double sum = 0;

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
		if (u[i] == "BTC") sum += x[i] * 380000.0;
		else sum += x[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
//https://www.codechef.com/LTIME59A/problems/GCDDIV
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    map<string, int> :: iterator itr;
    set<string> ans;
    set<string> :: iterator itrs;
    int max_cnt = 0;
    for(itr = mp.begin(); itr != mp.end(); itr++) {
        max_cnt = max(max_cnt, itr->second);
    }
    for(itr = mp.begin(); itr != mp.end(); itr++) {
        if(itr->second == max_cnt)
            ans.insert(itr->first);
    }
    for(itrs = ans.begin(); itrs != ans.end(); itrs++) {
        cout << (*itrs) << endl;
    }
    return 0;
}


Measured memory_bytes: 33280
#include<iostream>
using namespace std;
int main(){
  int n,x,i;long long ans = 0;cin >> n >> x;
  int a[n+1];a[0] = 0;
  for(i=1;i<=n;i++) cin >> a[i];
  for(i=1;i<=n;i++){
    if(a[i]+a[i-1]>x){
      ans += a[i]+a[i-1]-x;a[i] = x-a[i-1];
    }
  }
  cout << ans << endl;
}

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

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

#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 a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;

    return 0;
}

Measured memory_bytes: 256
#define Oo ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
typedef long long ll;
ll n;
ll a[200005];
ll t[200005];
ll mod=1000000007;
int main()
{
      Oo
      cin>>n;
      for (int i=1; i<=n; i++)cin>>a[i];
      for (int i=n; i>=1; i--)
      {
            if(i==n)t[i]=a[i];
            else
            {
                  t[i]=t[i+1]+a[i];
            }
            t[i]%=mod;
      }
      ll ans=0;
      for (int i=1; i<=n; i++)
      {
            ans+=(a[i]*t[i+1]%mod);
            ans%=mod;
      }
      cout << ans << endl;
	return 0;
}


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

int main() {
	int a,b;
  	bool isOdd;
	scanf("%d %d", &a, &b);
	isOdd = (a % 2 == 1) && (b % 2 == 1);
  	if(isOdd) {
      printf("Odd");
    } else {
      printf("Even");
    }
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
vector<ll>tree[200005];
ll vis[100005];
ll dis[100005];
ll par[100005];
void dfs(ll v)
{
    if(vis[v])
    return ;

    vis[v]=true;

    for(int i=0;i<tree[v].size();i++)
    {
        dfs(tree[v][i]);
    }

}
void bfs(ll v)
{
    queue<ll>q;
    q.push(v);
    dis[v]=0;
    vis[v]=true;
    while(!q.empty())
    {
        ll x=q.front();
        q.pop();

        for(int i=0;i<tree[x].size();i++)
        {
            if(!vis[tree[x][i]])
            {
                vis[tree[x][i]]=true;
                dis[tree[x][i]]=dis[x]+1;
                par[tree[x][i]]=x;
                q.push(tree[x][i]);
            }
        }
    }
}
int main() {

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

  ll n,m;
  cin>>n>>m;

  for(int i=0;i<m;i++)
  {
      ll u,v;
      cin>>u>>v;
      tree[u].push_back(v);
      tree[v].push_back(u);
  }
  ll cnt=0;
  for(int i=1;i<-n;i++)
  {
      if(!vis[i])
      {
          cnt++;
      }
  }
  if(cnt>1)
  cout<<"No\n";
  else
  {
      cout<<"Yes\n";
      memset(vis,false,sizeof vis);
      bfs(1);
      for(int i=2;i<=n;i++)
      cout<<par[i]<<endl;
  }



  


    return 0;
}

Measured memory_bytes: 16856
#include <iostream>
#include <string>
#define MAX 2000000

using namespace std;

int a[MAX+1];
int size=0;

void maxHeapify(int i){
  int largest;
  // select maximum node in left,itself,right
  if(2*i<=size && a[2*i]>a[i]) largest=2*i;
  else largest=i;
  if(2*i+1<=size && a[2*i+1]>a[largest]) largest=2*i+1;
  if(largest!=i){
    int t=a[i];
    a[i]=a[largest];
    a[largest]=t;
    maxHeapify(largest);
  }
}

void insert(int key){
  size++;
  a[size]=key;
  int i=size;
  while(i>1 && a[i/2]<a[i]){
    int t=a[i];
    a[i]=a[i/2];
    a[i/2]=t;
    i=i/2;
  }
}

int extractMax(){
  int max=a[1];
  a[1]=a[size];
  size--;
  maxHeapify(1);
  return max;
}

int main(){
  while(true){
    string com;
    cin >> com;
    if(com=="insert"){
      int k;
      cin >> k;
      insert(k);
    }else if(com=="extract"){
      cout << extractMax() << endl;
    }else if(com=="end"){
      break;
    }
  }
}

Measured memory_bytes: 6952
c = [list(map(int,input().split())) for i in range(3)]
if all((c[0][i+1] - c[0][i] == c[1][i+1] - c[1][i] == c[2][i+1] - c[2][i] for i in range(2))):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
//include
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
//macro
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define vecuni(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
//shorter type
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvs = vector<vector<string>>;
template<class T>
using vec = vector<T>;

//frequent functions
int gcd(int a, int b) { 
  if (a == 0) 
    return b; 
  return gcd(b % a, a); 
} 
int findGCD(vector<int> &arr, int n) {
  int result = arr[0]; 
  for (int i = 1; i < n; i++) 
    result = gcd(arr[i], result); 
  return result; 
}
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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

string s;
int K;
vs d;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> s >> K;
  for(int i = 0 ; i < s.length() ; i++){
    for(int j = 1 ; j <= K ; j++){
      d.push_back(s.substr(i,j));
    }
  }
  sort(all(d));
  vecuni(d);
  cout << d[K-1] << endl;
  return 0;
}


Measured memory_bytes: 1288
n=int(input())
flg=True
se=set()
for i in range(n):
  s=input()
  if s in se:
    flg=False
  se.add(s)
  if not i:
    f,b=s[0],s[-1]
  else:
    if s[0]!=b:
      flg=False
    f,b=s[0],s[-1]
if flg:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 38384
import java.util.*;

import static java.lang.System.*;

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

        long[] A = new long[N];
        long[] B = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            B[i] = sc.nextLong();
        }

        long cnt = 0;
        for (int i = N - 1; i >= 0; i--) {
            A[i] += cnt;
            if (A[i] % B[i] != 0) {
                cnt += ((long) (A[i] / B[i]) + 1) * B[i] - A[i];
            }
        }

        out.println(cnt);
    }
}

Measured memory_bytes: 89796
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;

const int INF = 1e9 ;
const int maxN = 2e5 + 5;
int n,k;
int a[maxN];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int ans = 2*INF;
	for(int i=1;i<=n-k+1;i++)
	{
		int num = a[i+k-1] - a[i];
		ans = min(ans,num);
	}
	printf("%d\n",ans);
	return 0;
} 

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

int64_t powi(int64_t base, int64_t n){
    int64_t ret = 1;
    for(int i = 0; i < n; i++){
        ret *= base;
    }
    return ret;
}

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

    int64_t count = 0;
	
  	if (n % 2 == 0){
    int64_t num = 1;
    for (num; (int64_t)(n / (powi(5, num) * 2)) > 0; num++){
        count += (int64_t)(n / (powi(5, num) * 2));
    }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int h = sc.nextInt();

		int maxa = 0;

		int count = 0;
		int attack = 0;

		List<Integer> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {

			int a = sc.nextInt();
			int b = sc.nextInt();

			maxa = Math.max(maxa, a);

			list.add(b);
		}

		list.sort(Comparator.reverseOrder());

		for (int num : list) {
			if(num > maxa) {

				attack += list.get(count);
				count++;

				if (attack >= h)
					break;
			}
		}

		while (attack < h) {
			attack += maxa;
			count++;
		}

		System.out.println(count);

		sc.close();

	}
}

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

int main() {
	int H;
	int W;

	cin >> H >> W;
	vector<string> strs(H);
	for (int i = 0; i < H; i++)
		cin >> strs.at(i);
	for (int i = 0; i < H; i++)
	{
		int count;

		count = 0;
		for (int j = 0; j < W; j++)
		{
			if (strs.at(i).at(j) == '.')
				count++;
		}
		if (count == W)
		{
			for (int j = 0; j < W; j++)
				strs.at(i).at(j) = 'N';
		}
	}
	for (int j = 0; j < W; j++)
	{
		int count;

		count = 0;
		for (int i = 0; i < H; i++)
		{
			if (strs.at(i).at(j) == '.' || strs.at(i).at(j) == 'N')
				count++;
		}
		if (count == H)
		{
			for (int i = 0; i < H; i++)
			{
				if (strs.at(i).at(j) == '.')
					strs.at(i).at(j) = 'N';
			}
		}
	}
	for (int i = 0; i < H; i++)
	{
		int count;

		count = 0;
		for (int j = 0; j < W; j++)
		{
			if (strs.at(i).at(j) != 'N')
			{
				cout << strs.at(i).at(j);
				count++;
			}
		}
		if (count != 0)
			cout << endl;
	}
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> elapsed(N - 1), start(N - 1), interval(N - 1);

    REP(i, N - 1) { cin >> elapsed[i] >> start[i] >> interval[i]; }

    REP(i, N - 1) {
        int current = start[i];
        current += elapsed[i];

        for (int j = i + 1; j < N - 1; j++) {
            current = max(current, start[j]);
            if (current % interval[j] > 0) current = (current - current % interval[j]) + interval[j];
            current += elapsed[j];
        }

        cout << current << endl;
    }

    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 384
from itertools import permutations
def read(): return list(map(int, input().split()))
 
 
INF = 114514810
 
 
def wf(d):
    N = len(d[0])
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    return d
 
 
def calc_dist(p, d):
    dist = 0
    for i in range(len(p) - 1):
        if d[p[i]][p[i + 1]] >= INF:
            return INF
        dist += d[p[i]][p[i + 1]]
    return dist
 
 
def main():
    N, M, R = read()
    r = map(lambda x: x - 1, sorted(read()))
    d = [[INF for i in range(N)] for j in range(N)]
 
    for i in range(M):
        a, b, c, = read()
        a -= 1
        b -= 1
        d[a][b] = d[b][a] = c
 
    d = wf(d)
 
    min_dist = INF
    for p in list(permutations(r)):
        min_dist = min(min_dist, calc_dist(p, d))
 
    print(min_dist)
 
 
if __name__ == '__main__':
    main()

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

int main() {
    string s;
    cin >> s;
    if(s.size() != 6) {
        cout << "No" << endl;
        return 0;
    }
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <string.h>
#include <cassert>
 
#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif
 
#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)
 
using namespace std;
typedef long long ll;
const int MODULO = 1000000007;
 
typedef pair<int,int> Pii;
// begin
 
int main()
{
	int n; 
	while(cin>>n,n){
		vector<int> s(n);
		FOR(i,n) cin>>s[i];
		sort(s.begin(),s.end());
		ll ans = 0;
		FOR(i,n) ans += s[i] * (n-i-1);
		cout << ans << endl;
	}

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main(){
int a;
int b;
int c;
while(cin >> a){
if(a!=0){b=1000-a;
c=0;
if(b>=500){b=b-500; c=c+1;}
if(b>=100){while(b>=100){b=b-100; c=c+1;}}
if(b>=50){b=b-50; c=c+1;}
if(b>=10){while(b>=10){b=b-10; c=c+1;}}
if(b>=5){b=b-5; c=c+1;}
c=b+c;
cout << c<<endl;
}
}
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

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

  for (int x = 0; x <= n; x++) {
    for (int y = 0; x + y <= n; y++) {
      int rest = yen - (10000 * x + 5000 * y);
      if (rest < 0)
	continue;
      int z = n - (x + y);
      if (rest != z * 1000)
	continue;

      cout << x << " " << y << " " << z << endl;
      return 0;
    }
  }

  cout << "-1 -1 -1" << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i,c,j,count=0,N;
        N=sc.nextInt();
        int[] array;
        array= new int[N];
        for(i=0;i<=N-1;i++){
            array[i]=sc.nextInt();
        }
        for(j=1;j<=N-1;j++){
            for(i=N-1;i>=j;i--){
                if(array[i]<array[i-1]){
                    c=array[i];
                    array[i]=array[i-1];
                    array[i-1]=c;
                    count++;
                }else{
                    continue;
                }
            }
        }
        for(i=0;i<N-1;i++){
            System.out.print(array[i]+" ");
        }
        System.out.println(array[N-1]+"\n"+count);
    }
}


Measured memory_bytes: 26208
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=3e5+5;

ll a[N],p[N],s[N];


int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
rep(i,1,n)cin>>a[i];
rep(i,1,n)p[i]=p[i-1]+a[i];
ren(i,n,1)s[i]=s[i+1]+a[i];

ll mn=abs(p[1]-s[2]);
rep(i,2,n-1)
{
	mn=min(mn,abs(p[i]-s[i+1]));
}
ol(mn);
return 0;
}



Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        string s;
        cin >> s;
        int ans = 0;
        for (int i = 0; i < 3; i++) {
            if (s[i] == 'S') continue;
            int j = i + 1;
            int len = 1;
            while (j < 3 && s[j] == 'R') {
                len++;
                j++;
            }
            ans = max(ans, len);
            i = j - 1;
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<ll,ll>

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,N)cout << g[i].size() << endl;
}

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

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	int N, T, A[100000], minA, ans = 0, s;
	cin >> N >> T;
	REP(i, N) {
		cin >> A[i];
	}

	minA = A[0];
	s = 0;
	REP(i, N) {
		minA = min(minA, A[i]);
		if (s < (A[i] - minA)) {
			s = A[i] - minA;
			ans = 1;
		}
		else if (s == A[i] - minA) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int arr[100005];
int cmp(int a,int b){
	return a<b;
}
int main(){
	int n;
	while(~getI(n)){
		F(i,0,n) getI(arr[i]);
		sort(arr,arr+n,cmp);
		int ans=0;
		F(i,1,100001){
			int cnt=lower_bound(arr,arr+n,i)-arr;
			if(cnt!=n&&cnt==n-cnt)ans++;
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 640