akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){
  long N;
  cin >> N;
  string list[N];
  long count = 0;
  long M = 0,A = 0,R = 0,C = 0,H = 0;
  for (long i = 0; i < N; i++) {
    cin >> list[i];
    switch (list[i][0]) {
      case 'M':
        M += 1;
        break;
      case 'A':
        A += 1;
        break;
      case 'R':
        R += 1;
        break;
      case 'C':
        C += 1;
        break;
      case 'H':
        H += 1;
        break;
    }
  }
  count += M*A*R;
  count += M*A*C;
  count += M*A*H;
  count += M*R*C;
  count += M*R*H;
  count += M*C*H;
  count += A*R*C;
  count += A*R*H;
  count += A*C*H;
  count += R*C*H;
  cout << count << endl;
  return 0;

}

Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int a,b,t;
    cin >> a >> b >> t;
    cout << (t/a)*b << endl;
    return 0;
}

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

void sort_atoz( vector<int> &v ){
  int i,j,tmp;
  for( i = 0 ; i < v.size() - 1 ; i++ ){
    for( j = 0 ; j < v.size() - 1 ; j++){
      
      if( v.at(j + 1) < v.at(j) ){
        tmp = v.at(j + 1);
        v.at(j + 1) = v.at(j);
        v.at(j) = tmp;
      }
      
    }
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> cards(n);
  
  int i;
  for( i = 0 ; i < n ; i++ )	cin >> cards.at(i);
  
  sort_atoz(cards);
  
  int a = 0,b = 0;
  for( i = 0 ; i < n ; i++ ){
    if( i % 2 == 0 )	a += cards.at(n - 1 - i);
    else	b += cards.at(n - 1 - i);
  }
  
  cout << a - b << endl;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val (K, N) = listOfInt()
    val A = listOfInt().toMutableList()
    A.add(A[0] + K)
    val C = IntArray(N)
    for (n in 0 until N) C[n] = A[n + 1] - A[n]
//System.err.println(C.joinToString())
    var ans = K - C.max()!!
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)


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

int main()
{
  int a, b;

  cin >> a >> b;

  string a_s = string(b, '0' + a);
  string b_s = string(a, '0' + b);

  if (a_s <= b_s)
  {
    cout << a_s << endl;
  }
  else
  {
    cout << b_s << endl;
  }
}


Measured memory_bytes: 3620
a,b,h,m = map(int,input().split())
import math
ar = math.pi * 2 * (h * 60 + m) / 720 #aの0から見た角度
br = math.pi * 2 * m / 60 #bの0から見た角度
r = abs(ar-br)
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(r))
print(ans)

Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int n,m;
    cin>>n>>m;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    for(int i=n-1;i>=n-m;i--){
        if(sum>4*m*a[i]){cout<<"No";return 0;}
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int h, w;
	cin >> h >> w;
	vector<vector<int>> board(h);
	rep(i, h) {
		rep(j, w) {
			int p;
			cin >> p;
			board[i].push_back(p);
		}
	}
	int n = 0;
	vector<vector<int>> move(h*w);
	rep(i, h) {
		rep(j, w - 1) {
			if (board[i][j] %= 2) { 
				board[i][j]--;
				board[i][j + 1]++;
				move[n].push_back(i + 1);
				move[n].push_back(j + 1);
				move[n].push_back(i + 1);
				move[n].push_back(j + 2);
				n++;
			}
		}
	}
	rep(i, h-1) {
		if (board[i][w - 1] % 2) {
			board[i][w - 1]--;
			board[i + 1][w - 1]++;
			move[n].push_back(i + 1);
			move[n].push_back(w);
			move[n].push_back(i + 2);
			move[n].push_back(w);
			n++;
		}
	}
	cout << n << endl;
	rep(i, n) {
		rep(j, 4) {
			cout << move[i][j]; 
			if (j != 3) cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

void get_topo(int s, vector<vector<ll>> &adj, vector<bool> &v, vector<ll> &topological_sort){
  v[s]=true;
  for(auto it:adj[s]){
    if(!v[it]){
      get_topo(it,adj,v,topological_sort);
    }
  }
  topological_sort.push_back(s);
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll t;
  // cin>>t;
  t=1;
  while(t--){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> adj(n+1);
    vector<bool> v(n+1);
    vector<ll> topological_sort, dp(n+1);
    forn(i,0,m){
      ll x,y;
      cin>>x>>y;
      adj[x].pb(y);
    }
    for(int i=1;i<=n;i++){
      if(!v[i]){
        get_topo(i,adj,v,topological_sort);
      }
    }
    reverse(topological_sort.begin(),topological_sort.end());
    ll ans=0;
    for(auto i:topological_sort){
      for(auto it:adj[i]){
        dp[it] = max(dp[it],dp[i]+1);
      }
      // debug2(i,dp[i]);
      ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;

  }
  return 0;
}


Measured memory_bytes: 13900
#include <iostream>
#include <fstream>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll n, a[100000], l[100000], r[100000];

int main() {
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> a[i];
    l[0] = a[0];
    r[n - 1] = a[n - 1];
    for (ll i = 1; i < n; i++) l[i] = gcd(l[i - 1], a[i]);
    for (ll i = n - 2; i >= 0; i--) r[i] = gcd(r[i + 1], a[i]);
    ll ret = max(r[1], l[n - 2]);
    for (ll i = 1; i < n - 1; i++) {
        ret = max(ret, gcd(l[i - 1], r[i + 1]));
    }
    cout << ret << endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<iterator>
using namespace std;

void dfs(int vertex,vector <vector <int>>& adj, vector <int>& colour, int present_colour, int& count, vector <int> &visited)
{
	if (present_colour != colour[vertex])
	{
		count++;
		present_colour = colour[vertex];
	}
	for (int i = 0; i < adj[vertex].size(); i++)
	{
		int child = adj[vertex][i];
		if (visited[child] == 0)
		{
			visited[child] = 1;
			dfs(child, adj, colour, present_colour, count, visited);
		}
	}
}

int main() {

	int d, t, s;
	cin >> d >> t >> s;
	long long travel = s * t;
	if (travel < d) cout << "No";
	else cout << "Yes";
	
	return 0;
}




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

typedef long long int lli;

int main(void)
{
	lli n, m;
	scanf("%lld%lld", &n, &m);
	if(n == 1 && m == 1) printf("1\n");
	else if(n == 1 || m == 1) printf("%lld\n", max(n,m)-2);
	else printf("%lld\n", (n-2)*(m-2));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
    int k;
    long long int total, gcd_ans;
    total = 0;
    cin >> k;
    for (int i=1; i<=k; i++) {
           for (int j=1; j<=k; j++) {
               gcd_ans = gcd(i, j);
                for (int l=1; l<=k; l++) {
                    total = total + gcd(gcd_ans, l);
                  }
           }
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K,N;
ll ans;
string S;
ll a,b,d;
ll A[1000001];
ll H,M,HH,MM;
 
 
int main(){
    cin >> S;
    for(int i=0;i<S.size();i++){
        if(S[i] == '?'){
            S[i] = 'D';
        }
    }
    cout << S << endl;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a.at(5) == '1' || a.at(6) == '5'|| a.at(6) == '6'|| a.at(6) == '7'|| a.at(6) == '8'|| a.at(6) == '9')
    cout << "TBD" << endl;
  else
    cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 20160116
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
vector<int> v[26];
int main(){
	string s;
	cin>>s;
	for (int i=0;i<s.size();i++){
		v[s[i]-'a'].push_back(i+1);
	}
	int ans=1e8;
	for (int i=0;i<26;i++){
		if (v[i].empty()) continue;
		int cnt=max(v[i][0]-1,(int)s.size()-v[i].back());
		for (int j=1;j<v[i].size();j++){
			cnt=max(cnt,(v[i][j]-v[i][j-1]-1));
		}
		ans=min(ans,cnt);
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
fn main() {
    let _ = rv::<usize>()[0];
    let a = rv::<u64>();
    let m = *a.iter().max().unwrap()as usize+1;
    let mut p = vec![0u32;m];
    for &a in &a {
        let mut x=a;
        let mut i=2;
        while i*i<=x {
            let mut c=0;
            while x%i==0 {
                c+=1;
                x/=i;
            }
            let k=i as usize;
            p[k]=std::cmp::max(p[k],c);
            i+=1;
        }
        if x>1 {
            let k=x as usize;
            p[k]=std::cmp::max(p[k],1);
        }
    }
    let mut t=1;
    for i in 0..m { if p[i]>0 {
        t = (t*pow(i as u64,p[i]))%MOD;
    }}
    let mut s=0;
    for a in a {
        s = (s+t*pow(a,MOD as u32-2))%MOD;
    }
    println!("{}",s);
}
const MOD: u64=1000000007;
fn pow(mut x:u64, mut c:u32) -> u64 {
    let mut t=1;
    while c>0 {
        if c&1==1 {
            t=(t*x)%MOD;
        }
        x=(x*x)%MOD;
        c>>=1;
    }
    t
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	while(n--) {
		int a, b; scanf("%d%d", &a, &b);
		
		printf("%d\n", (a - 1) % b + 1);
	}
	return 0;
}



Measured memory_bytes: 3220
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int dp[200005][2];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	rep(i, 200005) rep(j, 2) dp[i][j] = 0;
	dp[0][0] = (s[0] != '.');
	dp[0][1] = (s[0] != '#');
	repn(i, 1, n){
		dp[i][0] = dp[i - 1][0] + (s[i] != '.');
		dp[i][1] = min(dp[i - 1][1], dp[i - 1][0]) + (s[i] != '#');
	}
	cout << min(dp[n - 1][1], dp[n - 1][0]) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 2196
#include<iostream>
using namespace std;
int main()
{
	int a,b,x=1;
	cin>>a>>b;
	if(a>0)x=1;
	else if(a<=0&&b>=0)x=0;
	else
	{
		int i;
		for(int ib=a;ib<=(min(b,-1));ib++)i++;
		if(i%2==0)x=1;
		else x=-1;
	}
	if(x==1)cout<<"Positive\n";
	if(x==0)cout<<"Zero\n";
	if(x==-1)cout<<"Negative\n";
	return 0;
 }

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

int main() {
    string t;
    cin >> t;
    string s;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == '?') s += 'D';
        else s += t[i];
    }
    cout << s << endl;
}

Measured memory_bytes: 3924
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner ipt = new Scanner(System.in);
		int a = ipt.nextInt(), b = ipt.nextInt(), c = 0;
		c = b - a + 1;
		for (int i = (a * 2) - 1; i > 0; i--) {
			System.out.print(c + " ");
			c++;
		}
		ipt.close();
	}
}

Measured memory_bytes: 22612
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int t,a,b,a1,b1;
	long long sum;
	scanf("%d", &t);
	scanf("%d%d", &a, &b);
	while (--t)
	{
		scanf("%d%d", &a1, &b1);
		a = max(a, a1);
		b = min(b, b1);
	}
	sum = a + b;
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 128
s = str(input())
arr = list(s)
if len(arr) >1:
    if sum(map(int, arr))- int(arr[0])  != (len(arr)-1)*9:
        print(int(arr[0]) -1 + (9 * (len(arr)-1)))
    else:
        print(int(arr[0]) + (9 * (len(arr)-1)))
else:
    print(int(s))

Measured memory_bytes: 3064
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] eratos;
    int i, j, pcount;

    pcount = 0;
    eratos = new int[999999];
    eratos[0] = pcount;
    for(i = 2;i < 1001;i++){
      if(eratos[i - 1] == 0){
        pcount++;
        for(j = i * i;j < 1000000;j+=i){
          eratos[j - 1] = -1;
        }
      }
      eratos[i - 1] = pcount;
    }
    for(;i < 1000000;i++){
      if(eratos[i - 1] == 0)pcount++;
      eratos[i - 1] = pcount;
    }

    for(;sc.hasNext();){
      n = sc.nextInt();
      System.out.println(eratos[n - 1]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 24900
#include <iostream>
#include <vector>
#include <map>

int main()
{
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;
  int takahashiAttackNum = (c - 1) / b;
  int aokiAttackNum = (a - 1) / d;
  if (takahashiAttackNum > aokiAttackNum)
  {
    std::cout << "No" << std::endl;
  }
  else
  {
    std::cout << "Yes" << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3624
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)

LIMIT=max(a)
minPrime = [0]*(LIMIT+1)
minPrime[1] = 1
def make():
    for i in range(2,LIMIT+1):
        if minPrime[i] == 0:
            minPrime[i] = i
            #print(i)
            for j in range(i+i,LIMIT+1,i):
                #print(i,j)
                if minPrime[j] == 0:
                    minPrime[j] = i
make()
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)

        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i

    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num

    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret

    def factrial(self,N):
        ret = set()
        while 1 != N:
            ret.add(minPrime[N])
            N = N//minPrime[N]
        if N != 1:
            ret.add(N)
        return ret


sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])

for i in a:
    if not pc:
        break
    #asf = sofe.factorization(i)
    asf = sofe.factrial(i)

    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
# import sys,collections

# N = int(sys.stdin.readline())
# #a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = list(map(int,input().split()))

# import math

# # def factrial(N):
# #     ret = []
# #     while minPrime[N] != N:
# #         ret.append(minPrime[N])
# #         N = N//minPrime[N]
# #     if N != 1:
# #         ret.append(N)
# #     return ret

# def factrial(N):
#     ret = set()
#     while 1 != N:
#         ret.add(minPrime[N])
#         N = N//minPrime[N]
#     if N != 1:
#         ret.add(N)
#     return ret

# for i in range(N):
#     acc = math.gcd(acc,a[i])
# if acc != 1:
#     print("not coprime")
#     exit()

# pairwise = True
# p = set() #all prime
# for e in a:
#     if not pairwise:
#         break
#     f = factrial(e)
#     if p & f != set():
#         pairwise = False
#         print("setwise coprime")
#         exit(0)
#     p = p | f

# if pairwise:
#     print("pairwise coprime")
# else:
#     print("setwise coprime")


Measured memory_bytes: 202028
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

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

    cur = a[0];
    rep(i,n-1){
        if(cur == 2){
            put(i+1);
            return 0;
        }
        cur = a[cur-1];
    }
    put(-1);
}

Measured memory_bytes: 640
z[9999],a,b,c;f(x,y){fflush(!printf("? %d %d\n",x,y));scanf("%s",&b);b=b==89;}main(i){if(scanf("%d%d",&a,&b),a<=b){puts("Impossible");return;}for(i=a+=b;~--i;)!c||f(i,z[c-1])?(z[c++]=i):c--;for(c=*z,i=a;~--i;)z[i]=f(c,i);for(printf("! "),i=0;i<a;)printf("%d",z[i++]);}

Measured memory_bytes: 824
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  vector<int> s;
  vector<int> ord(n+1,-1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


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

public class Hello
{

    public static void Main()
    {
        int[] n = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        string s = Console.ReadLine();
        int m;

        if (int.TryParse(s.Substring(0,n[0]), out m) && s[n[0]] == '-' && int.TryParse(s.Substring(n[0] + 1,n[1]), out m) && n[0] + n[1] + 1 == s.Length)
        {
            Console.WriteLine("Yes");
            return;
        }
        Console.WriteLine("No");
        return;
    }

}



Measured memory_bytes: 13396
n = int(input())
num = list(map(int, input().split()))

q = int(input())
for _ in range(q):
    b, e, t = map(int, input().split())
    for i in range(e-b):
        num[b+i], num[t+i] = num[t+i], num[b+i]

print(' '.join(str(n) for n in num))


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF INT_MAX;
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int N,K;
  cin>>N>>K;
  int ans=0;
  for(int i=0;i<N;i++){
    if(i+K>N)break;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#正負で分割
#dpの作り方はARCの方の人のロジックを参考にした。
#こんなんでええんや...
def 解():
    iN,iA =[int(x) for x in input().split()]
    aX = [int(x) - iA for x in input().split()]
    aPlus = [x for x in aX if 0 < x ]
    aMinus = [-1 * x for x in aX if x < 0  ]
    iLenPlus = len(aPlus)
    iLenMinus = len(aMinus)
    iLen0 = iN - iLenPlus - iLenMinus

    iCZero = 2**iLen0  #sum(k=1..N){nCk} = 2^n -1 #1は組み合わせ0の場合
    iRet = 0
    iUlim = min(sum(aPlus) , sum(aMinus))
    if 0 < iUlim:
        dp1 = {0:1}
        for iX in aPlus:
            for k,v in dp1.copy().items():
                dp1[k+iX] = dp1.get(k+iX,0)+v
        dp2 = {0:1}
        for iX in aMinus:
            for k,v in dp2.copy().items():
                dp2[k+iX] = dp2.get(k+iX,0)+v
        for i in range(1,iUlim+1):
            if i in dp1 and i in dp2:
                iRet += dp1[i] * dp2[i]
    print((iRet+1)*iCZero  -1) #組み合わせ0の場合を引く
解()


Measured memory_bytes: 3316
#include <stdio.h>



int  n1,n2,a[100000],b[50000];

int linear(int);


int main(){
  int i,sum=0;
  scanf("%d",&n1);
 
  for(i=0;i<n1;i++) scanf("%d",&a[i]);
scanf("%d",&n2);
 
  for(i=0;i<n2;i++) scanf("%d",&b[i]);
  for(i=0;i<n2;i++){
    sum+=linear(b[i]);




}
  printf("%d\n",sum);

return 0;
}
int linear(int key){
  int i,l,r,m;
  l=0;
  r=n1;

  while(l<r){
    m=(l+r)/2;
    if(a[m]==key) return 1;
    else if(key<a[m])r=m;
    else l=m+1;
}
  return 0;

}

Measured memory_bytes: 1184
A, B, C, K = map(int, input().split())

ans = 0
if K % 2 == 1:
    ans = -A+B
else:
    ans = A-B

if abs(ans) > 1000000000000000000:
    print('Unfair')
else:
    print(ans)

'''
A, B, C
1: B+C, A+C, A+B, -A+B
2: 2A+B+C, A+2B+C, A+B+2C, A-B
3: 2A+3B+3C, 3A+2B+3C, 3A+3B+2C, -A+B
4: 6A+5B+5C, 5A+6B+5C, 5A+5B+6C, A-B
5: 10A+11B+11C, 11A+10B+11C, 11A+11B+10C, -A+B
6: 22A+21B+21C, 21A+22B+21C, 21A+21B+22C, A-B
'''


Measured memory_bytes: 3060
#define z 1000000
a[z],b[z],n,i=1,x,c;main(){for(;i++<z;)a[i]=i;for(i=-1;i++<z;)if(a[i])for(b[x++]=i,c=0;c<z;c+=i)a[c]=0;for(;~scanf("%d",&n);){c=0;while(b[c]<=n&&b[c++]);printf("%d\n",c);}exit(0);}

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

const int maxn = 1e5+10;
int n,x;
multiset<int>a;
multiset<int>::iterator it;

int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&x);
        if(a.empty())
            a.insert(x);
        else
        {
            it = a.lower_bound(x);
            if(it==a.begin())
                a.insert(x);
            else
            {
                it--;
                a.erase(it);
                a.insert(x);
            }
        }
    }
    int ans = a.size();
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4992
var a:array of longint;
    n,i:longint;
begin
  readln(n);
  setlength(a,n+1);
  for i:=1 to n do
    read(a[i]);
  i:=n;
  while i>0 do
  begin
    write(a[i],' ');
    dec(i,2);
  end;
  i:=(n and 1)+1;
  while i<=n do
  begin
    write(a[i],' ');
    inc(i,2);
  end;
end.

Measured memory_bytes: 2816
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 

int main(){
    fastio
    ll n , m ;
    cin >> n >> m ; 
    ll ans = 0 ; 
    // using both 
    ll x = min(n,m/2LL) ;
    ans += x ; 
    n -= x ; 
    m -= 2LL*x;
    ans += m / 4LL ; 
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    vector<vector<int>> graph(N);
    for(int i = 0; i < N - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    vector<int> color(N);
    vector<int> cnt(2);
    vector<vector<int>> vs(2);
    auto dfs = [&](auto&& self, int from = 0, int c = 0, int par = -1) -> void {
        color[from] = c;
        ++cnt[c];
        vs[c].emplace_back(from);
        for(int to : graph[from]){
            if(to == par)   continue;
            self(self, to, c ^ 1, from);
        }
    };
    dfs(dfs);

    vector<int> ans(N);
    if(cnt[0] >= (N + 1) / 3 && cnt[1] >= (N + 2) / 3){
        int x = 1, y = 2;
        if(cnt[0] < cnt[1]) swap(x, y);
        int p0 = 0, p1 = 0;
        for(int i = x; i <= N; i += 3){
            ans[vs[0][p0++]] = i;
        }
        for(int i = y; i <= N; i += 3){
            ans[vs[1][p1++]] = i;
        }
        int val = 3;
        while(p0 < cnt[0]){
            ans[vs[0][p0++]] = val;
            val += 3;
        }
        while(p1 < cnt[1]){
            ans[vs[1][p1++]] = val;
            val += 3;
        }
    }
    else if(cnt[0] >= (N * 2 + 1) / 3){
        int p = 0;
        for(int i = 1; i <= N;){
            ans[vs[0][p++]] = i;
            if(++i % 3 == 0)    ++i;
        }
        int val = 3;
        while(p < cnt[0]){
            ans[vs[0][p++]] = val;
            val += 3;
        }
        for(int i = 0; i < cnt[1]; ++i){
            ans[vs[1][i]] = val;
            val += 3;
        }
    }
    else{
        int p = 0;
        for(int i = 1; i <= N;){
            ans[vs[1][p++]] = i;
            if(++i % 3 == 0)    ++i;
        }
        int val = 3;
        while(p < cnt[1]){
            ans[vs[1][p++]] = val;
            val += 3;
        }
        for(int i = 0; i < cnt[0]; ++i){
            ans[vs[0][i]] = val;
            val += 3;
        }
    }


    for(int i = 0; i < N; ++i){
        cout << ans[i];
        cout << ((i == N - 1) ? '\n' : ' ');
    }
}

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

using namespace std;

int SA[200005],RANK[200005],H[200005],TMP[200005],cnt[200005],rank1[200005],rank2[200005],tmpSA[2000005];
char s[200005],t[200005];

const int ALPHABET_SIZE = 256; //ASCII

void build_SA(char* s){
    
    int L = strlen(s);
    
    for (int i = 0; i < ALPHABET_SIZE; i++) cnt[i] = 0;
    for (int i = 0; i < L; i++) cnt[s[i]]++;
    for (int i = 1; i < ALPHABET_SIZE; i++) cnt[i] += cnt[i - 1];
    for (int i = 0; i < L; i++) RANK[i] = cnt[s[i]] - 1;
    
    for(int k = 1; k < L; k *= 2){
        //sort by rank2
        for (int i = 0; i < L; i++)
            rank1[i] = RANK[i], rank2[i] = i + k < L ? RANK[i + k] : -1;
        
        for (int i = 0; i <= L; i++) cnt[i] = 0;
        for (int i = 0; i < L; i++) cnt[rank2[i] + 1]++;
        for (int i = 1; i <= L; i++) cnt[i] += cnt[i - 1]; 
        for (int i = L - 1; i >= 0; i--) tmpSA[--cnt[rank2[i] + 1]] = i;
        //sort by rank1
        for (int i = 0; i <= L; i++) cnt[i] = 0;
        for (int i = 0; i < L; i++) cnt[rank1[i]]++;
        for (int i = 1; i < L; i++) cnt[i] += cnt[i - 1];
        for (int i = L - 1; i >= 0; i--) SA[--cnt[rank1[tmpSA[i]]]] = tmpSA[i]; 
        RANK[SA[0]] = 0;
        for (int i = 1; i < L; i++) {
            RANK[SA[i]] = RANK[SA[i - 1]];
            if (rank1[SA[i]] != rank1[SA[i - 1]] || rank2[SA[i]] != rank2[SA[i - 1]])
                RANK[SA[i]]++;
        }
    }
    
    int h = 0;
    
    for(int i = 0; i < L; i++){
        if(RANK[i] == 0) continue;
        
        int t = SA[RANK[i] - 1];
        h = max(0, h - 1);
        
        while(i + h < L && t + h < L){
            if(s[i + h] != s[t + h]) break;
            h++;
        }
        
        H[RANK[i]] = h;
    }
}

char a[5005];

bool solve(int v) {
	int n = strlen(a);
	
	int mn = SA[0];
	int mx = SA[0];
	
	for (int i = 1; i < n; i++) {
		if (H[i] < v) {
			if (mn + v <= mx) return 1;
			mn = mx = SA[i];
		}
		else {
			mn = min(mn, SA[i]);
			mx = max(mx, SA[i]);
		}
	}
	
	if (mn + v <= mx) return 1;
	
	return 0;
}

int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", a);
	
	build_SA(a);
	
	int lb = 0;
	int ub = n / 2 + 1;
	
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		if (solve(mid)) lb = mid;
		else ub = mid;
	}
	
	printf("%d\n", lb);
}


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

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

	int ss = s.size();
	int st = t.size();
	int min = 100000;

	rep(i, ss-st+1) {
		int cnt=0;
		rep(j, st) {
			if(s[i+j] != t[j]) cnt++;
		}
		if(cnt < min) min = cnt;
	}

	cout << min << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define mod 1000000007
#define long long long
int arr[100000];
int dp[100000];

int main(){
    long n,k;cin>>n>>k;
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    
    for(int i=0;i<n;i++){
        dp[i]=mod;
    }dp[0]=0;
    for(int i=0;i<n;i++){
        for(int l=1;l<=k;l++){
            if(i+l<n){dp[i+l]=min(dp[i+l],dp[i]+abs(arr[i]-arr[i+l]));}
        }
    }
    
    cout<<dp[n-1];
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int x; cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << ednl;
    return 0;
}

Measured memory_bytes: 3632
n=int(input())
if n==1:
  print(0)
  exit()
h=list(map(int,input().split()))
c=[-1]*n
c[0]=0
c[1]=abs(h[1]-h[0])
for i in range(2,n):
  c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1]))
