akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

UnionFind uni(110000);
ll n, a[110000], b[110000], sa[110000], sb[110000], ans, a1;
vector<ll> xl[110000], yl[110000];
set<ll> xs[110000], ys[110000];
bool ok[110000];
int main() {
	cin >> n;
	REP(i, n) {
		cin >> sa[i] >> sb[i];
		a[sa[i]]++;
		b[sb[i]]++;
		xl[sa[i]].push_back(i);
		yl[sb[i]].push_back(i);
	}
	REP(i, 110000) {
		REP(j, (ll)xl[i].size() - 1) {
			uni.unionSet(xl[i][j], xl[i][j + 1]);
		}
	}
	REP(i, 110000) {
		REP(j, (ll)yl[i].size() - 1) {
			uni.unionSet(yl[i][j], yl[i][j + 1]);
		}
	}
	
	REP(i, n) {
		if (a[sa[i]] >= 2 and b[sb[i]] >= 2) {
			ok[uni.root(i)] = true;
		}
	}
	REP(i, n) {
		if (ok[uni.root(i)]) {
			ans++;
			xs[uni.root(i)].insert(sa[i]);
			ys[uni.root(i)].insert(sb[i]);
		}
	}
	REP(i, n) {
		if (ok[uni.root(i)] and uni.root(i) == i) {
			a1 += xs[i].size() * ys[i].size();
		}
	}
	if (!ok) {
		cout << 0 << endl;
		return 0;
	}
	
	cout << a1 - ans << endl;
}	


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

int main(){
  
  int N;
  cin >> N;
  
  bool judge = false;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
  if(7 * i + 4 * j == N){
    judge = true;
  }
    }
  }
  
  if(judge){
  cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


  
  
    
    
    
    
    

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	string S;
	cin >> N >> S;
	if(N < 3200) {
		cout << "red" << endl;
	}
	else {
		cout << S << endl;
	}
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define MAXN 1000000
#define int long long
#define Angel ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int n,a[MAXN],dp[MAXN];
main(){
	Angel
	cin >> n;
	for(int i = 0; i<n; i++) cin >> a[i];
	dp[0] = 0, dp[1] = abs(a[1]-a[0]);
	if(sizeof(a)==2) cout << dp[1] << '\n';
	else{
		for(int i = 2; i<n; i++){
			dp[i] = min( dp[i-2] + abs(a[i]-a[i-2]) , dp[i-1] + abs(a[i]-a[i-1]) );
		}
	} 
	cout << dp[n-1] << '\n';
}

Measured memory_bytes: 5120
X = int(input())

if X >= 400 and X <= 599:
    print(8)
elif X >= 600 and X <= 799:
    print(7)
elif X >= 800 and X <= 999:
    print(6)
elif X >= 1000 and X <= 1199:
    print(5)
elif X >= 1200 and X <= 1399:
    print(4)
elif X >= 1400 and X <= 1599:
    print(3)
elif X >= 1600 and X <= 1799:
    print(2)
elif X >= 1800 and X <= 1999:
    print(1)


Measured memory_bytes: 9184
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var A = input[0];
            var B = input[1];
            var C = input[2];
            if (A[A.Length - 1] == B[0] && B[B.Length - 1] == C[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            
        }
    }
}

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

int32_t main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t; cin>>s;
                cin>>t; int ct=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i]){ct++;}
    }
	cout<<ct;
}


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

typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) rep(i, b) cout << a;
    else rep(i, a) cout << b;
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    ll N, M;
    ll ans = 0;
    cin >> N >> M;
    vector<ll> X(M);
    vector<ll> XD(M-1,0);
    
    rep(i, 0, M){
        cin >> X[i];
    }
    sort(X.begin(), X.end());
    rep(i, 0, M-1){
        ll tmp = X[i+1]-X[i];
        XD[i] = tmp;
    }
    sort(XD.begin(), XD.end());
    rep(i, 0, M-N){
        ans += XD[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    long long N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    
    vector<long long> ZO;
    ZO.push_back(0);
    for (int i=0; i<N; i++) {
        if (i==0) {
            if (S[i]=='0') {
                ZO.push_back(1);
            }
            else{
                ZO[0]++;
            }
            continue;
        }
        
        if (S[i-1]==S[i]) {
            ZO[ZO.size()-1]++;
        }
        else{
            ZO.push_back(1);
        }
    }
    if (S[S.size()-1]=='0') {
        ZO.push_back(0);
    }
    
    
    
    vector<long long> SIGMA_ZO(ZO.size());
    SIGMA_ZO[0]=ZO[0];
    for (int i=1; i<ZO.size(); i++) {
        SIGMA_ZO[i]=SIGMA_ZO[i-1]+ZO[i];
    }
    
    long long ans=0;
    if ((2*K)+1>=ZO.size()) {
        ans=S.size();
    }
    for (int i=0; i+(2*K)<ZO.size(); i+=2) {
        long long kari=0;
        if(i==0){
            kari=SIGMA_ZO[i+(2*K)];
        }
        else{
            kari=SIGMA_ZO[i+(2*K)] - SIGMA_ZO[i-1];
        }
        if (ans<kari) {
            ans=kari;
        }
        
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 2164
#include <iostream>
using namespace std;
int main(){

    long long  cnt = 0;
    long long  t;

    while(1){
        cin>>t;
        if(t == 0) break;
        else cout<<"Case "<<cnt+1<<": "<<t;
        cout<<"\n";
        cnt++;
    }
    return 0;
}



Measured memory_bytes: 3012
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var rainOfDums = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();
            var mountainRains = new long[n];
            //
            long rainTransposedSum = 0;
            long transposeCoefficient = 1;
            foreach (var i in Enumerable.Range(0, n))
            {
                rainTransposedSum += rainOfDums[i] * transposeCoefficient;
                transposeCoefficient *= -1;
            }
            mountainRains[0] = rainTransposedSum;
            //
            Console.Write(mountainRains[0] + " ");
            //
            foreach (var i in Enumerable.Range(1, n - 1))
            {
                mountainRains[i] = 2 * rainOfDums[i - 1] - mountainRains[i - 1];
                Console.Write(mountainRains[i] + " ");
            }
        }
    }
}


Measured memory_bytes: 32344
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 998244353;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    long double A, B;
    cin >> A >> B;
    cout << (ll)floor(A * B) << endl;
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;

    bool ans = false;
    for(int i = 1; i < 101; ++i)
    {
        if((A * i) % B == C)
        {
            ans = true;
            break;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

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

template<typename T>
struct BIT {
    int n;
    vector<T> dat;
 
    BIT(int n=0){
        initialize(n);
    }
 
    void initialize(int nin){
        n = nin;
        dat.resize(n, 0);
    }
 
    T sum(int i){
        T s = 0;
        while(i >= 0){
            s += dat[i];
            i = (i & (i+1)) - 1;
        }
        return s;
    }
 
    T sum_between(int i, int j){
        return sum(j) - sum(i-1);
    }
 
    void plus(int i, T x){
        while(i < n){
            dat[i] += x;
            i |= i+1;
        }
    }

    void range_add(int a, int b, T x){
        if(a > b) return;
        plus(a, x);
        plus(b+1, -x);
    }
    T get_point(int a){
        return sum(a);
    }
};

int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    int N = S.size();
    vector<int> A(N);
    for(int i=0; i<N; i++) A[i] = S[i] - '0';

    BIT<int> bit(N);
    set<int> gap10;
    gap10.insert(0);
    bit.range_add(0, 0, A[0]);
    for(int i=1; i<N; i++){
        int last = bit.get_point(i-1);
        if(A[i] > last){
            A[i]--;
            int g = *gap10.rbegin();
            bit.range_add(g, g, 10);
            bit.range_add(g+1, i-1, 9);
            if(g > 0 && bit.get_point(g-1) - bit.get_point(g) < 10) gap10.erase(g);
            if(g+1 < i && bit.get_point(g) - bit.get_point(g+1) >= 10) gap10.insert(g+1);
        }
        bit.range_add(i, i, A[i]);
        if(bit.get_point(i-1) - bit.get_point(i) >= 10) gap10.insert(i);
    }
    int sum = bit.get_point(0);
    int ans = (sum+8)/9;
    cout << ans << endl;
}

Measured memory_bytes: 4868
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, x: "List[int]"):
    ret = float('inf')
    for l, r in zip(x, x[K-1:]):
        ret = min(ret, abs(r - l) + min(abs(l), abs(r)))
    return ret


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
    K = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, K, x)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17872
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll> 
#define vv vector<v>
#define p pair<ll,ll>
#define mid (start+end)/2
#define fi first
#define se second	
int main() {
	ll a,b;
	cin>>a>>b;
	ll c=a+b;
	if (c%2==0)
		cout<<c/2;
	else
		cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
count = 0
s = [[]*2]*m
for i in range(0, m):
  s[i] = list(map(int, input().split()))
s.sort()
r = s[0][1] - 1
count += 1
for i in range(1, m):
  if s[i][1] - 1 < r:
    r = s[i][1] - 1
  if r < s[i][0]:
    r = s[i][1] - 1
    count += 1
print(count)

Measured memory_bytes: 27916
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, r;
  while (cin >> n >> r) {
    if (n == 0 && r == 0) break;
    vector<P> num(n);
    rep(i, n) {
      num[i].first = i + 1;
      num[i].second = n - i;
    }

    rep(i, r) {
      int p, c;
      cin >> p >> c;
      int tmp = 1;
      rep(i, p + c - 1) {
        if (i < p - 1) {
          num[i].first += c;
        } else {
          num[i].first = tmp;
          tmp++;
        }
      }
      sort(all(num));
    }

    cout << num[0].second << "\n";
  }

  return 0;
}


