akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,cnt=0,s;
    double x;
    cin>>n>>m;
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a.at(i).at(j);
        }
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            s=0;
            for(int k=0;k<m;k++){
                s+=(a.at(i).at(k)-a.at(j).at(k))*(a.at(i).at(k)-a.at(j).at(k));    
            }
            x=sqrt(s);
            if(ceil(x)==floor(x)) cnt++;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 256
N,K = map(int,input().split())
p = list(map(int,input().split()))
x = []
for i in p:
    if i % 2 == 0:
        x.append(i//2 + 0.5)
    else:
        x.append(i // 2 + 1)

ans = 0
for i in range(K):
    ans += x[i]

ans_list = [ans]
if N != K:
    for i in range(K,N):
        ans_list.append(ans_list[len(ans_list)-1]+x[i]-x[i-K])
print(max(ans_list))


Measured memory_bytes: 25060
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0l);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//-----------------------------------------------------------------------------



int main() {
    srand(time(NULL));

    retry:
#ifdef LOCAL
    // gen();

    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    vector<int> a(n + 1);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        ans += a[a[i]] == i;
    }
    assert(ans % 2 == 0);
    cout << ans / 2 << endl;



    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int a,b,x; cin >> a >> b >> x;
    double y = 2.0 * x / (a*b);
    double tan;
    if(y<=a){
        tan = (double)a * b * b / (2.0*x);
    }else {
        double z = 2.0 * x / (a*a) - b;
        tan = (b-z) / a;
    }
    double ans = atan(tan) * 180.0 / M_PI;
    printf("%.10f\n", ans);
    return 0; 
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
using namespace std;
char s[51];
int n,k;
int main(){
	scanf("%d%d\n",&n,&k);
	scanf("%s",&s);
	for(register int i=0;i<strlen(s);i++){
		if(i!=k-1)putchar(s[i]);
		else putchar(s[i]+32);
	}
}

Measured memory_bytes: 128
def show(list1):
  for i in range(len(list1)):
    if i<len(list1)-1:
      print(list1[i],end=' ')
    else:
      print(list1[i])  # print() 默认以回车作为输入结束符

n = int(input()) # input()从标准输入读入一行文本
  
list1 = list(map(int,input().split()))  # str.split() 切割字符串返回list类型
  # map(f,list) 将函数f作用用list的每个元素，返回map类型，用list() 强制类型转换成list类型        

show(list1)

for i in range(1,n):
  key = list1[i]
  j = i-1
  while j>=0 and key<list1[j]:
    list1[j+1]=list1[j]
    j-=1
  list1[j+1] = key
  
  for i in range(n):
    if i<n-1:
      print(list1[i],end=' ')
    else:
      print(list1[i])


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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
static const int INF = 1LL<<61;

int p[1005], n, m, nn;
vector<int> gedo;

inline void cut(int *k) {
  if (m < *k) *k = 0;
}

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

  while (cin >> n >> m, n) {
    gedo.clear();
    for (int i = 0; i < n; ++i) {
      cin >> p[i];
    }

    for (int i = 0; i < n; ++i) {
      for (int j = i; j < n; ++j) {
        gedo.PB(p[i] + p[j]);
      }

      gedo.PB(p[i]);
    }
    gedo.PB(0);
    sort(gedo.begin(), gedo.end());
    gedo.erase(unique(gedo.begin(), gedo.end()), gedo.end());
    gedo.PB(INF);

    int ans = 0;
    for (int i = 0; i < gedo.size() - 1; ++i) {
      int l = 0, r = gedo.size() - 1, cur = gedo[i];

      while (1 <= r - l) {
        int j = (r + l) / 2, temp1 = cur + gedo[j], temp2 = cur + gedo[j + 1];
        cut(&temp1);
        cut(&temp2);
        ans = max(ans, temp1);

        if (temp1 != 0 && temp2 == 0) break;

        if (temp1 == 0) {
          r = j;
        } else {
          l = j + 1;
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 7064
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, d = nm()
    if (abs(b-a) <= d and abs(c-b) <= d) or abs(c-a) <= d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3696
#include <stdio.h>
#define NMAX 100

int selectionSort(int *,int);
int main(void){
  int N,i,inp[NMAX],cnt;

  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%d",&inp[i]);
  }

  cnt = selectionSort(inp,N);
  for(i = 0;i < N;i++){
    if(i == N - 1){
      printf("%d\n",inp[i]);
    }else{
      printf("%d ",inp[i]);
    }
  }
  printf("%d\n",cnt);

  return 0;
}

int selectionSort(int *A,int N){

  
  int i,j,x,temp,cnt = 0;
  for(i = 0;i < N;i++){
    x = i;
    for(j = i;j < N;j++){
      if(A[j] < A[x]){
	x = j;
      }
    }
    if(i != x){
      temp = A[i];
      A[i] = A[x];
      A[x] = temp;
      cnt++;
    }
  }
  return cnt;
}



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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M, P;
    cin >> N >> M >> P;
    ll Ai, Bi, Ci;
    vector<array<ll,3>> edges;
    for(int i=0;i<M;i++){
        cin >> Ai >> Bi >> Ci;
        Ai--; Bi--;
        edges.push_back(array<ll,3>{Ai, Bi, Ci});
    }

    std::vector<ll> d(N, numeric_limits<ll>::max());
    std::vector<ll> prev(N, numeric_limits<ll>::max());
    set<ll> used;

    d[0] = 0;

    for(size_t i=0; i<N; i++){
        for(size_t j=0; j<M; j++){
            auto e = edges[j];
            if(d[e[0]] == numeric_limits<ll>::max()) continue;
            if(d[e[1]] > d[e[0]] + (P - e[2])){
                d[e[1]] = d[e[0]] + (P - e[2]);
                prev[e[1]] = e[0];
            }
        }
    }
    set<ll> loopedNode;
    for(size_t j=0; j<M; j++){
        auto e = edges[j];
        if(d[e[0]] == numeric_limits<ll>::max()) continue;
        if(d[e[0]] + (P-e[2]) < d[e[1]]){
            loopedNode.insert(e[0]);
            loopedNode.insert(e[1]);
        }
    }
    bool isGood = true;
    auto node = N-1;
    while(true){
        if(loopedNode.count(node)){
            isGood = false;
            break;
        }
        node = prev[node];
        if(node==0) break;
    }
    if(loopedNode.count(N-1)) isGood = false;
    if(loopedNode.count(0)) isGood = false;
    if(!isGood){
        cout<<-1<<endl;
    }else{
        cout<<max((ll)0, -d[N-1])<<endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long

ll gcd(ll a, ll b) {
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

ll lcm(ll number1, ll number2) {
	return number1 * (number2 / gcd(number1, number2));
}

int main() {
	ll n, b = 1;
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		b = lcm(a, b);

	}
	cout << b << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }



ll calc(ll A) {
    if (A < 0) return 0;

    A++;
    // 10^12 <= 2進数 40桁くらい
    ll ans = 0;
    for (int i=0;i<50;++i) {
        // 0桁目 : 周期2 
        // 0桁目 : 周期4 
        // 0桁目 : 周期8 
        ll loop = (1LL << (i + 1));
        ll cnt = (A / loop) * (loop / 2);
        // 00000....0011111..11
        cnt += max(0LL, (A % loop) - (loop / 2));
        // その桁の1の数が奇数だったら足し算
        if (cnt % 2 == 1) ans += 1LL << i;
    }

    return ans;
}

int main(){
    ll A, B;
    cin >> A >> B;

    ll ans = calc(B) ^ calc(A - 1);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

struct ed {
  ll node;
  pll cost;
};

vector<ed> edge[MAX];
ll st, t;
vll ss, tt;

void bfs1() {
  queue<ll> que;

  que.push(st);
  while (!que.empty()) {
	tmp = que.front();
	que.pop();
	rep(i,edge[tmp].size()) {
	  ll k = edge[tmp][i].node;
	  if (ss[k] >  ss[tmp] + edge[tmp][i].cost.first) {
		que.push(k);
		ss[k] = ss[tmp] + edge[tmp][i].cost.first;
	  }
	}
  }
}

void bfs2() {
  queue<ll> que;

  que.push(t);
  while (!que.empty()) {
	tmp = que.front();
	que.pop();
	rep(i, edge[tmp].size()) {
	  ll k = edge[tmp][i].node;
	  if (tt[k] > tt[tmp] + edge[tmp][i].cost.second) {
		que.push(k);
		tt[k] = tt[tmp] + edge[tmp][i].cost.second;
	  }
	}
  }

}

int main(void) {
  cin >> n >> m >> st >> t;
  rep(i, m) {
	ll u, v, a, b;
	cin >> u >> v >> a >> b;
	ed e; e.node = v; e.cost = pll(a, b);
	edge[u].pb(e);
	e.node = u;
	edge[v].pb(e);
  }
  ss.resize(n + 1, inf);
  tt.resize(n + 1, inf);
  ss[st] = 0;
  bfs1();
  tt[t] = 0;
  bfs2();

  vll anss(n + 2, inf);
  RFOR(i, 1, n + 1) {
	anss[i] = min(anss[i + 1], ss[i] + tt[i]);
	//cout << anss[i] << endl;
  }

  FOR(i, 1, n + 1) cout << 1000000000000000 - anss[i] << endl;

  return 0;
}

Measured memory_bytes: 13864
#include<iostream>
//#include <algorithm>
#include <map>
using namespace std;

int main()
{
    unsigned long long n,q,b,c;
    map <int,int> m;

    cin >> n;
    unsigned long long sum = 0;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        m[x]++;
        sum += x;
    }


    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> b >> c;
        if(!m[b]) cout << sum << "\n";
        else{
            sum = (sum - (b*m[b]) - (c*m[c]));
            m[c] += m[b];
            sum = (sum + (c*m[c]));
            m[b] = 0;
            cout << sum << "\n";
        }
    }
    //for(auto x : m) cout << x.first << " " << x.second << endl;

    return 0;
}


Measured memory_bytes: 7844
import sys
def input(): return sys.stdin.readline().strip()

i  = lambda: int(input())
ms = lambda: map(str, input().split())

N = i()

rank = dict()
for i in range(N):
  S, P = ms()
  if S in rank.keys():
    rank[S][i+1] = int(P)
  else:
    rank[S] = {i+1: int(P)}

for k, v in sorted(rank.items()):
  for vk, vv in sorted(rank[k].items(), key=lambda x:x[1], reverse=True):
    print(vk)

Measured memory_bytes: 3064
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

// x + y = (x ^ y) + (x & y) << 1;
// x = y, y = x ^ y

// y + (x ^ y) = (y ^ (x ^ y)) + (y & (x ^ y)) << 1
//             = x + (y & ~x) << 1

// 19 127
// 108 127 127
// 19 127 127 127

int main(){
  const int t = getInt();

  REP(_,t) {
    const int n = getInt();
    const int d = getInt();

    printf("%d\n", 127 * (n - 1) + (n % 2 == 0 ? 127 - d : d));
  }

  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(n, m, s, p):
    ret = 0
    #print(s)
    #print(p)
    count = 0
    for bits in range(2 ** n):
        ok = True
        for j in range(m):
            count = 0
            for i in s[j]:
                if (bits & (1 << (i - 1))) > 0:
                    count += 1
            #        print(count)
            #        print('jk')
            #    print(bits, j, count)
            #print('--- count : ', count, j, p[j])
            #print(bits, j, count, p[j])
            if count % 2 != p[j]:
                ok = False
                break
        #print(bits)
        #print(ok)
        #print()
        if ok:
            ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [[] for _ in range(M)]
    for i in range(M):
        n = int(next(tokens))
        for j in range(n):
            s[i].append(int(next(tokens)))
    p = []
    for i in range(M):
        p.append(int(next(tokens)))
    solve(N, M, s, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(1000000)
import numpy as np 
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
  u, v = map(lambda x: int(x)-1, input().split())
  g[u] += [v]
  g[v] += [u]

col = [0]*n 
def dfs(u, c):
  col[u] = c 
  for v in g[u]:
    if col[v] == c:
      return False
    if (col[v] == 0 and not dfs(v, -c)):
      return False

  return True


if dfs(0, 1):
  col = np.array(col)
  b = len(col[col==1])
  w = len(col) - b
  print(b*w-m)
else:
  print(n*(n-1)//2-m)

Measured memory_bytes: 40044
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<ll> x(N), y(M);
    for (ll i = 0; i < N; i++) {
        cin >> x[i];
    }
    for (ll i = 0; i < M; i++) {
        cin >> y[i];
    }

    if (X >= Y) {
        cout << "War" << endl;
    } else {
        ll x_max = *max_element(x.begin(), x.end());
        x_max = max(x_max, X);
        ll y_min = *min_element(y.begin(), y.end());
        y_min = min(y_min, Y);
        if (x_max < y_min) {
            cout << "No War" << endl;
        } else {
            cout << "War" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

using namespace std;
int main(){
  char b;
  cin >> b;
  if(b == 'A') cout << "T" << endl;
  else if(b == 'C') cout << "G" << endl;
  else if(b == 'G') cout << "C" << endl;
  else cout << "A" << endl;

}


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

int main()
{
    int x,i;
    i=0;
    while (1>0)
    {
        x=0;
        cin>>x;
        if (x==0) return 0;
        cout<<"Case "<<++i<<": "<<x<<endl;
    }
}



Measured memory_bytes: 3000
n,a,b=map(int,raw_input().split())
h=[int(raw_input()) for _ in xrange(n)]
l=0
r=10**12
while r-l>1:
    m=(r+l)/2
    c=a-b
    cnt=0
    for i in xrange(n):
        if h[i]-b*m<0:continue
        if (h[i]-b*m)%c==0:
            cnt+=(h[i]-b*m)/c
        else:
            cnt+=(h[i]-b*m)/c+1
    if cnt<=m:
        r=m
    else:
        l=m
print r


Measured memory_bytes: 34332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<vector<int64_t>> G(N,vector<int64_t>(0));
  for(int i=0; i<N-1; i++){
    int64_t a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int64_t ans = 0;
  vector<int64_t> cnt(N+1,0);
  for(int64_t i=0; i<N; i++){
    ans += cnt[i] + (i+1);
    int64_t num = 0;
    sort(G[i].begin(),G[i].end());
    for(int64_t j=0; j<G[i].size(); j++){
      if(G[i][j] < i){
        num += G[i][j]+1;
      }
    }
    ans -= num;
    cnt[i+1] = cnt[i] + (i+1) - num;
  }
  cout << ans << endl;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;cin>>s;
  int mode=0;
  int i;
  int ans=0;
  rep(i,s.size())
  {
    if(mode==0&&s[i]=='A')
    {
      ans++;
      mode=1;
    }
    else if(mode==1&&s[i]=='Z')
    {
      ans++;
      mode=0;
    }
  }
  ans=ans/2*2;
  if(ans==0)cout<<-1<<endl;
  else
  {
    rep(i,ans)
    {
      if(i%2==0)cout<<'A';
      else cout<<'Z';
    }
    cout<<endl;
  }
}




Measured memory_bytes: 3208
N,Y = map(int,input().split())
Judge = False
for i in range(N+1):
  for j in range(N-i+1):
    if 10000*i + 5000*j + 1000*(N-i-j) == Y:
      Judge = True
      ans = [i,j,N-i-j]
if not Judge:
  print('-1 -1 -1')
else:
  print(ans[0],ans[1],ans[2])


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

double dist(P p1, P p2){
  double dx = p1.first - p2.first;
  double dy = p1.second - p2.second;
  return sqrt(dx*dx+dy*dy);
}

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

  vector<P> p(n);
  vector<int> a(n);
  rep(i, n){
    int x, y;
    cin >> x >> y;
    p[i] = P(x, y);
    a[i] = i;
  }

  double d[n][n];
  rep(i, n){
    for(int j = i; j < n; j++){
      if(i == j){
        d[i][j] = 0;
      }else{
        d[i][j] = dist(p[i], p[j]);
        d[j][i] = d[i][j];
      }
    }
  }

  double ans = 0;
  int m = 0;
  do{
    rep(i, n-1){
      ans += d[a[i]][a[i+1]];
    }
    m++;
  }while(next_permutation(a.begin(), a.end()));
  
  cout << fixed << setprecision(10) << ans / m << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	a := ReadInts(N)
	s := 0
	ss := 0
	for i := 0; i < N; i++ {
		s += a[i]
		ss += a[i] * a[i]
	}
	min := 1 << 60
	for i := -100; i <= 100; i++ {
		v := N*i*i - 2*s*i + ss
		if v < min {
			min = v
		}
	}
	fmt.Println(min)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

namespace ConsoleApp15
{
    class Class79
    {
        static void Main()
        {
            long[] XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long X = XY[0], Y = XY[1];
            long a = X;
            int count = 0;
            while (a <= Y)
            {
                a *= 2;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <queue>
#include <map>
using namespace std;
int main(void) {
  long long n, a;
  map<long long, bool> used;
  priority_queue<long long> que;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (used[a]) {
      used[a] = false;
      que.push(a);
    } else {
      used[a] = true;
    }
  }

  if (que.size() < 2) {
    cout << 0 << endl;
    return 0;
  }

  long long x = que.top(); que.pop();
  long long y = que.top();
  cout << x * y << endl;

  return 0;
}


Measured memory_bytes: 6528
from itertools import product

n = int(input())
P = [0, 0] + [int(i) for i in input().split()]
X = [0] + [int(i) for i in input().split()]

C = [[] for i in range (n+1)]

for i, p in enumerate(P):
    C[p].append(i)

def dfs(i):
    if not C[i]:
        return X[i], 0

    A = []
    
    for c in C[i]:
        A.append(dfs(c))

    S = 0
    for a in A:
        S += sum(a)

    dp = [[False]*(X[i]+1) for j in range(len(A)+1)]
    dp[0][0] = True

    for j in range(len(A)):
        for k in range(X[i]+1):
            a, b = A[j]
            if a <= k and dp[j][k-a]:
                dp[j+1][k] = True
            elif b <= k and dp[j][k-b]:
                dp[j+1][k] = True
        if not any(dp[j+1]):
            print('IMPOSSIBLE')
            exit()

    b = 0
    for j in range(X[i], -1, -1):
        if dp[len(A)][j]:
            b = j
            break

    return X[i], S - b

dfs(1)
print('POSSIBLE')

Measured memory_bytes: 5184
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;

int main()
{
	int n,m;
	int a[1005];
	cin >> n >> m;
	int sum=0;
	float k;
	for (int i=0; i<n; i++) 
	{
		cin >> a[i];
		sum+=a[i];
	}
	k=(float)sum/(4*m);
	int count=0;
	for (int i=0; i<n; i++)
		if ((float)a[i] >= k) count++;
	if (count >= m) cout <<"Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 384
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse = True)
if N == 3:
  print(a[0] + a[1])
ans1 = 2*sum(a[0:N//2]) - a[0]
if N%2 == 0:
  print(ans1)
if N%2 == 1 and N != 3:
  print(ans1 + a[N//2])

Measured memory_bytes: 31712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){
    if(a>b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 *
 * */

int main() {

    int A, B, T;
    cin >> A >> B >> T;

    int count = 0;
    for (int i = 1; i <= 20; ++i) {
        if(i*A > T) break;
        count += B;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    priority_queue<int> pq;
    ll sum = 0;
    REP(i,N){
        ll a;
        cin >> a;
        sum += a;
        pq.push(a);
    }
    REP(i,M){
        ll tmp = pq.top(); pq.pop();
        sum -= tmp;
        tmp /= 2;
        sum += tmp;
        pq.push(tmp);
    }
    cout << sum << endl;

}


Measured memory_bytes: 892
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, e, s, t = MAP()
s-= 1
t-= 1    
G1 = [[]for i in range(n)]
G2 = [[]for i in range(n)]       

for i in range(e):
    fr, to, w1, w2 = MAP()
    G1[fr-1].append((w1, to -1))
    G1[to-1].append((w1, fr -1))
    G2[fr-1].append((w2, to -1))
    G2[to-1].append((w2, fr -1))


def djkstra(s,G):
    visited = [False]*n     #その頂点を確定したかどうか
    d = [INF]*n
    que = []
    heapq.heapify(que)
    heapq.heappush(que, (0,s))

    while(len(que)>0):
        vs = heapq.heappop(que)
        distance = vs[0]
        vertex = vs[1]
        if visited[vertex]:
            continue
        d[vertex] = distance
        visited[vertex] = True
        for Gs in G[vertex]:
            if d[Gs[1]] <= distance+Gs[0]:
                continue
            heapq.heappush(que,(distance+Gs[0], Gs[1]))
    
    return d

d_yen = djkstra(s,G1)
d_snuuk = djkstra(t,G2)

d_sum = [0]*n

for i in range(n):
    d_sum[i] = d_yen[i] + d_snuuk[i]

d_sum.reverse()
d_ans = [0]*n
d_ans[0] = d_sum[0]
for i in range(1,n):
    d_ans[i] = min(d_ans[i-1],d_sum[i])

for i in range(n-1,-1,-1):
    print(10**15 - d_ans[i])



Measured memory_bytes: 123864
# -*- coding: utf-8 -*-
import sys

#読み込み
n = int(input())

strs = []

for i in range(n):
    strs.append(input())

#文字列の確認
str_in_num = 0
str_both_ab = 0
str_head_a = 0
str_tail_b = 0

for st in strs:
    #文字列中にABを含むもの
    #print(st)
    if len(st) > 2:
        str_in_num += st[0:-1].count('AB')

    #文字列の先頭がBのもの
    if st[-1] == 'A' and st[0] == 'B':
        str_both_ab += 1
    else:
        if st[-1] == 'A':
            str_head_a += 1

        if st[0] == 'B':
            str_tail_b += 1

total = 0

if str_both_ab > 0:
    total += (str_both_ab - 1)

    if str_head_a > 0:
        total += 1
        str_head_a -= 1
    if str_tail_b > 0:
        total += 1
        str_tail_b -= 1

total += str_in_num
total += min(str_head_a, str_tail_b)

print(total)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    ios
    int n,k,x,y;
    cin>>n>>k;

    vector<pii> v;
    for(int i=1;i<=k;i++)
    {
        cin>>x>>y;
        v.pb(make_pair(y,x));
    }
    sort(all(v));
    
    int cnt=0,key=0;
    for(int i=0;i<k;i++)
    {
        x=v[i].first;
        y=v[i].second;

        if(y>key)
        {
            cnt++;
            key=x-1;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 2420
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <set>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18

int main()
{
    int N; cin >> N;
    set<string> S;
    for (int i=1; i<=N; i++) {
        string temp; cin >> temp;
        S.insert(temp);
    }
    cout << S.size() << endl;
}


Measured memory_bytes: 19252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n, k;
  cin >> n >> k;
  vector<bool> s(n, false);
  rep(i,k){
    ll d;
    cin >> d;
    rep(j,d){
      ll a;
      cin >> a;
      s[a - 1] = true;
    }
  }
  ll count = 0;
  rep(i, n){
    if(s[i]==false){
      count++;
    }
  }
  print(count);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i=0; i<n-1; i++){
        if (a[i] == a[i+1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 20:56:20 2020

@author: Kanaru Sato
"""
import collections

n,m = list(map(int,input().split()))
connected = [[]for i in range(n+1)]
for i in range(m):
    a,b = list(map(int,input().split()))
    connected[a].append(b)
    connected[b].append(a)

distance = [-1,0]
for i in range(n-1):
    distance.append(-1)

ans = [-1 for i in range(n+1)]
ans[1] = 1

q = [1]
q = collections.deque(q)

while q:
    cp = q.popleft()
    for np in connected[cp]:
        if ans[np] == -1 or distance[ans[np]] > distance[cp]:
            q.append(np)
            ans[np] = cp
            distance[np] = distance[cp] + 1

print("Yes")
for i in range(n-1):
    print(ans[i+2])

Measured memory_bytes: 35108
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s, ss;
    cin >> s >> ss;

    bool f = true;

    for (int i = 0; i < 3; i++)
        if (s[i] != ss[2 - i]) f = false;

    cout << (f ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

class UnionFind{
public:
	vector<int> par;
	//0-indexed
	UnionFind(int n){init(n);}
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		else par[x] = y;
	}
	int setsize(){
		set<int> se;
		for(auto x:par){
			se.insert(root(x));
		}
		return se.size();
	}
};

int main(){
	ll N;
	cin >> N;
	vector<ll> x(N),y(N);
	FOR(i,0,N)cin>>x[i]>>y[i];
	UnionFind uf(N+1);
	map<ll,ll> ux,uy;
	FOR(i,0,N){
		if(ux[x[i]]!=0){
			uf.unite(ux[x[i]],i+1);
		}else{
			ux[x[i]] = i+1;
		}
		if(uy[y[i]]!=0){
			uf.unite(uy[y[i]],i+1);
		}else{
			uy[y[i]] = i+1;
		}
	}

	set<ll> lx[N+1],ly[N+1];
	FOR(i,0,N){
		lx[uf.root(i+1)].insert(x[i]);
		ly[uf.root(i+1)].insert(y[i]);
	}
	ll ans = 0;
	FOR(i,0,N+1){
		ans += lx[i].size()*ly[i].size();
	}
	cout << ans - N << endl;
}



Measured memory_bytes: 22528
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;

int main(){
while(1){
  int N;
  scanf("%d", &N);
  if(N==0)break;
  int dp[1<<N];
  for(int i=0;i<(1<<N);i++){
    dp[i]=inf;
  }
  int t[N][N+1];
  for(int i=0;i<N;i++)for(int j=0;j<=N;j++){
    scanf("%d", &t[i][j]);
  }
  dp[0] = 0;
  for(int i=1;i<(1<<N);i++){
    for(int j=0;j<N;j++){
      if((i&(1<<j))!=0){
        int tmp = i - (1<<j);
        dp[i]=min(dp[i], dp[tmp]+t[j][0]);
        for(int k=0;k<N;k++)if((tmp & (1<<k))!=0){
          dp[i] = min(dp[i], dp[tmp] + t[j][k+1]);
        }
      }
    }
  }
printf("%d\n", dp[(1<<N)-1]);
}

  return 0;
}



Measured memory_bytes: 3424
n = gets.to_i
arr = []
n.times do |i|
  s, pt = gets.split
  pt = pt.to_i
  arr << [s, pt, i+1]
end

ans = []
n.times do |i|
  injection = arr[i]
  if i == 0
    ans.push(injection)
    next
  end
  
  i.times do |k|
    if k == (i - 1)
      if ans[k][0] < injection[0]
        ans.push(injection)
        break
      else
        if ans[k][0] > injection[0]
          ans.insert(k, injection)
          break
        else
          if ans[k][1] > injection[1]
            ans.push(injection)
            break
          else
            ans.insert(k, injection)
            break
          end
        end
      end
      
      
    end

    next if ans[k][0] < injection[0]
    if ans[k][0] == injection[0]
      next if ans[k][1] > injection[1]
      if ans[k][1] < injection[1]
        ans.insert(k, injection)
        break
      end
    end
    ans.insert(k, injection)
    break
  end
end

puts ans.map{|arr| arr[2] }

Measured memory_bytes: 1788
N, D = map(int, input().split())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())
ans = 0
for i in range(N):
    if (x[i]) ** 2 + (y[i]) ** 2 <= D ** 2:
        ans += 1

print(ans)


Measured memory_bytes: 24708
s = input()
k = int(input())

n = len(s)
cnt = 1
arr = []

for i in range(n):
    try:
        if s[i] == s[i+1]: cnt += 1
        else: arr.append(cnt) ; cnt = 1
    except: arr.append(cnt)

if len(arr) == 1 : ans = (len(s)*k)//2
else:
    if s[0] == s[n-1] : arr[0],arr[len(arr)-1] = 0,arr[0]+arr[len(arr)-1]
    ans = 0
    for i in range(len(arr)): ans += arr[i]//2
    ans *= k
    if arr[0]==0 and arr[len(arr)-1]%2==0 : ans -= 1

print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    ll x,y;
    cin>>x>>y;
    ll ans=1;
    while(x*2<=y){
        x*=2;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include <queue>
#include<algorithm>
#include <bitset>
#include <math.h>
#include <numeric>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 10000000000000


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

template<class T>
bool inline ChangeMinimum( T &a, T b )
{
	if( a > b ){
		a = b;
		return true;
	}
	return false;
}

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

template<class T>
class Vec3
{
	public:
		T act[3];
};

int Stair( int now, vector<ll> &H )
{
	if( H[now] >= H[now+1] ){}
	
}

int main(void) {
	
	int N;
	inp(N);
	string S;
	inp(S);

	vector<vector<int>> dp(N+1,vector<int>(N+1));
	rep(i,N+1)rep(j,N+1){
		dp[i][j] = 0;
	}

	for(int i=N-1; i>=0; i--){
		for(int j=N-1; j>=0; j--){
			if(S[i]==S[j]) dp[i][j] = min( abs(i-j),dp[i+1][j+1]+1);
		}
	}
	int max = 0;
	rep(i,N){
		rep(j,N){
			if(max<dp[i][j]) max = dp[i][j];
		}
	}
	out(max);
}

Measured memory_bytes: 98176
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
using ll = long long;
int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<ll,vector<ll>,less<ll>> q;
  for(int i=0;i<n;i++){
    ll a;
    cin >> a;
    q.push(a);
  }

  for(int i=0;i<m;i++){
    ll v = q.top();
    q.pop();
    q.push(v/2);
  }

  ll sum = 0;
  for(int i=0;i<n;i++){
    ll v = q.top();
    q.pop();
    sum += v;
  }

  cout << sum << endl;
}


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

int main(){
  int c[1000][1000],i,j,k,l,m;

  for(i=0;i<3;i++){
    for(j=0;j<6;j++){
      cin >> c[i][j];
    }
  }

  for(i=0;i<3;i++){
    
    for(j=5;j>=3;j--){
      
      if(c[i][j]<c[i][j-3] && c[i][j-1]==0){
	c[i][j-2]-=1;
	c[i][j-1]=59;
	c[i][j]=(60+c[i][j])-c[i][j-3];
      }
      else if(c[i][j]<c[i][j-3]){
	c[i][j-1]-=1;
	c[i][j]=(60+c[i][j])-c[i][j-3];
      }
      else{
	c[i][j]-=c[i][j-3];
      }
      
    }
    
  }
  
  for(i=0;i<3;i++){
    printf("%d %d %d\n",c[i][3],c[i][4],c[i][5]);
  }
  

}

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

int main()
{
  int i,j,N,minj,sub,count = 0;
  int *array;

  scanf("%d",&N);
  array = (int *)malloc(sizeof(int) * N);
  if(array == NULL) exit(0);

  for(i = 0;i < N;i++){
    scanf("%d",&array[i]);
  }

  for(i = 0;i < N;i++){
    minj = i;
    for(j = i;j < N;j++){
      if(array[j] < array[minj]) minj = j;
    }
    sub = array[minj];
    array[minj] = array[i];
    array[i] = sub;
    if(array[i] != array[minj]) count++;
  }

  for(i = 0;i < N;i++){
    printf("%d",array[i]);
    if(i != N-1) printf(" ");
  }

  printf("\n");
  printf("%d\n",count);

  free(array);

  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
 int i, c;
 printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

 if(T[u].p==NIL) printf("root, ");//
 else if(T[u].l==NIL) printf("leaf, ");//
 else printf("internal node, ");

 printf("[");
 for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
   if(i) printf(", ");
   printf("%d", c);
 }
 printf("]\n");

}

void calcDepth(int u, int p){//root 0
 D[u] = p;
 if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
 if(T[u].r!=NIL) calcDepth(T[u].r,p);//
}

int main(){
 int i, j, k;
 int n;
 int id, sib, child;
 int root = NIL;
 scanf("%d", &n);
 for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

 for(i=0; i<n; i++){
   scanf("%d %d", &id, &k);
   for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
     scanf("%d", &child);
     T[child].p = id;
     if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
     else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
     sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
   }
 }

 //根を求める (find the root)
 for(i=0; i<n; i++){
   if(T[i].p == -1) root = i;
 }

 //それぞれのノードの深さを求める (find depth of each node)
 calcDepth(root, 0);

 //出力 (output)
 for(i=0; i<n; i++) print(i);

 return 0;
}



Measured memory_bytes: 3360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define pll pair<long long, long long>
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll dx[] = {1,-1,0,0};
ll dy[] = {0,0,1,-1};
const ll sz = 3e5+5,mod = 998244353;
ll t,n,m,k;
vector<ll> p(sz),sp(sz),fac(sz);

const ll lim = 1e18;
const ll inf = 1e15;

ll Power(ll a, ll b)
{
    if(a==0)
        return 0;
    if(b==0)
        return 1;
    ll ans=Power((a*a)%mod,b/2);
    if(b&1)
        return (a*ans)%mod;
    return ans%mod;
}
ll Inv(ll a)
{
    return Power(a,mod-2);
}


int main()
{
    FIO
    ll Max = 0;
    cin>>n>>m;
    vector<ll> v(m);
    for(int i=0;i<m;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<m;i++)
    {
        ll j = (i+1)%m;
        ll tmp = 0;
        if(v[j] < v[i])
           tmp += v[j]+n-v[i];
        else
            tmp += v[j]-v[i];

        Max = max(Max,tmp);
    }
    cout<<n-Max;

}


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

using namespace std;
using ll = long long;

int main() {
	int H, W;
	cin >> H >> W;
	int h, w;
	cin >> h >> w;

	int res = (H * W) - (h * W) - (w * H) + (h * w);
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
n,k,c= map(int,input().split())
s = input()
i = 0

def func(s,k,c):
  i = 0
  res = []
  while 1:
    if s[i] == 'o':
      res.append(i)
      if len(res)== k:
        break
      i += c
    i+= 1
  return res
ans1 = func(s,k,c)
ans2 = func(s[::-1],k,c)
ans2 = [n-a-1 for a in ans2]
ans2 = ans2[::-1]

for i in range(k):
  if ans1[i]==ans2[i]:
    print(ans1[i]+1)




Measured memory_bytes: 27496
#include<cstdio>
char S[110];
int K;
int main(){
	scanf("%s%d",S,&K);
	int ans=0,fir=0,la=0;
	bool same=1;
	for(int i=0,j=0;S[i];i=j){
		for(;S[j]==S[i];j++);
		ans+=(j-i)/2;
		if(!i&&!S[j]){
			printf("%lld\n",1ll*j*K/2);
			return 0;
		}
		if(!i)fir=j-i;
		if(!S[j])la=j-i,same=S[0]==S[j-1];
	}
	if(same)printf("%lld\n",ans*1ll*K+((fir+la)/2-fir/2-la/2)*(K-1ll));
	else printf("%lld\n",ans*1ll*K);
}

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

int main() {
    int n, k;
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2) {
        cout << -1 << endl;
    } else {
        vector<pair<int, int>> ans;
        for (int i = 1; i <= n - 1; i++) {
            ans.push_back({i, n});
        }
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i + 1; j <= n - 1; j++) {
                ans.push_back({i, j});
            }
        }
        int num = n - 1 + (n - 1) * (n - 2) / 2 - k;
        cout << num << endl;
        for (int i = 0; i < num; i++) {
            cout << ans[i].first << ' ' << ans[i].second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
//#define SAMPLE 1000000
using namespace std;
//using P=pair<int,int>;
//using M=map<int,int>;
//using ll=long long;
 
int main(){
    int n; 
    cin >> n;
    vector<int> A(n);
    int64_t sum=0;
    bitset<4000009> dp;
    dp.set(0,1);

    for(int i=0;i<n;i++){
        cin>>A.at(i);
        sum+=A.at(i);
        dp |= (dp<<A[i]);//先にシフト演算しておいて問題はない。
    }

    int64_t odd = sum%2;
    int64_t key=sum/2 + odd;

    for(int i=key;i<4000009;i++){
        if(dp.test(i)){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 1792
a,b = map(int,input().split())
li1 = [input() for i in range(a)]
li2 = [input() for i in range(b)]
#print(li1,li2)
for i in range(a-b+1):
    for j in range(a-b+1):
        flag = True
        for k in range(b):
            if li1[i+k][j:j+b] != li2[k]:
                flag = False
                break
        if flag:
            print("Yes")
            exit()
print("No")


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

using namespace std;

static const int N = 55;

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

    const int di[] = {-1, 1, 0, 0};
    const int dj[] = {0, 0, -1, 1};

    int h, w;
    string s[N];
    bool can = true;
    cin >> h >> w;

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

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
            {
                bool can2 = false;
                for (int k = 0; k < 4; k++)
                {
                    const int si = i + di[k];
                    if (si < 0 || si > h - 1)
                        continue;
                    const int sj = j + dj[k];
                    if (sj < 0 || sj > w - 1)
                        continue;
                    if (s[si][sj] == '#')
                    {
                        can2 = true;
                        break;
                    }
                }
                if (!can2)
                    can = false;
            }
            if (!can)
                break;
        }
        if (!can)
            break;
    }

    if(can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> mat(h,vector<char>(w));
	vector<int> row(h,0),col(w);
    for(int i = 0; i < h; i++){
		for(int j = 0;j<w;j++){
			cin >> mat[i][j];
			if (mat[i][j] == '#'){
				col[j]++;
				row[i]++;
			}
		}
	}
	for(int i = 0; i<h;i++){
		if(row[i]==0) continue;
		for(int j = 0; j<w;j++){
			if(col[j]!=0) cout << mat[i][j];
		}
		cout << endl;
	}
			
}


Measured memory_bytes: 256