akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
void Solve(){
	int n, m;
	cin>>n>>m;
	vector<int> g[n + 1];
	while(m--){
		int u, v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<bool> vst(n + 1);
	queue<int> q;
	vector<int> res(n + 1);
	q.push(1);
	vst[1] = true;
	while(!q.empty()){
		int current = q.front();
		q.pop();
		for(auto x: g[current]){
			if(!vst[x]){
				vst[x] = true;
				q.push(x);
				res[x] = current;
			}
		}
	}
	cout<<"Yes\n";
	for(int i = 2; i <= n; i++) cout<<res[i]<<'\n';
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T = 1;
	//cin>>T;
	while(T--){
		Solve();
	}
}

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

int main(){
  string s;
  int ans=0;
  cin >> s;
  if(s[1]=='1') ans+=1;
  if(s[2]=='1') ans+=1;
  if(s[0]=='1') ans+=1;
  cout << ans << endl;
}
  


Measured memory_bytes: 256
import java.util.*;
import java.lang.Integer;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int P = sc.nextInt();
      
      P = P + A * 3;
      int ApplePie = P / 2;
      
      System.out.println(ApplePie);
    }
}


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

using namespace std;
typedef long long ll;
typedef long  double lb;
int mod=1e9+7;
const int N=1e5+5;
bool cmp(int x,int y){return x>y;}
int main()
{
    int n,m;
    double sum=0;
    cin>>n>>m;
    int a[200];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a+1,a+1+n,cmp);
    double k=1.0/4/m;
    for(int i=1;i<=m;i++){
        double kk= a[i]*1.0/sum;
        if(kk<k) {cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
table=[]
for i in range(M):
    a,b=map(int,input().split())
    table.append((a-1,b-2))
table.sort()
s=0
t=N
ans=0
for a,b in table:
    if t<a:
        ans+=1
        s=a
        t=b
    else:
        s=a
        t=min(t,b)
        #print(s,t)
print(ans+1)
    

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

int main(void){
    int N,M;cin>>N>>M;
    vector<int>ans(N,0);
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        ans[a-1]++;
        ans[b-1]++;
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

int main() {
  int N;
  string s[100];
  cin >> N;
  int i;
  int a = 0;
  for (i = 0; i < N; i++) {
    cin >> s[i];
    if(s[i] == "Y"){
      a++;
    }
  }
  if(a >= 1){
    cout << "Four" << endl;
  }else {
    cout << "Three" << endl;
  }

}


Measured memory_bytes: 256
// dile a la jardinera que traigo flores
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define tm1 ff
#define tm2 ss.ff
#define tm3 ss.ss
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define all(v) (v).begin(),(v).end()
#define FER(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define IFR(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define N 100005
#define M 27
#define N1 150005
#define N2 200005
#define MAXN 4353546332
//#define mod 1000000007
using namespace std;
typedef int ll;
typedef pair<ll,ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif

int main(){
  fastio;
  ll a,b; cin>>a>>b;
  vi v; v.pb(a), v.pb(b);
  sort(all(v)); ll flag=1;
  for(auto xd: v) if(xd%2==0) flag=0;
  flag? cout<<"Yes"<<"\n":cout<<"No"<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
char s[12345];
int main()
{
	cin>>s;
	int len=strlen(s);
	long long ans=0;
	for(int t=0;t<(1<<(len-1));t++)
	{
		long long num=s[0]-'0';
		for(int i=0;i<len-1;i++)
		{
			if(t&(1<<i))
		{
				ans+=num;
				num=0;
		}
		num=num*10+s[i+1]-'0';
	}
	ans+=num;
	}
	cout<<ans<<endl;
	return 0;
}

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


def solve(N: int, P: "List[int]"):
    sorted_lis = sorted([(n, i) for i, n in enumerate(P)])
    max_con = 1
    con_cnt = 0
    pre_idx = N
    for _, i in sorted_lis:
        if i > pre_idx:
            con_cnt += 1
        else:
            max_con = max(max_con, con_cnt)
            con_cnt = 1
        pre_idx = i
    max_con = max(max_con, con_cnt)
    print(N - max_con)
    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()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34004
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int array_sum_from_i(vector<int> & data, int i) {
	if (i == data.size()) {
		return 0;
	}
	int s = array_sum_from_i(data, i + 1);
	return data.at(i) + s;
}

int array_sum(vector<int> & data) {
	return array_sum_from_i(data, 0);
}

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> d(n);

	d[0] = k + a[0] - a[n-1];
	for(int i=1; i<n; i++) d[i] = a[i] - a[i - 1];

	int ind = 0;
	rep(i, n) {
		if (d[ind] < d[i]) ind = i;
	}

	int ans = array_sum(d) - d[ind];

	dunk(ans);
	return 0;
}


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

const int max_val = 1000;

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

	int diff_min = max_val;

	string s;
	cin >> s;

	int digits[s.size()];
	for (int i = 0; i < s.size(); ++i)
		digits[i] = s[i] - '0';

	for (int i = 0; i < s.size()-2; ++i) {
		int number = digits[i] * 100 + digits[i+1] * 10 + digits[i+2];
		diff_min = min(diff_min, abs(number-753));
	}

	cout << diff_min << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int n;
  cin >> n;
  int c = 0;
  for(int i = 0; i < n; i++) {
    ll b;
    cin >> b;
    if(c > 0) {
      for(int j = 0; j < c; j++) {
        b = b * 3;
      }
    }
    for(int j = 0; j < 10e5; j++) {
      if(b % 2 == 0) {
        b = b / 2;
        c++;
      } else {
        break;
      }
    }
  }
  cout << c << endl;
}

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

using namespace std;

int main()
{
   int n,m;
   cin>>n>>m;
   if (n==1 && m==0)
   {
       cout<<0;
       return 0;
   }
   vector<int>a(n,-1);
   while(m--)
   {
       int s,c;
       cin>>s>>c;s--;
       if (a[s]!=-1 && a[s]!=c || (s==0 && c==0 && n!=1))
       {
           cout<<-1;
           return 0;
       }
       a[s]=c;
   }
   if (a[0]==-1)
    a[0]=1;
   for (int i=0;i<n;i++)
    if (a[i]!=-1)
         cout<<a[i];
   else
    cout<<0;
    return 0;
}

Measured memory_bytes: 256
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	int dp[n];
	vi stones(n);
	for(int i=0;i<n;cin>>stones[i++]);
	dp[0] = 0;
	dp[1] = abs(stones[1] - stones[0]);
	for(int i=2;i<n;i++) {
			dp[i] = min(dp[i-1] + abs(stones[i] - stones[i-1]), dp[i-2] + abs(stones[i] - stones[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}





Measured memory_bytes: 1024
gets
a = gets.chomp.split(" ").map(&:to_i)
q = gets.to_i

hash = Hash.new{0}
ans = 0

a.each do |e|
  ans += e
  hash[e] += 1
end

q.times do
  b,c = gets.chomp.split(" ").map(&:to_i)
  ans += (c-b)*hash[b]
  hash[c] += hash[b]
  hash[b] = 0
  p ans
end

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int n;
    cin >> n;
    int cnt = 1;
    for(int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        if(temp == cnt)
            cnt++;
    }

    if(cnt == 1)
        cout << "-1";
    else
        cout << n - cnt + 1;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>

int main() {
	int n, m; std::cin >> n >> m;
	std::vector<std::vector<int>> node(n);
	for (auto i = 0; i < m; ++i) {
		int a, b; std::cin >> a >> b; --a; --b;
		node[a].push_back(b);
	}
	std::vector<std::vector<bool>> can_reach(n, std::vector<bool>(n, false));
	std::queue<std::pair<int, int>> queue;
	for (auto i = 0; i < n; ++i) {
		queue.emplace(i, i);
		can_reach[i][i] = true;
	}
	while (!queue.empty()) {
		auto top = queue.front(); queue.pop();
		for (const auto next : node[top.second]) if (!can_reach[top.first][next]) {
			queue.emplace(top.first, next);
			can_reach[top.first][next] = true;
		}
	}
	for (auto i = 0; i < n; ++i) {
		bool first = true;
		for (auto j = 0; j < n; ++j) if (can_reach[i][j] && can_reach[j][i]) {
			if (!first) std::cout << ' ';
			std::cout << j + 1;
			first = false;
		}
		std::cout << '\n';
	}
}



Measured memory_bytes: 4220
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    if ( n % 2 == 0 ) {
        string a = s.substr(n/2);
        string b = s.substr(0, n/2);
        if (a == b) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }       
    } else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			long sumA = 0;
			long sumB = 0;
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				sumA += a[i];
			}
			int[] b = new int[n];
			for (int i = 0; i < n; i++) {
				b[i] = in.nextInt();
				sumB += b[i];
			}
			long total = sumB - sumA;
			if (total < 0) {
				out.println("No");
				return;
			}
			long min = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] >= b[i]) {
					min += a[i] - b[i];
				} else if (a[i] % 2 != b[i] % 2) {
					min += 1;
				}
			}
			if (min > total) {
				out.println("No");
			} else {
				out.println("Yes");
			}
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 27604
// author: erray
#include<bits/stdc++.h>
 