Measured memory_bytes: 3104
import math
a,b,c = map(float,input().split())
rad = math.radians(c)
x = (a**2+b**2-2*a*b*math.cos(rad))**(1/2)
L = a+b+x
S = a*b*math.sin(rad)/2
h = 2*S/a
print("{:.8f}\n{:.8f}\n{:.8f}".format(S,L,h))


Measured memory_bytes: 5704
function main(input) {
  var N = input[0]-0;
  var S = input[1];
  var map = {};
  for(var i=0;i<S.length;i++){
    if(!map[S[i]]) map[S[i]] = [];
    map[S[i]].push(i);
  }
  var ans = 0;
  for(var i=0;i<1000;i++){
    var num = ("000"+i).slice(-3);
    var a = map[num[0]];
    var b = map[num[1]];
    var c = map[num[2]];
    var t = find(a, 0);
    if(t==-1) continue;
    t = find(b, t+1);
    if(t==-1) continue;
    t = find(c, t+1);
    if(t==-1) continue;
    ans++;
  }
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))

function find(arr, n, min){
  if(!min)min=0;
  if(!arr) return -1;
  for(var i=min;i<arr.length;i++){
    if(arr[i]>=n) return arr[i];
  }
  return -1;
}


Measured memory_bytes: 8248
#include <iostream>

using namespace std;

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

  int L[N];
  for(int i = 0; i < N; ++i) cin >> L[i];

  int D = 0;
  int ans = 1;

  for(int i = 0; i < N; ++i){
    D += L[i];
    if(D<=X) ans++;
  }

  cout << ans << endl;
}


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

if len(set(A))<=k:
    print(0)
else:
    d = {i:0 for i in set(A)}
    for a in A:
        d[a] += 1
    ans = list(d.values())
    ans.sort(reverse = True)
    print(sum(ans[k:]))

Measured memory_bytes: 45748
x = int(input())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

for i in range(x, 10**18):
    if is_prime(i):
        print(i)
        break

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		for (int i = 0; i < 2; i++) {
			int[] num = new int[10];
			for (int j = 0; j < 10; j++) {
				num[j] = scanner.nextInt();
			}
			Arrays.sort(num);
			int ans = 0;
			for (int j = 9; j > 6; j--)
				ans += num[j];
			System.out.print(ans);
			System.out.print(i == 0 ? ' ' : '\n');
		}
	}
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b;
  if(n%2==1){
    for(int i=0; 2*i<n; i++){
      b.push_back(a[n-i*2-1]);
    }
    for(int i=0; i*2+1<n; i++){
      b.push_back(a[i*2+1]);
    }
    for(int i=0; i<n; i++){
      cout << b[i] << " ";
    }
  }
  else{
    for(int i=0; 2*i<n; i++){
      b.push_back(a[n-i*2-1]);
    }
    for(int i=0; i*2<n; i++){
      b.push_back(a[i*2]);
    }
    for(int i=0; i<n; i++){
      cout << b[i] << " ";
    }
  }
}

