akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
	static FastReader f = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		String s = f.next();
		long sum = 0;
		for(int i=0;i<s.length();i++) {
			sum += s.charAt(i) - '0';
		}
		out.println(sum % 9 == 0 ? "Yes" : "No");
		out.close();
	}
		

	static class FastReader {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;

		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine() {
			String str = "";

			try {
				str = br.readLine();
			} catch(IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

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

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define	inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

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


const int S=100100;
int cnt[S+5];
int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
	int n;
	while(~sf("%d",&n))
	{
		mem(cnt,0);
		for(int i=1;i<=100;i++)
		{
			for(int j=1;j<=100;j++)
			{
				for(int k=1;k<=100;k++)
				{
					int sum=(i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i);
					cnt[sum]++;
				}
			}
		}

		for(int i=1;i<=n;i++)pf("%d\n",cnt[i]);
	}
    return 0;
}
 






































Measured memory_bytes: 4144
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		double[] x = new double[N];
		String[] u = new String[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextDouble();
			u[i] = sc.next();
		}
		double s = 0;
		for (int i = 0; i < N; i++) {
			if (u[i].equals("JPY"))
				s += x[i];
			else
				s += x[i] * 380000;
		}
		System.out.println(s);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22868
#include <iostream>

int main() {
  int N, X, T;
  std::cin >> N >> X >> T;
  if (N%X != 0){
    std::cout << (N/X + 1) * T << std::endl;
  }
  else{
    std::cout << (N/X) * T << std::endl;
  }
}


Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
using namespace std;
int a[100000];
int main(){
	int i,i2,sum,ans,n,k;
	cin>>n>>k;
	while(n!=0){
		ans=0;
		for(i=0;i<n;i++)cin>>a[i];
		for(i=0;i<n-k;i++){
			sum=a[i];
			for(i2=1;i2<k;i2++)sum+=a[i+i2];
			ans=max(ans,sum);
		}
		cout<<ans<<endl;
		cin>>n>>k;
	}
}

Measured memory_bytes: 3364
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt = 0
for i in range(n):
  if a[i] <= b[i]:
    cnt += a[i]
    b[i] -= a[i]
    if b[i] >= a[i+1]:
      cnt += a[i+1]
      a[i+1]=0
    else:
      cnt += b[i]
      a[i+1] -= b[i]
  else:
    cnt += b[i]
print(cnt)

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

int main(){
  ll MOD = 1000000007;
  int n;
  cin >> n;
  vvi a(n, vi(n));
  rep(i,n) rep(j,n) cin >> a[i][j];
  vl dp(1<<n);
  dp[0] = 1;
  for(int s=1; s<(1<<n); s++){
    int i = __builtin_popcount(s);
    rep(j,n){
      if(a[i-1][j] == 1 && s >> j & 1){
        dp[s] += dp[s ^ (1<<j)];
        dp[s] %= MOD;
      }
    }
  }
  //rep(i, 1<<n) cout << dp[i] << " ";
  cout << dp[(1<<n)-1] << endl;
}


Measured memory_bytes: 19648
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  string a,b,c;
  cin>>a>>b>>c;
  cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,flag=1; cin >> n;
    string w[100];
    for (int i=0; i<n; i++) cin >> w[i];
    for (int i=0; i<n-1; i++) {
        if (w[i][w[i].size()-1] != w[i+1][0]) {flag=0; break;}
    }
    for (int i=0; i<n-1; i++){
        if (flag==0) break;
        for (int j=i+1; j<n; j++){
            if (w[i] == w[j]) {flag=0; break;}
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int	main(){
  int a, b;
  scanf("%d %d", &a,&b);
  if(a < b){
    printf("a < b\n");
  }
  else if(a > b){
    printf("a > b\n");
  }
  else if(a == b){
    printf("a == b\n");
  }
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  priority_queue<int> que;
  rep(i,n){
    que.push(a[i]);
  }
  rep(i,m){
    int cur = que.top();
    que.pop();
    cur = cur >> 1;
    que.push(cur);
  }
  ll ans = 0;
  rep(i,n){
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
# -*- coding: utf-8 -*-
# E - Virus Tree 2
import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int, readline().split())
MOD = 10**9+7
graph = [[] for _ in range(N+1)]

for _ in range(N-1):
    a,b = map(int,readline().split())
    graph[a].append(b)
    graph[b].append(a)

dist = [-1]*(N+1)
dist[1] = K
q = deque([1])

def bfs():
    while q:
        x = q.popleft()
        if dist[x] == K:
            cnt = 1
        else:
            cnt = 2
        for nx in graph[x]:
            if dist[nx] != -1:
                continue
            dist[nx] = max(0,K-cnt)
            q.append(nx)
            cnt += 1
            
bfs()
ans = 1
for i in range(1,N+1):
    ans *= dist[i]
    ans %= MOD      
print(ans)

Measured memory_bytes: 85148
H,N = map(int,input().split())
magic = []
for i in range(N):
  a,b = map(int,input().split())
  magic.append((a,b))
A = [item[0] for item in magic]
maxA = max(A)
minA = min(A)
dp = [float("inf")]*(H+maxA+1)
dp[0]=0
for i in range(H+maxA):
  for j in range(N):
    dp[i] = min(dp[i],
                dp[max(i-magic[j][0],0)]+magic[j][1])
print(dp[H])

Measured memory_bytes: 42716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int n, ax[100009], ay[100009], bx[100009], by[100009], cnt;
vector<int>Z1[100009], Z2[100009]; bool used[200009];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> ax[i] >> ay[i]; Z1[ax[i]].push_back(ay[i]); }
	for (int i = 0; i < n; i++) { cin >> bx[i] >> by[i]; Z2[bx[i]].push_back(by[i]); }
	for (int i = 0; i <= 2 * n; i++) {
		for (int j = 0; j < Z1[i].size(); j++) used[Z1[i][j]] = true;
		for (int j = 0; j < Z2[i].size(); j++) {
			int maxn = -1;
			for (int k = 0; k < 2 * n; k++) {
				if (used[k] == true && k < Z2[i][j]) maxn = k;
			}
			if (maxn >= 0) {
				cnt++; used[maxn] = false;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n;
  vector<int>a(n);for(int i=0;i<n;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  m=a.at(n-1)-a.at(0)+1;
  vector<int>d(m);
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++)d.at(i)+=(a.at(j)-a.at(0)-i)*(a.at(j)-a.at(0)-i);
  }
  sort(d.begin(),d.end());
  cout<<d.at(0)<<endl;
}
  


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

void calcCanReach( char c[20][20], int x, int y, int a, int b )
{
    c[b][a] = '@';
    if( b - 1 >= 0 && c[b-1][a] == '.' )
        calcCanReach( c, x, y, a, b - 1 );
    if( b + 1 < y && c[b+1][a] == '.' )
        calcCanReach( c, x, y, a, b + 1 );
    if( a - 1 >= 0 && c[b][a-1] == '.' )
        calcCanReach( c, x, y, a - 1, b );
    if( a + 1 < x && c[b][a+1] == '.' )
        calcCanReach( c, x, y, a + 1, b );
}

int main()
{
    char c[20][20];
    int x, y, a, b;

    while( cin >> x >> y )
    {
        if( x == 0 && y == 0 )
            break;

        for( int i = 0; i < y; i++ )
            for( int j = 0; j < x; j++ )
            {
                cin >> c[i][j];
                if( c[i][j] == '@' )
                {
                    a = j;
                    b = i;
                }
            }
        
        calcCanReach( c, x, y, a, b );

        int cnt = 0;
        for( int i = 0; i < y; i++ )
            for( int j = 0; j < x; j++ )
                if( c[i][j] == '@' )
                    cnt++;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
N,M,X=map(int, input().split())

#Nさつ
C=[]
A=[]
for i in range(N):
    I=list(map(int, input().split()))
    C.append(I[0])
    A.append(I[1:])

#print(C, A)
ans="-1"
for b in range(2**N):
    L=[0]*M
    cost=0
    for i in range(N):
        if b>>i&1==0:
            cost+=C[i]
            l=A[i]
            for j,a in enumerate(l):
                L[j]+=a
    if min(L)>=X:
        if ans=="-1":
            ans=cost
        else:
            ans=min(ans, cost)
print(ans)


Measured memory_bytes: 9220
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        solve(a,s);
    }

    public static void solve(int a, String s){
        if(a<3200){
            System.out.println("red");
        }else{
            System.out.println(s);
        }
    }
}

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

using namespace std;

int main()
{
    long long a,b,k;
    cin >> a >> b >> k;

    if(a<=k){
        k-=a;
        a=0;
    }
    else{
        a-=k;
        k=0;
    }
    if(b<=k){
        k-=b;
        b=0;
    }
    else{
        b-=k;
        k=0;
    }

    cout << a << " " << b << endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A;
    cin >> A;
    cout << A + A * A + A * A * A << endl;
    return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = 0
t = 99
for i in a:
  if t+1 == i:
    s += c[t-1]
  s += b[i-1]
  t = i

print(s)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define forn1 for(i=1; i<=n; i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g,bb;
//    string ss,s;
////    cin>>_;
//    while(_--)
//    {
//        c
//
//    }
    double dd,cc;
    cin>>dd;
    cc=acos(-1);
    cout<<2*dd*cc<<endl;
}


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

int main(){
  int n;
  cin >> n;
  
  n = n % 10;
  
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9 )
    cout << "hon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8 )
    cout << "pon" << endl;
  else
    cout << "bon" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
int n,k;
int a[100005];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	if((n-k)%(k-1)==0)
		cout<<(n-k)/(k-1)+1;
	else
		cout<<(n-k)/(k-1)+2;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{
    int N;
    io >> N;
    int ans = ((N+999) / 1000) * 1000 - N;
    io << ans << BR;
}

Measured memory_bytes: 3824
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <complex>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
// define x, y as real(), imag()


template<class T>
istream& operator>> (istream& is, complex<T>& p) {
  T value;
  is >> value;
  p.real(value);
  is >> value;
  p.imag(value);
  return is;
}
#define M_PI 3.14159265358979323846
typedef long long int lli;
lli mod=1e9+9ll;
#define OS //single input use oeis
lli INF=9223372036854775807;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c,s,t;
const double pi=3.14159265358979323846;
lli me(lli a,lli b)
{
    // cout<<mod<<"\n";
    lli res=1;
    while(b)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        a=a*a;
        a%=mod;
        b=b>>1;
    }
    return res;
}
lli mI(lli a)
{
    return (me(a,mod-2)%mod+mod)%mod;
}
vector<lli> v[1005];
lli mk[1005][1005];
lli vis[1005];
lli val=-1;
void bfs()
{
    queue<ll> q;
    q.push({s,0});
    while(!q.empty())
    {
        ll no=q.front();
        q.pop();
        if(vis[no.first])
        continue;
        vis[no.first]=1;
        if(no.first==t)
        {
            val=no.second;
            break;
        }
        for(auto &j: v[no.first])
        {
            q.push({j,no.second+1});
        }
    }
}
int main()
{
   string s,t;
   cin>>s>>t;
   t.pop_back();
   if(s==t)
   cout<<"Yes";
   else
   cout<<"No";
}

Measured memory_bytes: 3660
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e5+3; //AREGLAAAAAAAAR!!!!
int a[MAXN],da[MAXN];
int main(){
	int n;
	ri(n);
	FOR(i,0,n) ri(a[i]);
	int p=0,ans=0;
	while(1){
		ans++;
		if(da[p]){
			ans=-1;
			break;
		}
		da[p]=1;
		if(a[p]==2) break;
		else if(a[p]==p+1){
			ans=-1;
			break;
		}else{
			p=a[p]-1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int read(){
	int sum = 0;;char c = getchar();
	while(c<'0'||c>'9') c = getchar(); 
	while(c>='0'&&c<='9') sum = sum * 10 + c - 48 , c = getchar();
	return sum;
}
int main(){
	int a , b , c , x , y;
	long long ans = 1e15;
	a = read();b = read();c = read();x = read();y = read();
	if( 2 * c < a + b){
		for(int i = 0;i <= max( x , y );++i){
		    long long now = 0;
		    now = now + c * i * 2;
		    if( i < x ) now = now + ( x - i ) * a;
			if( i < y ) now = now + ( y - i ) * b;
			ans = min( ans , now ); 
		}
	}
	else{
		ans = a * x + b * y;
	}
	printf("%lld",ans);
	return 0;
}

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

#define lli long long int
#define pb push_back
#define f first
#define sec second
#define mod 1000000007

lli dp[1001][1001];

main()
{
    lli n,m,a,b,c,i,j,k,x,y;

    cin>>n>>m;

    string s[n];

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

    dp[0][0] = 1;

    for(i=1;i<n;i++)
    {
        if(s[i][0] == '.')
        {
            dp[i][0] = dp[i-1][0];
        }
        else
        {
            dp[i][0] = 0;
        }
    }
    for(i=1;i<m;i++)
    {
        if(s[0][i] == '.')
        {
            dp[0][i] = dp[0][i-1];
        }
        else
        {
            dp[0][i] = 0;
        }
    }

    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(s[i][j] == '#')
            {
                dp[i][j] = 0;
            }
            else
            {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            }
        }
    }

    cout<<dp[n-1][m-1];
}


Measured memory_bytes: 9088
#include<stdio.h>
int main()
{
	int X,Y,Z,A,B,C,temp,temp1;
	scanf("%d %d %d",&X,&Y,&Z);
	A=X;
	B=Y;
	C=Z;
	temp=A;
	A=B;
	B=temp;
	temp1=A;
	A=C;
	C=temp1;
	printf("%d %d %d\n", A,B,C);
	return 0;
}


Measured memory_bytes: 128
A, B, M = gets.chomp.split().map(&:to_i)
a = gets.chomp.split().map(&:to_i)
b = gets.chomp.split().map(&:to_i)
comb = []
ans = 10000000

M.times do
  comb << gets.chomp.split().map(&:to_i)
end

comb.each do |x, y, c|
  ans = [a[x-1] + b[y-1] - c, ans].min
end

puts [ans, a.min + b.min].min

Measured memory_bytes: 20508
import collections
import itertools
import operator
import sys


class UnionFind:
    def __init__(self):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def are_same(self, x, y):
        return self.find(x) == self.find(y)

    def grouper(self):
        parent_getter = operator.itemgetter(1)
        for _, group in itertools.groupby(
                sorted(self.parent.items(), key=parent_getter), parent_getter):
            yield [i for i, _ in group]


sys.stdin.readline()
uf = UnionFind()
for line in sys.stdin:
    com, x, y = map(int, line.split())
    if com == 0:
        uf.unite(x, y)
    elif com == 1:
        print(1 if uf.are_same(x, y) else 0)



Measured memory_bytes: 7868
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#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 SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    string s;
    int K;
    cin >> s >> K;
    for (auto &c : s) {
        if (c == 'a') continue;
        int x = 'z' - c + 1;
        if (x <= K) {
            c = 'a';
            K -= x;
        }
    }
    if (K) s.back() = 'a' + (s.back() - 'a' + K) % 26;
    cout << s << endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    char a, b;
    cin >> a >> b;
    if(a == b) cout << 'H';
    else cout << 'D';
    cout << endl;
    return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
int main()
{


    string s;
    cin>>s;
    if(s=="SUN")
    {
        cout<<7<<endl;
    }
    else if(s=="MON")
    {
        cout<<6<<endl;
    }
    else if(s=="TUE")
    {
        cout<<5<<endl;
    }
    else if(s=="WED")
    {
        cout<<4<<endl;
    }
    else if(s=="THU")
    {
        cout<<3<<endl;
    }
    else if(s=="FRI")
    {
        cout<<2<<endl;
    }
    else if(s=="SAT")
    {
        cout<<1<<endl;
    }

}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
q = gets.to_i
bc = q.times.map{gets.split.map(&:to_i)}

sum = 0
cnt = {}
a.each do |x|
  sum += x
  if cnt[x].nil?
    cnt[x] = 1
  else
    cnt[x] += 1
  end
end

bc.each do |b, c|
  b_cnt = cnt[b] || 0
  diff = c - b

  sum += (diff * b_cnt)
  puts sum

  cnt[b] = 0
  if cnt[c].nil?
    cnt[c] = b_cnt
  else
    cnt[c] += b_cnt
  end
end


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

int a,b;
string s,t,u;

int main(){
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  cout << a-(u==s) << " " << b-(u==t);
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  math2do
 *    created: 30.08.2020 18:54:14
**/

#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(const char &ch) {
  return "'" + string(1, ch) + "'";
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  reverse(res.begin(), res.end());
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "{" + to_string(p.first) + ", " + to_string(p.second) + "}";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "{" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + "}";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "{" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = (int) 1e5;

vector <int> cnt(N + 1, 0);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    sum += val;
    cnt[val]++;
  }
  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    if (cnt[b] > 0) {
      int many = cnt[b];
      sum -= (long long) many * b;
      sum += (long long) many * c;
      cnt[b] = 0;
      cnt[c] += many;
    } 
    cout << sum << '\n';
  } 
  return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>

int main(){
    int n=0;
    int l[10]={0};
    int max=0;
    int sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&l[i]);
        if(max<l[i]){
            max = l[i];
        }
        sum+=l[i];
    }
    sum-=max;
    if(sum>max){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]

a = [[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j] == b:
                a[i][j] = True

bingo = False
for i in range(3):
    if a[i][0] and a[i][1] and a[i][2]:
        bingo = True
for j in range(3):
    if a[0][j] and a[1][j] and a[2][j]:
        bingo = True
if a[0][0] and a[1][1] and a[2][2]:
    bingo = True
if a[2][0] and a[1][1] and a[0][2]:
    bingo = True
print("Yes" if bingo else "No")




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

int cmp(const void * a, const void * b){
    return *(int *)a - *(int *)b;
}

int main(void){
    int N = 0;
    int d[100000];
    int cnt;

    scanf("%d", &N);

    int i = 0;

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

    qsort(d, N, sizeof(int), cmp);
    if(d[N/2] == d[N/2-1]){
        printf("0");
        return 0;
    }
    printf("%d", d[N/2]-d[N/2-1]);
    return 0;
}

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

def solve(S: str):
    prev = -1
    ans = [0] * len(S)
    cr = 0
    cl = 0
    for i, x in enumerate(S):
        if x == "R":
            if prev == "L":
                # print("cr {} cl {}".format(cr, cl))
                ans[prev_R] = cr//2 + cl//2 + cr%2
                ans[prev_L] = cr//2 + cl//2 + cl%2
                cr = 0
            prev_R = i
            cr += 1
        elif x == "L":
            if prev == "R":
                cl = 0
                prev_L = i
            cl += 1
        # print(ans)
        prev = x
    
    ans[prev_R] = cr//2 + cl//2 + cr%2
    ans[prev_L] = cr//2 + cl//2 + cl%2

    print(*ans)

    
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 47932
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int w, h;
vector<VB> a(20, VB(20));
vector<VB> v(20, VB(20));
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };

void Dfs(int x, int y) {
	if (x < 0 || y < 0 || x >= w || y >= h || !a[y][x] || v[y][x])return;
	v[y][x] = true;
	rep(i, 4)Dfs(x + dx[i], y + dy[i]);
}

int main() {
	while (cin >> w >> h && (w || h)) {
		VS s(h); rep(i, h)cin >> s[i];
		int sx, sy;
		rep(i, h) {
			rep(j, w) {
				if (s[i][j] == '.')a[i][j] = true;
				if (s[i][j] == '@') { a[i][j] = true; sx = j; sy = i; }
				if (s[i][j] == '#')a[i][j] = false;
			}
		}
		rep(i, 20)rep(j, 20)v[i][j] = false;

		Dfs(sx, sy);

		int ans = 0;
		rep(i, h) {
			rep(j, w)ans += v[i][j];
		}
		Cout(ans);
	}
}


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

int main(){
  int N, H=0, Flag=0;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; ++i){
    cin >> V.at(i);
  }
  
  for (int i = 0; i < N-1; ++i){
    if(V.at(i)-V.at(i+1) > 1){
      Flag = 1;
      break;
    }else if(V.at(i)-V.at(i+1) == 1){
      if(V.at(i) < H){
        Flag = 1;
        break;
      }else{
        H = max(H,V.at(i));
      }
    }
  }
  
  if(Flag == 0){
    cout << "Yes" << endl;
  }else if (Flag == 1){
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}

////////////////////////////////////////////////////////////////////
ll now;
vector <ll> x[100008];
vector <ll> y[100008];
ll cx[100008];
ll cy[100008];
ll vx[100008];
ll vy[100008];

void dfs(ll k, ll t){
    if(t==1){
if(cx[k]==1){
    return;
}
cx[k]=1;
if(x[k].size()>=1){
vx[now]++;}

for(int i=0;i<x[k].size();i++){
    if(cy[x[k][i]]==0){
        dfs(x[k][i], 2);
    }
}
    }


    if(t==2){
if(cy[k]==1){
    return;
}
cy[k]=1;
if(y[k].size()>=1){
vy[now]++;}

for(int i=0;i<y[k].size();i++){
    if(cx[y[k][i]]==0){
        dfs(y[k][i], 1);
    }
}
    }



return ;
    }









int main() {
    now=-1;
ll n;
cin>>n;

for(int i=1;i<=n;i++){
    ll p,q;
    cin>>p>>q;
    x[p-1].push_back(q-1);
    y[q-1].push_back(p-1);
}


for(int i=0;i<=100007;i++){
cx[i]=0;
cy[i]=0;
vx[i]=0;
vy[i]=0;
}

ll sum=0;

for(int i=0;i<=100007;i++){
    now++;
    if(cx[i]==0){
        dfs(i, 1);
    }
}

for(int i=0;i<=100007;i++){
sum+=vx[i]*vy[i];
}

sum-=n;

cout<<sum<<endl;


return 0;

}


Measured memory_bytes: 13440
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 100 * 1000 + 10;

double s[MAXN];
double t;

int main()
{
    int n, k;
    while(cin >> n >> k && n)
    {
        s[0] = 0;
        REP(n){cin >> t; s[i+1] = s[i] + t;}
        double ans = 0;
        for(int i = 0;i + k < n;i++){ ans = max(ans, s[i+k] - s[i]);}

        printf("%d\n", (long long)ans);
    }

    return 0;
}

Measured memory_bytes: 1688
#include <stdio.h>

int main(void) {

    char buf[16];
    char *p;
    int a,b,c,n;

    p = fgets(buf, 16, stdin);
    n = sscanf(buf, "%d %d %d", &a, &b, &c);
    if(a == b) n--;
    if((c == b) || (a == c)) n--;

    printf("%d\n", n);
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s.back() << endl;
    return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
mod=2019

min=0
if L//mod == R//mod:
    L%=mod
    R%=mod
    min=mod
    for i in range(L,R):
        for j in range(i+1,R+1):
            if min > i*j % mod:
                min=i*j % mod
        if min==0:
            break
print(min)


Measured memory_bytes: 2940
//C
//#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>


#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Hang in there!

using namespace std;


int main() {
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2 << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  int m,n;
  int initial;
  int year;
  bool torf;
  double nenri;
  int tesuryo;

  int zandaka;
  int rishi;

  int max;

  cin >> m;
  
  for(int i=0;i<m;i++){// ???????????????????????°???????????????

    cin >> initial;
    cin >>year;
    cin >>n;

    max=0;
    
      for(int j=0;j<n;j++){ //?????¨????????°???????????????

	zandaka=initial;
	rishi=0;
	
	cin >> torf >> nenri >> tesuryo;
      
	if(!torf){
	  for(int k=0;k<year;k++){
	    rishi+=(int)(zandaka*nenri);
	    zandaka=zandaka-tesuryo;
	  }

	  if(max<zandaka+rishi)
	    max=zandaka+rishi;
	}

	else if(torf){
	  for(int l=0;l<year;l++){
	    rishi=(int)(zandaka*nenri);
	    zandaka=zandaka+rishi-tesuryo;
	  }

	  if(max<zandaka)
	    max=zandaka;

	}

      }
      cout << max << endl;
  }
  return 0;

}

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

int main()
{
	int N, T;
	int minv = INT_MAX;
	cin >> N >> T;
	for ( int i = 0; i < N; i++ ) {
		int c, t;
		cin >> c >> t;
		if ( t <= T ) {
			minv = min(minv, c);
		}
	}

	if ( minv == INT_MAX ) {
		cout << "TLE" << endl;
	} else {
		cout << minv << endl;
	}

	return ( 0 );
}


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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int a, b, c, d;

int main()
{
	a = gi();
	for (int i = 1; i <= a; i+=1)
	{
		double x = 1. * i * 1.08;
		if ((int)(x) == a) {printf("%d\n", i); return 0;}
	}
	puts(":(");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
//long long int aa[100000];
int main() {
	//C
	int n;
	cin >> n;

	int i,j,k;
	i = n;
	while (1) {
		if (i % 2 == 1) {
			if (i == 1) {
				cout << "No";
				return 0;
			}
			else {
				break;
			}
		}
		else {
			i = i / 2;
		}
	}
	j = n;
	k = 1;
	while (j > 0) {
		if (j > 1) {
			j = j - (j % 2);
			j = j / 2;
			k = k * 2;
		}
		else {
			break;
		}
	}

	cout << "Yes\n";

	cout << 3 + n;
	cout << ' ';
	cout << 1 + n;
	cout << '\n';

	cout << 1 + n;
	cout << ' ';
	cout << 2 + n;
	cout << '\n';

	cout << 2 + n;
	cout << ' ';
	cout << 3;
	cout << '\n';

	cout << 3;
	cout << ' ';
	cout << 1;
	cout << '\n';

	cout << 1;
	cout << ' ';
	cout << 2;
	cout << '\n';

	if (n > 3) {
		cout << 1;
		cout << ' ';
		cout << 4;
		cout << '\n';
		cout << 1;
		cout << ' ';
		cout << 5 + n;
		cout << '\n';
		if (n % 2 == 1) {
			for (i = 4; i < n; i++) {
				cout << i;
				cout << ' ';
				cout << i + 1;
				cout << '\n';
			}
			for (i = 4; i < n; i = i + 2) {
				cout << i + n;
				cout << ' ';
				cout << i + 1 + n;
				cout << '\n';
				if (i + 3 <= n) {
					cout << i + n;
					cout << ' ';
					cout << i + 3 + n;
					cout << '\n';
				}
			}
		}
		else {
			for (i = 4; i < n - 1; i++) {
				cout << i;
				cout << ' ';
				cout << i + 1;
				cout << '\n';
			}
			for (i = 4; i < n - 1; i = i + 2) {
				cout << i + n;
				cout << ' ';
				cout << i + 1 + n;
				cout << '\n';
				if (i + 3 <= n - 1){
					cout << i + n;
					cout << ' ';
					cout << i + 3 + n;
					cout << '\n';
				}
			}
			if (n % 4 == 2) {
				cout << n;
				cout << ' ';
				cout << 2 * n - 1;
				cout << '\n';
				cout << 2;
				cout << ' ';
				cout << 2 * n;
				cout << '\n';

			}
			else {
				cout << n;
				cout << ' ';
				cout << k;
				cout << '\n';
				cout << 2 * n;
				cout << ' ';
				cout << n-k+1+n;
				cout << '\n';

			}

		}
	}



	return 0;
		//A
	/*int n;
	cin >> n;

	int i;

	for (i = 0; i < n; i++) {
		cin >> aa[i];
	}
	long long int  a, b, c;
	a = 0;
	b = 0;
	c = 0;
	int counta = 0;
	int countb = 0;
	int countc = 0;

		for (i = 0; i < n; i++) {
			if (counta == 0) {
				counta++;
				a = aa[i];
			}
			else {
				if (aa[i] == a) {
					counta++;
				}
				else {
					if (countb == 0) {
						countb++;
						b = aa[i];
					}
					else {
						if (aa[i] == b) {
							countb++;
						}
						else {
							if (countc == 0) {
								countc++;
								c = aa[i];
							}
							else {
								if (aa[i] == c) {
									countc++;
								}
								else {
									cout << "No";
									return 0;
								}
							}
						}
					}
				}
			}
		}
		if ((counta == countb) && (countb == countc)) {
			if (a == (b ^ c)) {
				cout << "Yes";
			}
			else {
				cout << "No";
			}
			return 0;
		}
		else if ((counta == n) && (a == 0)) {
			cout << "Yes";
		}
		else if ((counta == 2 * countb) && (b == 0) && (countc == 0)) {
			cout << "Yes";
		}
		else if ((2 * counta == countb) && (a == 0) && (countc == 0)) {
			cout << "Yes";
		}
		else {
			cout << "No";
			return 0;
		}
	*/
}

Measured memory_bytes: 2816
//package sample;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		int T, X;
		Scanner sc = new Scanner(System.in);

		T = sc.nextInt();
		X = sc.nextInt();

		System.out.println((double)T/X);

		sc.close();
	}

}


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

int main(){
  int m, f, b;
  cin >> m >> f >> b;
  if(m >= b){
    cout << 0 << endl;
  }else{
    if((m + f) >= b){
      cout << b - m << endl;
    }else{
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 3124
N = int(input())
S = input()
ans = [] 
for i in range(len(S)):
  if ord(S[i]) + N > 90:
    ans.append(chr(ord(S[i]) + N - 90 + 64))
  else:
  	ans.append(chr(ord(S[i])+N))
ans = ''.join(ans)
print(ans)

Measured memory_bytes: 3060
import sys
#a = []
#for l in sys.stdin:
#    a.append(int(l))
k = int(input())
s = input()
if len(s) <= k:
   print(s)
else:
   for i in range(k):
      print(s[i], end="")
   for i in range(3):
      print('.', end="")

Measured memory_bytes: 9148
import java.util.*


// グラフの中から，取り除くとグラフがサブグラフに分割されるようなエッジの本数を求める


// 思考
// エッジを一つずつ削って，全部のノードにたどり着けるか確認する？？
// O(E^2) の計算量になるか？
// 辺の数は 最大50本 -> 行けそう
// もっと効率的に求める方法もありそうだがとりあえず

// 探索方法
// ・全域木を作成する
// ・UnionFind Tree を作る？？が良いかも？？ 親子ではなく，循環が発生するかもしれないから面倒？？
// ツリーを作り直すのは面倒か？？　一旦全域探索をする方針で行く


// ノード１から順にグループにノードを追加
// 追加時に，自身を含めた，つながる事のできるノード 別配列に管理
// つながる事のできるものを順次追加していく？


// 計算量的には？？ E^2


fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val nodes = Array(n) { mutableListOf<Int>() }

    // 無向グラフの隣接リストを作成
    for (i in 0 until m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        nodes[a - 1].add(b - 1)
        nodes[b - 1].add(a - 1)
    }

    // 配列のコピーを作成し，エッジを一つ削除し，判定 を繰り返す
    var cnt = 0
    for (i in 0 until nodes.size) {
        for ( j in 0 until nodes[i].size) {
            var tmp = Array(n) {i: Int -> nodes[i].toMutableList()}
            tmp[i].removeAt(j)
            if (!isConnected(tmp)){
               cnt += 1
            }
        }
    }

    print(cnt)
}

fun isConnected(nodes: Array<MutableList<Int>>): Boolean {

    var cur = 0
    var visited = mutableListOf(0)
    val next: Queue<Int> = ArrayDeque<Int>()
    next.addAll(nodes[0])

    while (!next.isEmpty()) {
        cur = next.poll()!!
        if (!visited.contains(cur)) {
            visited.add(cur)
            next.addAll(nodes[cur].filter { !visited.contains(it) })
        }
        if (visited.size == nodes.size) {
            return true
        }
    }
    return false
}

Measured memory_bytes: 38820
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(0, n+1, r):
    for j in range(0, n+1, g):
        tmp = n - (i+j)
        if tmp < 0:
            break
        if tmp%b == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 2940