using namespace std;
 
int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int q = j + 1; q < n; ++q) {
        if (a[i] == a[j] || a[j] == a[q]) continue;
        ans += (a[i] + a[j] > a[q]);
      }
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 先攻はA[i] > B[i]のものを1つだけ残して他を全部0にするのが最適

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int>B(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }
    int k = INT_MAX;
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i] > B[i]) k = min(k, B[i]);
        ans += A[i];
    }
    if (k != INT_MAX) ans -= k;
    else ans = 0;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
n=int(input())
A=[0]
A+=map(int,input().split())
A.append(0)
dist=0
for i in range(1,n+2):
    dist+=abs(A[i]-A[i-1])
for i in range(1,n+1):
    print(dist-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 14048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n % 2 == 0) {
			System.out.println(n);
		} else {
			int ans = n * 2;
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[123];

int main(){
	int n; scanf("%d", &n); n--;
	REP(i, n) scanf("%d", a+i);
	int ans = a[0] + a[n-1];
	REP(i, n-1) ans += min(a[i], a[i+1]);
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);
int main()
{   
 
    vector<long long> vec(0);
    vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    uint32_t sum = 0;
    uint64_t num;
    uint32_t res_i = 0;
    string str_temp, str_temp2;
    uint32_t temp, temp2;
    int32_t i, j, k, l, m, n, o, size;
    uint32_t count = 0;
    string str;
    uint8_t k_flag;
 
    cin >> str;
    size = str.size();
 
    k_flag = FALSE;

    for (i = 0; i < size; i++) {
        str_temp = str[size - i - 1];
        if (i != size - 1) {
            str_temp2 = str[size - i -2];
            temp2 = atoi(str_temp2.c_str());
        }
        temp = atoi(str_temp.c_str());
        // cout << temp << endl;

        if (k_flag == TRUE) {
            temp++;
        }

        if (temp > 5) {
            sum += 10 - temp;
            k_flag = TRUE;
            if (((i + 1) == size)) {
                sum++;
            }
        } else if (temp == 5) {
            if (temp2 <= 4){
                sum += temp;
                k_flag = FALSE;
            } else {
                sum += temp;
                k_flag = TRUE;
            }
        } else {
            sum += temp;
            k_flag = FALSE;
        }
    }
  
    cout << sum << endl;

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 1412
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	ULL GCD(ULL a, ULL b) { return (b == 0) ? a : GCD(b, a % b); }

	void Solve() {
		UL N; cin >> N;
		vector<UL> A(N), B(N);
		rep(i, N) cin >> A[i];
		rep(i, N) cin >> B[i];
		vector<UL> Ap, Bp;
		rep(i, N) {
			if (i == 0) {
				Ap.push_back(A[N - 1] ^ A[0]);
				Bp.push_back(B[N - 1] ^ B[0]);
			}
			else {
				Ap.push_back(A[i] ^ A[i - 1]);
				Bp.push_back(B[i] ^ B[i - 1]);
			}
		}
		rep(i, N - 1) Ap.push_back(Ap[i]);
		vector<UL> bi(N);
		bi[0] = (UL)-1;
		{
			UL p = 1, q = -1;
			while (p < bi.size()) {
				if (q == (UL)-1) {
					bi[p] = 0;
					p++; q = 0;
				}
				else if (Bp[q] == Bp[p - 1]) {
					bi[p] = bi[p - 1] + 1;
					p++; q++;
				}
				else {
					q = bi[q];
				}
			}
		}
		vector<UL> founds;
		{
			UL p = 0, q = 0;
			while (p < Ap.size()) {
				if (Ap[p] == Bp[q]) {
					p++; q++;
					if (q == Bp.size()) {
						founds.push_back(p - N);
						q = bi[q - 1] + 1;
					}
				}
				else {
					q = bi[q];
					if (q == (UL)-1) {
						p++; q = 0;
					}
				}
			}
		}
		for (UL i : founds) {
			cout << i << " " << (A[i] ^ B[0]) << endl;
		}
		/*
		string s, t; cin >> s >> t;

		vector<UL> bi(t.size());
		bi[0] = (UL)-1;
		{
			UL p = 1, q = -1;
			while (p < bi.size()) {
				if (q == (UL)-1) {
					bi[p] = 0;
					p++; q = 0;
				}
				else if (t[q] == t[p - 1]) {
					bi[p] = bi[p - 1] + 1;
					p++; q++;
				}
				else {
					q = bi[q];
				}
			}
		}
		vector<UL> founds;
		{
			UL p = 0, q = 0;
			while (p < s.size()) {
				if (s[p] == t[q]) {
					cout << q << " ";
					p++; q++;
					if (q == t.size()) {
						founds.push_back(p - t.size());
						q = bi[q - 1] + 1;
					}
				}
				else {
					q = bi[q];
					if (q == (UL)-1) {
						cout << q << " ";
						p++; q = 0;
					}
				}
			}
			cout << endl;
		}
		for (UL f : founds) cout << f << " "; cout << endl;
		*/
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 9960
#include<stdio.h>
int main()
{
  int a,b,c,x,y,d;
  scanf("%d %d %d",&a,&b,&c);
  x=a+b;
  y=a+c;
  d=b+c;
  if(x==c)
    printf("Yes\n");
  else if(y==b)
    printf("Yes\n");
  else if(d==a)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
#define mp make_pair
#define fr first
#define sc second
#define pb push_back
#define lc (x<<1)
#define rc ((x<<1)|1)
const int N=100005;
int a[N];
LL b[N];
LL cal(int n,int P){
    LL ans=0;
    for (int i=1;i<=n;i++) if ((a[i]|P)==P) ans+=b[i];
    return ans;
}
int main(){
   // freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int i,n,K,P=0;LL ans=0;
    scanf("%d%d",&n,&K);K++;
    for (i=1;i<=n;i++) scanf("%d%lld",&a[i],&b[i]);
    for (i=30;i>=0;i--){
        if (!(K&(1<<i))) continue;
        P|=((1<<i)-1);
        ans=max(ans,cal(n,P));
        P^=((1<<i)-1);
        P|=(1<<i);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1408
input = STDIN.gets.split(' ')
a = input[0].to_f
b = input[1].to_f
c = input[2].to_f * (Math::PI / 180.0)

s = 0.5 * a * b * Math.sin(c)
l = a + b + Math.sqrt(a*a + b*b - 2 * a * b * Math.cos(c))
h = b * Math.sin(c)

puts s
puts l
puts h

Measured memory_bytes: 6172
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
ll N,X,A[100005];
ll res=0;
int main()
{
	scanf("%lld%lld",&N,&X);
	for(int i=0;i<N;i++)scanf("%lld",&A[i]);
	if(A[0]>X)
	{
		res+=min(A[0]-X,A[0]);
		A[0]=max(X,0LL);
	}
	for(int i=1;i<N;i++)
	{
		if(A[i]+A[i-1]>X)
		{
			res+=(A[i]+A[i-1])-X;
			A[i]-=(A[i]+A[i-1])-X;
		}
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main() {
	int N;
	std::cin >> N;

	for( int i=0; i<N; ++i ) {
		int a=0, b=0, c=0;
		std::cin >> a >> b >> c;
		std::cout << (( a*a + b*b == c*c )?"YES":(( b*b + c*c == a*a )?"YES":(( c*c + a*a == b*b )?"YES":"NO"))) << std::endl; 
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int n,k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i,n) {
		cin >> h[i];
	}
	sort(h.begin(), h.end(), std::greater<ll>());
	ll acc = 0;
	for(int i=k; i<n; i++) {
		acc += h[i];
	}
	cout << acc << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i<N;i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  int cnt = 1;
  int cur = vec.at(0);
  
  for (int i = 0; i < N-1; i++) {
    if (cur < vec.at(i+1)) {
      cur = vec.at(i+1);
      cnt++;
    }
  }
  cout << cnt << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string ans = "safe";
    int a, b;
    cin >> a >> b;
    if(b >= a) ans = "unsafe";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;
ll dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
ll dy[9] = {-1,  0,  1,-1, 0, 1,-1, 0, 1};

int main(){    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<double> t(N);
    vector<double> v(N);
    REP(i, N){
        cin >> t[i];
    }
    REP(i, N){
        cin >> v[i];
    }
    ll T = 0;
    REP(i, N){
        T += t[i];
    }
    
    vector<double> maxV(2*T+1, (double)INF);
    int cT = 0;
    REP(i, N){
        REP(ti, t[i]){
            int t1 = cT + ti * 2;
            int t2 = cT + ti * 2 + 1;
            maxV[t1] = min(maxV[t1], v[i]);
            maxV[t2] = min(maxV[t2], v[i]);
        }
        cT += t[i] * 2;
        maxV[cT] = min(maxV[cT], v[i]);
    }
    
    maxV[0] = maxV[T*2] = 0.0;
    REP(ti, 2*T+1){
        maxV[ti+1] = min(maxV[ti+1], maxV[ti]+0.5);
    }
    RREP(ti, 2*T+1){
        maxV[ti] = min(maxV[ti], maxV[ti+1]+0.5);
    }
    double ans = 0.0;
    REP(i, 2*T+1){
        ans += (maxV[i] + maxV[i+1]) * 0.5 / 2.0;
    }
    printf("%.8f\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#define INF 10000
using namespace std;

struct edge {
    int from, to, cost;
};

edge es[100];
int d[11];
int n,maxV=0;

int shortest_path(int s){
    int sum=0;
    for(int i=0;i<maxV+1;i++){
        d[i] = INF;
    }
    d[s] = 0;
    while(1){
        bool update = false;
        for(int i=0;i<2*n;i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update){
            break;
        }
    }
    for(int i=0;i<maxV+1;i++){
        if(d[i] != INF){
        	// cout << i << " " << d[i] << endl;
            sum += d[i];
        }
    }
    return sum;
}

int main(void){
    
    while(cin >> n && n){
    	maxV = 0;
        int a, b, c, tmp, min,sum2=100000;
        for(int i=0;i<n;i++){
            cin >> a >> b >> c;
            es[i].from = a;
            es[i].to = b;
            es[i].cost = c;

            es[i+n].from = b;
            es[i+n].to = a;
            es[i+n].cost = c;
            
            if(maxV < b){
           		maxV = b;
           	}
           	if(maxV < a){
           		maxV = a;
           	}
           	
        }
        //??????????????°?????????
        for(int i=0;i<maxV+1;i++){
            int tmp = shortest_path(i);
            // cout << tmp << endl;
            if(sum2 > tmp){
                sum2 = tmp;
                min = i;
            }
        }
        cout << min << " " << sum2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
string str;
int n;
int longestRepeatedSubstring()
{
	int LCSRe[n+1][n+1];

	memset(LCSRe, 0, sizeof(LCSRe));

	string res;
	int res_length = 0;

	int i, index = 0;
	for (i=1; i<=n; i++)
	{
		for (int j=i+1; j<=n; j++)
		{
			if (str[i-1] == str[j-1] &&
				LCSRe[i-1][j-1] < (j - i))
			{
				LCSRe[i][j] = LCSRe[i-1][j-1] + 1;
				if (LCSRe[i][j] > res_length)
				{
					res_length = LCSRe[i][j];
					index = max(i, index);
				}
			}
			else
				LCSRe[i][j] = 0;
		}
	}
	if (res_length > 0)
		for (i = index - res_length + 1; i <= index; i++)
			res.push_back(str[i-1]);

	return res.size();
}

int main()
{
    cin>>n>>str;
	cout << longestRepeatedSubstring();
	return 0;
}


Measured memory_bytes: 97920
s=list(input())
l=[chr(i) for i in range(97,97+26)]
lc=[]
for j in l:
  if j in s:
    c=0
    t=s
    while len(set(t))!=1:
      u=[]
      for k in range(len(t)-1):
        if t[k]==j or t[k+1]==j:u.append(j)
        else:u.append(t[k])
      t=u
      c+=1
    lc.append(c)
print(min(lc))

Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {

        //var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var S = Console.ReadLine();
        var dic = new Dictionary<char,int>();

        for (int i = 0; i < S.Length; i++)
        {
            if (dic.ContainsKey(S[i]))
            {
                dic[S[i]]++;
            }
            else
            {
                dic.Add(S[i],1);
            }
        }
 
        if(dic.Count == 1)
        {
            if(S.Length == 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");

            }
        }
        else if (dic.Count == 2)
        {
            var sum = 0;
            foreach (var item in dic)
            {
                sum += item.Value;
            }

            if(S.Length == 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");

            }
        }
        else
        {
            var max = 0;
            var min = long.MaxValue;
            foreach (var item in dic)
            {
                max = Math.Max(max,item.Value);
                min = Math.Min(min,item.Value);

                
            }
            if (max - min <= 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");

            }
        }
        
    }



}


Measured memory_bytes: 26576
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_resistors_in_parallel(void) {
	int n;
	int a;
	cin >> n;
	double sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += (1.0 / a);
		//cout << sum << endl;
	}

	cout << (1 / sum) << endl;


}

int main()
{
    b_resistors_in_parallel();

    return 0;
}

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

int main() {
    ll H, W;
    cin >> H >> W;

    ll ans = 0;
    if(H==1||W==1){
        cout << 1 << endl;
        return 0;
    }
    ans += ((H + 1) / 2) * ((W + 1) / 2);
    ans += (H / 2) * (W / 2);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m,v,i,h,w;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w;
  ll ans = INF;
  if(h%3==0||w%3==0){
    cout<<0<<endl;
    return;
  } else {
    minch(ans,w);
    minch(ans,h);
  }

  repl(i,1,h/2+1){
    ll Smax = 0,Smin = INF;
    if(w%2==0){
      Smax = max(w*i,(h-i)*(w/2));
      Smin = min(w*i,(h-i)*(w/2));
    } else {
      Smax = max(w*i,(h-i)*(w/2+1));
      Smin = min(w*i,(h-i)*(w/2));
    }
    minch(ans,Smax-Smin);
  }
  repl(i,1,w/2+1){
    ll Smax = 0,Smin = INF;
    if(h%2==0){
      Smax = max(h*i,(w-i)*(h/2));
      Smin = min(h*i,(w-i)*(h/2));
    } else {
      Smax = max(h*i,(w-i)*(h/2+1));
      Smin = min(h*i,(w-i)*(h/2));
    }
    minch(ans,Smax-Smin);
  }
  cout<<ans<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int x,n;
    cin>>x>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];

    int ans=-100;
    for(int i=-10;i<110;i++){
        bool ok=true;
        rep(j,n){
            if(i==p[j]) ok=false;
        }

        if(!ok) continue;
        if(abs(ans-x)>abs(i-x)) ans=i;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3600
n,m = map(int,input().split())
ans = 0
sc = []
for i in range(m):
    s, c = map(int,input().split())
    sc.append([s,c])
for i in range(1000):
    flag = True
    if len(str(i)) != n:
        continue
    else:
        for j in range(len(sc)):
            if str(i)[sc[j][0]-1] != str(sc[j][1]):
                flag = False
    if flag:
        print(i)
        exit()
print(-1)


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

using namespace std;

int main()
{
    int n,a[101],i,j,d[100001],k=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
           int diff=abs(a[i]-a[j]);
           d[k++]=diff;
        }
    }
   sort(d,d+k);
   cout<<d[k-1];
    return 0;
}


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

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

int main(){
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<int,int>> p(n);

    int a;
    REP(i,n){
        cin >> a;
         p[i] = make_pair(a, i);
    }
    sort(All(p));

    cout << p[0].sc +1;
    REAP(i,1,n){
        cout <<" " << p[i].sc+1;
    }
    cout << endl;
}


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

using namespace std;

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

	int A,B,M;
	cin>>A>>B>>M;

	vector<int> a(A);
	vector<int> b(B); 
	int amin=1e5+1;
	int bmin=1e5+1;
	int cmin=2e5+1;
	for(int i=0;i<A;i++){ 
		cin>>a[i];
		amin=min(amin,a[i]);

	} 
	for(int i=0;i<B;i++){ 
		cin>>b[i];
		bmin=min(bmin,b[i]);
	}
	vector<int> c(M);
	int x,y;

	for(int i=0;i<M;i++){ 
		cin>>x>>y>>c[i];
		x--;
		y--;
		cmin=min(cmin,a[x]+b[y]-c[i]);
	} 
	cout<<min(amin+bmin,cmin);


	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()


int main(){
  ll N,M,Q;cin>>N>>M>>Q;
  int v[N+1][N+1];
  rep(i,N+1)rep(j,N+1)v[i][j]=0;
  rep(i,M){
    ll l,r;cin>>l>>r;
    v[l][r]++;
  }
  for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)v[i][j]+=v[i][j-1];
	for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)v[i][j]+=v[i-1][j];
  rep(i,Q){
    ll p,q;cin>>p>>q;
    cout << v[q][q]+v[p-1][p-1]-v[q][p-1]-v[p-1][q] << endl;
  }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
string s[8]={"","SAT","FRI","THU","WED","TUE","MON","SUN"};
int main() 
{
	string st;
	cin>>st;
	for(int i=1;i<=7;i++) if(s[i]==st) cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    rep(i,n) {
        int c = (i+1)/10000 + (i+1)/1000%10 + (i+1)/100%10 + (i+1)/10%10 + (i+1)%10;
        if (a <= c && c <= b) ans += i+1;
    }
    ct(ans);
}

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

int main() {
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d;
	cin >> n;
	ll sa = min(q * 4, min(h * 2, s));
	ll da = min(d, sa * 2);
	if (n % 2 == 0) cout << da * (n / 2) << endl;
	else cout << sa + da * (n / 2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
int main()
{
    ll n,k;
    cin>>n>>k;
    if(k==1)
    {
        cout<<0;
        return 0;
    }
    cout<<n-k;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <numeric>
using namespace std;
// rep macro
#define rep(i, n)        for (int i = 0; i < (int)(n); i++)
#define rev(i, n)        for (int i = (int)(n - 1); i >= 0; i--)
const int di[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dj[8] = {0, 1, 0, -1, -1, 1, 1, -1};
// vector macro
#define all(v) v.begin(), v.end()
using  vi = vector<int>;
using vvi = vector<vector<int>>;
using  vc = vector<char>;
using vvc = vector<vector<char>>;
// pair macro
#define fi first
#define sj second
using pii = pair<int, int>;

bool on_board(pii p)
{
    return (p.fi >= 0 && p.fi < 8 && p.sj >= 0 && p.sj < 8);
}
bool chk(vvc& b)
{
    bool res = true;
    vector<pii> q;
    // vertical and horizontal 
    rep(i, 8)
        rep(j, 8)
            if (b[i][j] == 'Q') q.push_back(pii(i, j));
    for (auto p : q)
    {
        for (int i = 0; i < 8; i++)
        {
            pii now;
            now = p;
            while(on_board(pii(now.fi+di[i], now.sj+dj[i])))
            {
                now.fi += di[i];
                now.sj += dj[i];
                if (b[now.fi][now.sj] == 'Q')
                {
                    res = false;
                    break;
                }
            }
            if (res == false) break;
        }
        if (res == false) break;
    }
    return res;
}
void print_board(vvc& b)
{
    rep(i, 8)
    {
        rep(j, 8)
        {
            cout << b[i][j];
        }
        cout << endl;
    }
}
int main()
{
    int k; cin >> k;
    vector<pii> q(k);
    rep(i, k) cin >> q[i].fi >> q[i].sj;
    vi I(8); iota(all(I), 0);
    bool res;
    do
    {
        vvc b(8, vc(8, '.'));
        rep(i, 8)
        {
            b[i][I[i]] = 'Q';
        }
        bool skip = false;
        for(auto p : q)
        {
            if (b[p.fi][p.sj] != 'Q') 
            {
                skip = true;
                break;
            }
        }
        if (skip) continue;
        res = chk(b);
        if (res == true)
        {
            print_board(b);
            break;
        }
    } while (next_permutation(all(I)));
}


Measured memory_bytes: 3092
N, A, B = map(int,input().split())
V = list(map(int,input().split()))
V.sort(reverse = True)
Vs=V[:A]
print(sum(Vs)/A)
###################################
Vs = list(set(Vs))
Vs.sort(reverse = True)
###################################
com = [[0]*51 for i in range(51)]
for i in range(51):
    com[i][0] = 1
    for j in range(1, 51):
        com[i][j] = com[i-1][j-1] + com[i-1][j]
###################################
if len(Vs)!=1:
    N = V.count(Vs[-1])
    k = V[:A].count(Vs[-1])
    ans = com[N][k]
else:
    ans = 0
    N = V.count(Vs[0])
    for k in range(A,B+1):
        ans += com[N][k]
print(ans)

Measured memory_bytes: 3192
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void)
{
    double a,b,h,m,ha,ma,sa,x;
    double pi=acos(-1.0);
    cin >> a >> b >> h >> m;
    x = 2 * pi * (h/12 + m/60/12 - m/60);
    printf("%.12lf" ,pow(a*a+b*b-2*a*b*cos(x),0.5));
    return 0;
}



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

int gcd(int a, int b) {
	return a % b == 0 ? b : gcd(b, a % b);
}

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

	int ret;
	cin >> ret;
	for (int i = 1; i < n; ++i) {
		int a;
		cin >> a;
		ret = gcd(ret, a);
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n; cin >> n;
    if(n % 10 == 0) {
        cout << 10 << endl;
        return 0;
    }
    int ans = 0;
    while(n > 0) {
        ans += n % 10;
        n /= 10;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
int cntw[3000005];
int cnte[3000005];

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int minn = inf;
	int cnt;
	if (s[0] == 'E')cnte[0] = 1;
	else cntw[0] = 1;
	for (int i = 1; i < n; i++) {
		cnt = 0;
		if (s[i] == 'W') {
			cnt++;
			cntw[i] = cntw[i - 1] + cnt;
			cnte[i] = cnte[i - 1];
			//cout << cntw[i] << endl;
		}
		else if (s[i] == 'E') {
			cnt++;
			cntw[i] = cntw[i - 1];
			cnte[i] = cnte[i - 1] + cnt;
		//	cout << cnte[i] << endl;
		}
	}
	for (int i = 0; i < n; i++) {
		int change = 0;
		if ((i-1) >= 0 && (i+1) < n) {
			change = cntw[i - 1] + cnte[n - 1] - cnte[i];
		//	cout << cntw[i - 1] << ' ' << cnte[n - 1] - cnte[i + 1] << endl;
			//cout << change << endl;
			minn = min(minn, change);
		}
		if (i == 0) {
			change = cnte[n - 1] - cnte[0];
			//cout << change << endl;
			minn = min(minn, change);
		}
		if (i == n - 1) {
			change = cntw[n - 2];
			//cout << change << endl;
			minn = min(minn, change);

		}
	}
	cout << minn << endl;
}


Measured memory_bytes: 5908
def actual(s):
    left, right = int(s[:2]), int(s[2:])

    valid_right_as_mm = 1 <= right <= 12
    valid_left_as_mm = 1 <= left <= 12

    if valid_left_as_mm and valid_right_as_mm:
        return 'AMBIGUOUS'

    if valid_left_as_mm:
        return 'MMYY'

    if valid_right_as_mm:
        return 'YYMM'

    return 'NA'

s = input()
print(actual(s))

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
S, W = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])

if S <= W:
    print("unsafe")
else:
    print("safe")


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

lli dp[101][101][401]; // dp[i][j][k]: i 個目まで使える状態で、j 個使って重さ k を満たす最大の価値

int main() {
    lli n, W;
    cin2(n, W);
    lli w[n], v[n];
    REP(i, 0, n) {
        cin >> w[i] >> v[i];
    }
    lli w_diff = w[0] - 1;
    REP(i, 0, n) {
        w[i] -= w_diff;
    }
    //cout << "hoge" << endl;

    lli ans = 0;
    REPE(use_count, 1, n) {
        lli cur_w = W - w_diff*use_count;
        if (cur_w < 0)
            break;
        REPE(i, 1, n) {
            REPE(j, 1, use_count) {
                REPE(k, 0, 400) {
                    if (k-w[i-1] < 0) {
                        dp[i][j][k] = dp[i-1][j][k];
                    }
                    else {
                        dp[i][j][k] = max(dp[i-1][j][k], dp[i-1][j-1][k-w[i-1]] + v[i-1]);
                    }
                    //cout << "dp[" << i << "][" << j << "][" << k << "]: " << dp[i][j][k]  << endl;
                }
            }
        }
        // 評価
        REPE(i, 0, n) {
            REPE(j, 0, n) {
                REPE(k, 0, min((lli)400, cur_w)) {
                    ans = max(ans, dp[i][j][k]);
                    dp[i][j][k] = 0;
                }
            }
        }
    }
//dp[3][3][3]: 4
//dp[3][3][4]: 4
//dp[3][3][5]: 4
//dp[3][3][6]: 4
//dp[3][3][7]: 14
//dp[3][3][8]: 14
//dp[3][3][9]: 14
//dp[3][3][10]: 18
//dp[3][3][11]: 18
//dp[3][3][12]: 18

    //REPE(i, 1, n) {
    //    REPE(j, 1, i) {
    //        REPE(k, 0, 10) {
    //            cout << "dp[" << i << "][" << j << "][" << k << "]: " << dp[i][j][k]  << endl;
    //        }
    //    }
    //}

    cout << ans << endl;
}


//4 6
//2 1
//3 4
//4 10
//3 4
//
//
//
//5 => 5
//6 => 11
//5 => 5
//9 => 15
//
//4 6
//1 1
//2 4
//3 10
//2 4
//
//3 => 5
//4 => 11
//3 => 5
//6 => 15
//
//
//
//


Measured memory_bytes: 32256