Measured memory_bytes: 3828
import java.util.Scanner;

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

	String s = scan.next();

	String yy = s.substring(0,4);
	String mm = s.substring(5,7);
	String dd = s.substring(8,10);

	int year = Integer.parseInt(yy);
	if(year < 2019){
	    System.out.println("Heisei");
	}else if(year == 2019){
	    if(mm.equals("01") || mm.equals("02") ||
	       mm.equals("03") || mm.equals("04")){
		System.out.println("Heisei");
	    }else{
		System.out.println("TBD");
	    }
	}else{
	    System.out.println("TBD");
	}

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
typedef int weight;
struct edge
{
	int from, to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};

typedef vector<edge> Edges;
typedef vector<Edges> Graph;
//int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

struct union_find
{
	vector<int> par;
	union_find(int n) :par(n, -1) {}
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		if (par[y] < par[x]) swap(x, y);
		if (par[x] == par[y]) par[x]--;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] < 0) cnt++;
		return cnt;
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};
int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		Edges es;
		REP(i, m)
		{
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			es.push_back(edge{ a, b, c });
		}
		sort(ALL(es));
		int ans = INF;
		REP(i, m)
		{
			union_find uf(n);
			int mn = INF, mx = -1;
			FOR(j, i, m)
			{
				if (!uf.same(es[j].from, es[j].to))
				{
					chmin(mn, es[j].cost);
					chmax(mx, es[j].cost);
					uf.unite(es[j].from, es[j].to);
				}
			}
			if (uf.count() == 1) chmin(ans, mx - mn);
		}
		if (ans == INF) puts("-1");
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1352
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// get a integer
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt() - 1;
		}
		
		int count = 0;
		for(int i = 0; i < n; i++) {
			int targetIndex = arr[i];
			if(arr[targetIndex] == i)
				count++;
		}
		System.out.println(count/2);
	}
}


Measured memory_bytes: 32448
n = int(input())
a = [int(i) for i in input().split()]
mod = (10 ** 9) + 7
max_a = max(a)
ans = 0
for j in range(len(bin(max(a))) - 2):
    t = sum([1 & i for i in a]) 
    ans += (2 ** j) * t * (n - t)
    a = [i >> 1 for i in a]
    ans = ans % mod
print(ans)

Measured memory_bytes: 137792
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
int n, m;
vector<vector<int>> graph;

signed main() {
    int n;
    cin >> n;
    vector<pair<int, int>> as(n);
    REP(i, n) { cin >> as[i].first >> as[i].second; }
    sort(as.begin(), as.end());
    REP(i, n) { cout << as[i].first << " " << as[i].second << endl; }
}


Measured memory_bytes: 3532
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;
const int D = 16;

template <class T, int D>
class Vec {
  using V = Vec<T, D - 1>;
  vector<V> vec;

 public:
  template <class... I>
  Vec(int size, I... rest) : vec(size, V(rest...)) {}
  int size() const { return vec.size(); }
  V& operator[](int i) { return vec[i]; }
  const V& operator[](int i) const { return vec[i]; }
};

template <class T>
class Vec<T, 1> {
  vector<T> vec;

 public:
  Vec(int size) : vec(size) {}
  Vec(int size, const T& init) : vec(size, init) {}
  T& operator[](int i) { return vec[i]; }
  const T& operator[](int i) const { return vec[i]; }
};

vector<int> split(ll n) {
  vector<int> dig(D);
  for (int i = D - 1; i >= 0; i--) {
    dig[i] = n % 10;
    n /= 10;
  }
  return dig;
}

Vec<int, 3> solveDP(const vector<int>& dig) {
  Vec<int, 3> dp(D + 1, 2, D * 9 + 1, 0);
  dp[D][0][0] = dp[D][1][0] = 1;
  for (int i = D - 1; i >= 0; i--) {
    for (int big = 0; big < 2; big++) {
      for (int dsum = 0; dsum <= D * 9; dsum++) {
        for (int d = big ? 0 : dig[i]; d <= 9; d++) {
          if (dsum - d < 0) break;
          dp[i][big][dsum] |= dp[i + 1][big | (d > dig[i])][dsum - d];
        }
      }
    }
  }
  return dp;
}

ll solveGreedy(const vector<int>& dig, const Vec<int, 3>& dp, int dsum) {
  if (!dp[0][0][dsum]) {
    return -1;
  }
  ll m = 0;
  bool big = false;
  for (int i = 0; i < D; i++) {
    for (int d = big ? 0 : dig[i]; d <= 9; d++) {
      if (dp[i + 1][big | (d > dig[i])][dsum - d]) {
        m = m * 10 + d;
        big |= d > dig[i];
        dsum -= d;
        break;
      }
    }
  }
  return m;
}

