Go: package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	a, b, c := io.NextInt(), io.NextInt(), io.NextInt()
	for i := 0; i < 61; i++ {
		for j := 0; j < 61; j++ {
			if (a+b)*i-60*j <= c && c <= (a+b)*i-60*j+a {
				io.Println(60*j + c)
				return
			}
		}
	}
	io.Println(-1)
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include<iostream>
int n,m,c,i;main(){std::cin>>n>>m>>c;for(i=0;i<99;i++){if(c%(n+m)<=n)goto a;c+=60;}c=-1;a:printf("%d\n",c);}

C++: #include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	rep(i,70){
		int time=60*i+c;
		if(time%(a+b)<=a){
			cout<<time<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

C++: #include<iostream>
#include<climits>
#define ll long long 
using namespace std;

int main(){
  int a,b;
  ll c,time=0;

  cin>>a>>b>>c;

  bool flag=1;
  if(a+b>c) flag=0;
  while(1){
    if(time>=60) flag=0;
    if(c>=INT_MAX){
      c=-1;
      break;
    }

    time+=a;
    if(time>=c) break;
    time+=b;


    if(flag==0){
      c+=60;
      flag=1;
    }

  }

  cout<<c<<endl;
  
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int n=0;
  while(n<100000000){
    if(n%60<=c&&c<=n%60+a)cout<<n/60*60+c<<endl,n=10000000;
    n+=a+b;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int MAX = 1e8;

signed
main(){
		int a,b,c;
		cin >> a >> b >> c;
		int ans = MAX;

		for(int k=0;k<a+b;k++)
		{
				for(int t=0;t<c;t++)
				{
						if(k*(a+b) <= c+60*t && c+60*t <= k*(a+b) + a)
						{
								ans = min(ans, c+60*t);
						}
				}
		}
		if(ans == MAX)
		{
				cout << -1 << endl;
		}else
		{
				cout << ans << endl;
		}
}

C++: #include <bits/stdc++.h>

using namespace std;

long long lcm(int a, int b)
{
  return a / __gcd(a, b) * b;
}

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = -1;
  for(int i = c; i < lcm(60, a+b); i += 60){ //Kai ha 60t + c & lcm de loop
    if(i % (a+b) <= a){ ans = i; break; } //a+b no amari ga a ika
  }
  cout << ans << endl;
  return 0;
}

C++: #include <iostream>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int a1 = a;
	int b1 = b;
	int count = 0;
	while (true)
	{
		bool Time[60]; 
		for (int i = 0; i<60; i++)
		{
			if (a1>0)
			{
				Time[i] = true;
				a1--;
			}
			else if (b1>0)
			{
				Time[i] = false;
				b1--;
			}
			if(a1==0 && b1 == 0)
			{
				a1 = a;
				b1 = b;
			}
		}
		if (Time[c-1] == true)
		{
				cout << count * 60 + c << endl;
				return 0;
		}
		if (a1 == a && b1 == b)
		{
			cout << -1 << endl;
			return 0;
		}
    count++;
	}//while
	return 0;
}

C++: #include<iostream>
#include<map>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    map<int, bool> is_visited;
    int now = 0;
    while (true) {
        int left = (A + B) * now;
        int right = (A + B) * now + A;
        int c_pos = (left / 60) * 60 + C;
        if (is_visited[left % 60]) {
            cout << -1 << endl;
            return 0;
        }
        if (left <= c_pos && c_pos <= right) {
            cout << c_pos << endl;
            return 0;
        }
        is_visited[left % 60] = true;
        now++;
    }
    return 0;
}