print(c[n-1])

Measured memory_bytes: 13900
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()

tasks = []
for i in range(N):
    A, B = nl()
    tasks.append([A, B])

tasks = sorted(tasks, reverse=True, key=lambda x: x[1])
t = tasks[0][1] - tasks[0][0]
for task in tasks[1:]:
    t = min(task[1], t) - task[0]

if t < 0:
    print('No')
else:
    print('Yes')


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<ll> array;
    if (s[0] == '0') {
        array.push_back(0);
    }
    ll count = 1;
    repd(i, 1, n) {
        if (s[i - 1] != s[i]) {
            array.push_back(count);
            count = 0;
        }
        count++;
    }
    array.push_back(count);
    if (array.size() % 2 == 0) {
        array.push_back(0);
    }

    if (array.size() <= 2 * k + 1) {
        cout << n << endl;
        return 0;
    }
    ll ans = 0;
    ll sum = 0;
    rep(i, 2 * k + 1) { sum += array[i]; }
    ans = max(ans, sum);

    ll num = (array.size() - (2 * k + 1)) / 2;
    rep(i, num) {
        sum -= array[2 * i] + array[2 * i + 1];
        sum += array[2 * k + 1 + 2 * i] + array[2 * k + 2 + 2 * i];
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4416
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N, M;
    cin >> N >> M;
    map<int, int> cities;
    for (int i = 1; i <= N; ++i) cities[i] = 0;
    for (int i = 0; i < M; ++i)
    {
        int ai, bi;
        cin >> ai >> bi;
        ++cities[ai];
        ++cities[bi];
    }
    for (const auto &kvp : cities)
    {
        cout << kvp.second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main()
{
    int W, H, C, g;
    cin >> W >> H >> C;
    g = gcd(W,H);
    cout << (W/g)*(H/g)*C << endl;
    
}


Measured memory_bytes: 3108
S = input()
cnt = 0
max_cnt = 0

for s in S:
    if s=="A" or s=="C" or s=="G" or s=="T":
        cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
    else:
        if cnt > max_cnt:
            max_cnt = cnt
        cnt = 0
        
print(max_cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[102];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	for(ll i=1;i<n;i++){
		if(a[i]==a[i-1]){
			ans++;
			a[i]=101;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
        int A,B,C;
        cin >> A >> B >> C;
        int x[B];
        for(int i=0;i<B;i++){
                x[i] = i;
        }
        int surp = A % B;
        int ssum = surp;
        while(ssum != C){
                if(x[ssum] == -1){
                        cout << "NO" << endl;
                        return 0;
                }
                x[ssum] = -1;
                ssum = (ssum + surp) % B;
        }
        cout << "YES" << endl;

        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	
	
	int a,b;
	cin>>a>>b;
	int ans=max(a+b,max(a+a-1,b+b-1));
	cout<<ans<<endl;
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[1005];
int main()
{
	int h,w;
	cin>>h>>w;
	char a[h+2][w+2];
	for(int i=0;i<=h+1;i++)
	{
		for(int j=0;j<=w+1;j++)
		{
			if(i==0||j==0||i==h+1||j==w+1)
			{
				cout<<"#";
			}
			else{
				cin>>a[i][j];
				cout<<a[i][j];
			}
		}
		cout<<"\n";
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    for(int i=1; i<=a; i++)
        for(int j=1; j<=b; j++)
        {
            string s;
            cin >> s;
            if(s == "snuke")printf ("%c%d\n", j+64, i),exit(0);
        }
}

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

int N,C,cnt[30][30],d[30][30];

int main(){
	scanf("%d%d",&N,&C);
	for(int i=0;i<C;i++) for(int j=0;j<C;j++) scanf("%d",&d[i][j]);
	for(int i=0;i<N;i++) for(int j=0;j<N;j++){
		int c;
		scanf("%d",&c);
		cnt[(i+j)%3][c-1]++;
	}
	int ans=1e9;
	for(int a=0;a<C;a++) for(int b=0;b<C;b++) for(int c=0;c<C;c++){
		if(a==b||b==c||a==c) continue;
		int tot=0;
		for(int i=0;i<C;i++) tot+=cnt[0][i]*d[i][a];
		for(int i=0;i<C;i++) tot+=cnt[1][i]*d[i][b];
		for(int i=0;i<C;i++) tot+=cnt[2][i]*d[i][c];
		ans=min(tot,ans);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd


N = int(input())
M = 1000000000000001

k = 3
mini = 26*(1 - 26**(k-1)) / (1 - 26) + 1
maxi = mini + 26**k - 1

for k in range(100):
    mini = 26*(1 - 26**(k-1)) / (1 - 26) + 1
    maxi = mini + 26**k - 1

    if mini <= N <= maxi:
        keta = k
        nunkome = N - mini
        break

import string
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = alphabets[:26]
def base_cvt(value, n=26):

    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result =  characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result

matsubi = base_cvt(nunkome)

num = k - len(matsubi)
print("a"*num + matsubi)


Measured memory_bytes: 27192
#include <iostream>

using namespace std;

int f(int a, int b) {
    if (a == 1) {
        if (b == 1) {
            return 0;
        } else {
            return 1;
        }
    } else if (b == 1) {
        return -1;
    }
    if (a > b) {
        return 1;
    }
    if (a < b) {
        return -1;
    }
    return 0;
}

int main() {

    int a, b;
    cin >> a >> b;

    int result = f(a, b);

    if (result == 1) {
        cout << "Alice" << endl;
    } else if (result == -1) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;cin>>n>>m;
  string str="";
  for(int i=0;i<n;i++)
    str+='#';
  bool check=true;
  for(int i=0;i<m;i++)
  {
    int s,c;cin>>s>>c;
    s--;
    if(str[s]=='#')
      str[s]=c+'0';
    else if(str[s]!=c+'0')
       check=false;
  }
  if(str[0]=='0' && n>1)
    check=false;
  if(!check)
  {
    cout<<-1<<endl;
    return 0;
  }
  if(str[0]=='#')
  {
  	if(n==1)
      str[0]='0';
  	else
      str[0]='1';
  }
  for(int i=1;i<n;i++)
    if(str[i]=='#')
      str[i]='0';
  cout<<str<<endl;
  return 0;
}
  	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> s = {"KIHBR","KIHBRA","KIHBAR","KIHBARA","KIHABR","KIHABRA","KIHABAR","KIHABARA",
                        "AKIHBR","AKIHBRA","AKIHBAR","AKIHBARA","AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"};
    string S;
    cin>>S;
    bool flg=false;
    for(auto str:s){
        if(str==S) flg=true;
    }
    if(flg) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    let n = s.len();

    let r = s.iter().filter(|&&c| c == '0').count();
    println!("{}", 2 * std::cmp::min(r, n - r));
}


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

using namespace std;

const int N = 3010;

double p[N];

long double dp[N][N];

int main() {

    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >> p[i];


    dp[0][0] = 1;

    for(int i = 1 ; i <= n ; i++) 
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
    

    for(int i = 1 ; i <= n ; i++) {
        for(int j = 1; j <= i ; j++) {
            dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
        }
    }

    double ans = 0;
    for(int i = (n + 2) / 2 ; i <= n ; i++) 
        ans = ans + dp[n][i];

    cout << setprecision(10) <<  ans << '\n';

    return 0;
}


Measured memory_bytes: 139776