ll f(ll n) {
  auto dig = split(n);
  auto dp = solveDP(dig);
  ll p = 1, q = 0;
  for (int k = 1; k <= D * 9; k++) {
    ll m = solveGreedy(dig, dp, k);
    if (m < 0) continue;
    if (p * k > m * q || (p * k == m * q && p > m)) {
      p = m;
      q = k;
    }
  }
  return p;
}

int main() {
  int K;
  while (cin >> K) {
    vector<ll> res;
    res.push_back(1);
    while (res.size() < K) {
      ll n = res.back();
      res.push_back(f(n + 1));
    }
    for (ll x : res) cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	int n;
	cin >> n;
	int p;
	int MIN = 999999999;
	int cnt = 0;
	rep(i, n) {
		cin >> p;
		if (p < MIN) {
			cnt++;
			MIN = min(p, MIN);
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, s, cnt;
	int i, j, k, l, a, b, c, d, e;
	
	while (scanf("%d %d", &n, &s), n != 0 || s != 0){
		cnt = 0;
		for (i = 0; i <= 9; i++){
			if (1 < n){
				for (j = i + 1; j <= 9; j++){
					if (2 < n){
						for (k = j + 1; k <= 9; k++){
							if (3 < n){
								for (l = k + 1; l <= 9; l++){
									if (4 < n){
										for (a = l + 1; a <= 9; a++){
											if (5 < n){
												for (b = a + 1; b <= 9; b++){
													if (6 < n){
														for (c = b + 1; c <= 9; c++){
															if (7 < n){
																for (d = c + 1; d <= 9; d++){
																	if (8 < n){
																		for (e = d + 1; e <= 9; e++){
																			if (i + j + k + l + a + b + c + d + e == s){
																					cnt++;
																			}
																		}
																	}
																	else if (i + j + k + l + a + b + c + d == s){
																		cnt++;
																	}
																}
															}
															else if (i + j + k + l + a + b + c == s){
																cnt++;
															}
														}
													}
													else if (i + j + k + l + a + b == s){
														cnt++;
													}
												}
											}
											else if (i + j + k + l + a == s){
												cnt++;
											}
										}
									}
									else if (i + j + k + l == s){
										cnt++;
									}
								}
							}
							else if (i + j + k == s){
								cnt++;
							}
						}
					}
					else if (i + j == s){
						cnt++;
					}
				}
			}
			else if (i == s){
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
	return (0);
}

Measured memory_bytes: 596
h,w = map(int,input().split())
s = []
for i in range(h):
    s1 = list(input())
    s.append(s1)
p = []
q = []
r = []
t = []
l = 0
for i in range(h):
    count1 = 0
    count2 = 0
    p1 = []
    q1 = []
    for j in range(w):
        if s[i][j] == ".":
            count1 = count1 + 1
            p1.append(count1)
        elif s[i][j] == "#":
            count1 = 0
            p1.append(count1)
        if s[i][w-j-1] == ".":
            count2 = count2 + 1
            q1.append(count2)
        elif s[i][w-j-1] == "#":
            count2 = 0
            q1.append(count2)
    p.append(p1)
    q.append(q1)
for i in range(w):
    count1 = 0
    count2 = 0
    r1 = []
    t1 = []
    for j in range(h):
        if s[j][i] == ".":
            count1 = count1 + 1
            r1.append(count1)
        elif s[j][i] == "#":
            count1 = 0
            r1.append(count1)
        if s[h-j-1][i] == ".":
            count2 = count2 + 1
            t1.append(count2)
        elif s[h-j-1][i] == "#":
            count2 = 0
            t1.append(count2)
    r.append(r1)
    t.append(t1)
for i in range(h):
    for j in range(w):
        l1 = p[i][j]+q[i][w-j-1]+r[j][i]+t[j][h-i-1]
        if l < l1:
            l = l1
print(l-3)

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

int bubbleSort(int A[], int N);
int main(){
    int N, x;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    x = bubbleSort(A, N);
    
    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl << x << endl;
    
    return 0;
}

int bubbleSort(int A[], int N){
    bool flag = 1;
    int x = 0;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = N -1; j >= i + 1; j--){
            if(A[j] < A[j -1]){
                swap(A[j], A[j -1]);
                flag = 1;
                x++;
            }
        }
    }return x;
    
}


Measured memory_bytes: 3076
#include <stdio.h>
int a[40] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
int k;
int main() {
	scanf("%d", &k);
	printf("%d\n", a[k - 1]);
}

Measured memory_bytes: 128
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
signed main(){
    int a,b;cin>>a>>b;
    if(a<=b)cout<<a<<endl;
    else cout<<a-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	for (long long int i = -2000; i <= 2000; i++) {
		for (long long int j = -2000; j <= 2000; j++) {
			if (i*i*i*i*i - j * j*j*j*j == N) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3700
S = [ i for i in input()]

if len(S) <= 1:
  print(0)
  exit()

zerone = ['0', '1']
a = 0
b = 0

def is_even(num):
  return 0  if num % 2 == 0 else 1

for i in range(len(S)):
  if S[i] != zerone[is_even(i)]:
    a += 1
  else:
    b += 1

print(a if a < b else b)




Measured memory_bytes: 3956
import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  x,a,b = map(int, input().split())
  
  if b-a <= 0:
    print("delicious")
  elif b-a >0 and b-a <= x:
    print("safe")
  else:
    print("dangerous")
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int mod = 1e9 + 7;

long long mod_pow(long long x,long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x*x % mod, n / 2);
    if(n & 1) res = res*x % mod;
    return res;
}

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, 0, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    bool f = true;
    if(n % 2){
        if(mp[0] != 1) f = false;
        rep(i, 1, n / 2 + 1){
            if(mp[2 * i] != 2) f = false;
        }
    }else{
        rep(i, 0, n / 2){
            if(mp[2 * i + 1] != 2) f = false;
        }
    }
    int ans = mod_pow(2, n / 2);
    if(f) cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }











void solve() {
    ll d,t,c;
    cin>>d>>t>>c;
    if(d <= t*c){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    




}







signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    ll t=1;
    rep(i,t){
        solve(); 
    }


    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        cout << 'x';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
//typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s;
    cin >> s;
    vector<string> t={"Sunny","Cloudy","Rainy","Sunny"};
    rep(i,3){
        if(s==t[i]){
            cout << t[i+1];
            return 0;
        }
    }

}

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

int main() {
	int Q;
	cin >> Q;
	priority_queue<long long> MIN;
	priority_queue<long long, vector<long long>, greater<long long> > MAX;
	long long MINC = 0, MAXC = 0, BC = 0;
	for (int i = 0; i < Q; i++) {
		int Type;
		cin >> Type;
		if (Type == 1) {
			long long A, B;
			cin >> A >> B;
			BC += B;
			if (MIN.size() == MAX.size()) {
				if (MIN.size() == 0) {
					MIN.push(A);
					MINC += A;
				}
				else if (A <= MAX.top()) {
					MIN.push(A);
					MINC += A;
				}
				else {
					MIN.push(MAX.top());
					MINC += MAX.top();
					MAXC -= MAX.top();
					MAX.pop();
					MAX.push(A);
					MAXC += A;
				}
			}
			else {
				if (MIN.top() >= A) {
					MAX.push(MIN.top());
					MAXC += MIN.top();
					MINC -= MIN.top();
					MIN.pop();
					MIN.push(A);
					MINC += A;
				}
				else {
					MAX.push(A);
					MAXC += A;
				}
			}
		}
		else {
			cout << MIN.top() << " " << MAXC - MIN.top() * (long long)MAX.size() + MIN.top() * (long long)MIN.size() - MINC + BC << endl;
		}
	}
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int a = min(A, B), b = max(A, B);
    if (a == 1) cout << (b == 2 ? 3 : 2) << endl;
    else if (a == 2) cout << 1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int table[15][15];
int main(){
	int a;
	while(scanf("%d",&a),a){
		int row=a/2+1;
		int col=a/2;
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				table[i][j]=0;
		for(int i=0;i<a*a;i++){
			if(table[row%a][col%a]){
				row++;
				col--;
			}
			table[row%a][col%a]=i+1;
			row++;
			col++;
		}
		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++){
				printf("%4d",table[i][j]);
			}
			printf("\n");
		}
	}
}

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

signed main(){
	int h,w;
	cin>>h>>w;
	char s[w][h];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[j][i];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[j][i]=='#'){
				if(j>0&&s[j-1][i]=='#'){
					continue;
				}
				else if(j<w-1&&s[j+1][i]=='#'){
					continue;
				}
				else if(i>0&&s[j][i-1]=='#'){
					continue;
				}
				else if(i<h-1&&s[j][i+1]=='#'){
					continue;
				}
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

using namespace std;

#define ll  long long

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef unordered_map<int,int> um;
typedef unordered_set<int> us;
typedef priority_queue<int> pq;
typedef deque<int> dq;
typedef queue<int> q;
typedef stack<int> st;

#define f first
#define s second
#define pb push_back
#define mp make_pair

#define rep(i,a,b)  for(auto i = a; i < b; i++)
//#define bitset<n> b<n>

/* typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; */



void c_p_c()
{
	
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	ll n;
	cin>>n;

	std::vector<ll> v(n);

	rep(i,0,n){
		cin>>v[i];
	}

	std::vector<ll> res(n);

	res[0] = 0;
	res[1] = abs(v[1]-v[0]);

		rep(i,2,n){
			res[i] = min((res[i-1]+abs(v[i]-v[i-1])),(res[i-2]+abs(v[i]-v[i-2])));
		}
	

	cout<<res[n-1];
	//ll t;
	//cin>>t;
	//while(t--){

	//}

	return 0;
	}

		

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int k = 0;
    while(1){
        if(k >= 61){
            cout << "-1\n";
            break;
        }
        if((60*k+c) % (a+b) <= a){
            cout << 60*k+c << "\n";
            break;
        }
        k++;
    }
    return 0;
}

Measured memory_bytes: 3088
n, m = map(int, input().split())
s = input()

ans = []

i = n
while i > 0:
    flag = 1
    for l in reversed(range(1, m+1)):
        ni = i - l
        if ni < 0:
            continue
        if s[ni] == '1':
            continue
        if s[ni] == '0':
            ans.append(l)
            i = ni
            flag = 0
            break
    if flag:
        print(-1)
        exit()

ans_ = []
for i in reversed(range(len(ans))):
    ans_.append(ans[i])
print(*ans_)
    

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

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

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define prll(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    ll n;
    cin >> n;
    if (n%2)
        cout << fixed << setprecision(32) << (ld) (n/2 + 1)/n << endl;
    else
        cout << 0.5 << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
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<<"	";
    }
    return s;
}

// 2 dimentional vector
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;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll a,b,c;
    cin>>a>>b>>c;
    ll ans=a*b/2;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
// 2018/01/15 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int H;
		cin >> H;

		if(H==0)
			break;

		int S[10][5];
		for(int y=0; y<H; y++){
			for(int x=0; x<5; x++){
				cin >> S[y][x];
			}
		}

		int sco = 0;

		while(true){
			bool flg = false;

			for(int y=0; y<H; y++){
				int m = S[y][2];
				if(m==0)
					continue;

				if(S[y][0]==m && S[y][1]==m){
					sco += m*3;  S[y][0] = S[y][1] = S[y][2] = 0;  flg = true;
					if(S[y][3]==m){
						sco += m;  S[y][3] = 0;
						if(S[y][4]==m){
							sco += m;  S[y][4] = 0;
						}
					}
				}
				else if(S[y][1]==m && S[y][3]==m){
					sco += m*3;  S[y][1] = S[y][2] = S[y][3] = 0;  flg = true;
					if(S[y][4]==m){
						sco += m;  S[y][4] = 0;
					}
				}
				else if(S[y][3]==m && S[y][4]==m){
					sco += m*3;  S[y][2] = S[y][3] = S[y][4] = 0;  flg = true;
				}
			}

			if(!flg)
				break;

			for(int x=0; x<5; x++){
				for(int y=H-1; y>=0; y--){
					if(S[y][x]!=0)
						continue;

					for(int y2=y-1; y2>=0; y2--){
						if(S[y2][x]!=0){
							S[y][x] = S[y2][x];
							S[y2][x] = 0;
							break;
						}
					}
				}
			}
		}

		cout << sco << endl;
	}

	return 0;
}



Measured memory_bytes: 3068
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-28 22:12:17
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double all;
  cin >> n;
  all = 0.0;
  vector<double>a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    all += 1/a.at(i);
  }
  cout << fixed << setprecision(10);
  cout << 1/all << endl;
}

Measured memory_bytes: 256