akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;


int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k)cout << s;
    else {
        cout << s.substr(0, k) << "...";
    }
}




Measured memory_bytes: 3100
#include <iostream>

int main()
{
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;
	
	if (x-r < 0 || x+r > W || y-r < 0 || y+r > H) {
		std::cout << "No" << std::endl;
	} else {
		std::cout << "Yes" << std::endl;
	}
	return 0;
}



Measured memory_bytes: 3104
using System;
class Program
{
	static void Main(string[] args)
	{
      string[] input = Console.ReadLine().Split(' ');
      string[] input2 = Console.ReadLine().Split(' ');
      int H= int.Parse(input[0]);
      int N=int.Parse(input[1]);
      var A=new int[N];
      int sum=0;
      for(int i=0;i<N;i++){
        A[i]=int.Parse(input2[i]);
      }
      for(int i=0;i<N;i++){
        sum+=A[i];
      }
      if(sum<H){
        Console.WriteLine("No");
      }
      else{
        Console.WriteLine("Yes");
      }
    }
}

Measured memory_bytes: 16480
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx") 
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
int a,b;
int main()
{
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <iostream>
using namespace std;
int n;
set<string> s;
string a;
char lat;
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    cin>>a;
    if(s.count(a)){
      printf("No\n");
      return 0;
    }
    if(i>1&&a[0]!=lat){
      printf("No\n");
      return 0;
    }
    lat=a[a.length()-1];
    s.insert(a);
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val x = readLine()!!.split(" ").map{ it.toLong() }
	val ml = x.sorted()[n/2-1]
	val mr = x.sorted()[n/2]
	x.fold(StringBuilder()) {acc, it->
		acc.append(if(it<=ml) "$mr\n" else "$ml\n")
	}.let {println(it)}
	
}

Measured memory_bytes: 100440
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] c = { str.charAt(0), str.charAt(1), str.charAt(2) };
        String ans = "No";

        if( c[0] != c[1] && c[1] != c[2] && c[2] != c[0] ){
            ans = "Yes";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926
 
int a[3];
 
int main(){
    int n;
    cin >> n;
    int j = n%10;
    int d = (n % 100)/10;
    int s = n/100;
    if(j == 9)
        j = 1;
    else
        j = 9;
    if(d == 9)
        d = 1;
    else
        d = 9;
    if(s == 9)
        s = 1;
    else
        s = 9;
    cout << s << d << j;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in(n)  int n; cin>>n;
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
#define ll long long int
using namespace std;
int  main()
{

int n;
cin>>n;
int ar[n];
loop
cin>>ar[i];
int sum1=0;
for(int i=0;i<n;i++)
{
	sum1+=ar[i];
}
int sum2=0;
int ans=INT_MAX;
for(int i=0;i<n;i++)
{
	sum2+=ar[i];
ans=min(abs(sum1-(2*sum2)),ans);
}
cout<<ans;
}

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

#define llint long long int

using namespace std;

int main()
{
    int N;

    cin >> N;

    vector<bool> zorome(N);

    for (int i = 0; i < N; i++)
    {
        int D1, D2;

        cin >> D1 >> D2;

        if (D1 == D2)
        {
            zorome[i] = true;
        }
        else
        {
            zorome[i] = false;
        }
    }
    for (int i = 2; i < N; i++)
    {
        if (zorome[i - 2] && zorome[i - 1] && zorome[i])
        {
            cout << "Yes" << endl;

            return 0;
        }
    }
    cout << "No" << endl;
}

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

bool isPrime(long long X){
    if (X < 2) return 0;
    for(long long i = 2; i < X ; i ++){
        if (X % i == 0) return 0;
    }
    return 1;
}

long long solve(long long X){
    while (1)
    {
        if(isPrime(X)) return X;
        X++;      
    };
    
}

// 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)
int main(){
    long long X;
    scanf("%lld",&X);
    cout << solve(X) << endl;;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    n=n/2;
    cout<<arr[n]-arr[n-1];
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	if (2 * c < a + b) {
		int m = min(x, y);
		int ans = 2 * c * m;
		x -= m;
		y -= m;
		if (x) {
			if (2 * c < a) {
				ans += 2 * c * x;
			} else {
				ans += a * x;
			}
		} 
		if (y) {
			if (2 * c < b) {
				ans += 2 * c * y;
			} else {
				ans += b * y;
			}
		}

		cout << ans << "\n";
	} else {
		cout << a * x + b * y << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#define mod 1000000007
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define srep(i,s,t) for (ll i = s; i < t; i++)
#define drep(i,n) for(ll i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef vector<vector<char>> field_t;
typedef unsigned long long ull;
typedef pair<ll, ll> point_t;


int main()
{
    string s,t;
    cin >> s >>t;
    ull ans=0;
    for(ull i=0;i<(ull)s.length();i++){
        if(s.at(i)!=t.at(i)){
            ans++;
        }
    }
    cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 3912
#include <iostream>

using namespace std;

typedef long long LL;
#define IFOR(v,it) for(string::iterator it=(v).begin();it!=(v).end();++it)


int main() {
  string S;
  cin >> S;
  LL K;
  cin >> K;

  IFOR(S, it) {
    --K;
    if (K == 0 || *it != '1') {
      cout << *it << endl;
      return 0;
    }
  }
  cout << S.back() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl
#define coYES cout << "YES" << endl
#define coyes cout << "yes" << endl
#define coNo cout << "No" << endl
#define coNO cout << "NO" << endl
#define cono cout << "no" << endl
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){ //最大公約数
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int n,max1=0,j=1;
    cin >> n;
    vector<int> a(n),b(n);
    rep0(i,n){
        cin >> a[i];
    }
    rep1(i,n){
        cin >> b[n-i];
    }
    while(n>0){
        int sum=0;
        rep0(i,n){
            sum+=a[i];
        }
        for(int i=0;i<j;i++){
            sum+=b[i];
        }
        n--;
        j++;
        max1=max(sum,max1);
    }
    cout << max1 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}
const int n_max = 105;
const int k_max = 100005;

signed main(){
    int n,k;
    cin >> n >> k;
    int A[n];
    REP(i,n) cin >> A[i];
    int dp[n_max][k_max];

    REP(i,k_max) dp[0][i] = 0;
    dp[0][0] = 1;
    REP(i,n){
        int summ = 0;
        REP(j,k+1){
            summ += dp[i][j];
            if(j - A[i] - 1>= 0) summ -= dp[i][j - A[i] - 1];
            summ += MOD;
            summ %= MOD;
            dp[i+1][j] = summ;

        }
    }
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 80384
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  string S,T;
  in(S,T);
  int ans=0;
  rep(i,3)if(S[i]==T[i])ans++;
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	int n;
	ll k;
	cin >> n >> k;

	if(2*k-1>n) {
		cout << -1 << endl;
		return 0;
	}

	vector<tuple<ll, ll, ll>> v;
	for(int i=0; i<k-1; i++){
		v.push_back({k+2*n+1+2*i, n+1+i, k+n+i});
		dbg(k+2*n+1+2*i, n+1+i, k+n+i);
	}
	for(int i=0; i<n-k+1; i++){
		v.push_back({3*k+n-1+2*i, k+i, 2*k+n-1+i});
		dbg(3*k+n-1+2*i, k+i, 2*k+n-1+i);
	}
	sort(v.begin(), v.end());
	for(int i=0; i<n; i++){
		cout << get<1>(v[i]) << " " << get<2>(v[i]) << " " << k+2*n+i << endl;
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

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

    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b);




    return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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


  ll sum = 0;
  rep1(i, n-1) sum += i;

  cout << sum << endl;



  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int x, y, z;
    std::cin >> x >> y >> z;
    int ans = 0;
    while (x >= ((y + z) * ans) + z) { ans++; }
    std::cout << --ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long n; cin >> n;
  long long res = 0;
  for(long long i = 1; i * i < n; i++) {
    if(n % i == 0 && n % (n/i - 1) != 0) {
      res += n/i - 1;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;
const long double pi = acos(-1);

int n, m, b[MAXN], c[MAXN], tp;
pii a[MAXN];
bool f1, f2;
long double ans;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	int x1 = Read(), y1 = Read(), x2 = Read(), y2 = Read();
	if (x1 > x2)
		f1 = true, x1 = 1e8 - x1, x2 = 1e8 - x2;
	if (y1 > y2)
		f2 = true, y1 = 1e8 - y1, y2 = 1e8 - y2;
	n = Read();
	for (int i = 1; i <= n; i ++)
	{
		a[i].xx = Read();
		if (f1)
			a[i].xx = 1e8 - a[i].xx;
		a[i].yy = Read();
		if (f2)
			a[i].yy = 1e8 - a[i].yy;
	}
	ans = 100LL * ((x2 - x1) + (y2 - y1));
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i ++)
		if (a[i].xx >= x1 && a[i].xx <= x2 && a[i].yy >= y1 && a[i].yy <= y2)
			b[++ tp] = a[i].yy, c[tp] = 1 << 30;
	for (int i = 1; i <= tp; i ++)
		c[upper_bound(c + 1, c + tp + 1, b[i]) - c] = b[i];
	for (int i = 1; i <= tp; i ++)
		if (c[i] < 1 << 30)
			m ++;
	ans -= (20 - 5 * pi) * m;
	if (m == min(x2 - x1, y2 - y1) + 1)
		ans += 5 * pi;
	return printf("%.12Lf\n", ans), 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    int count = 0;
    if (S[0] == '1') ++count;
    if (S[1] == '1') ++count;
    if (S[2] == '1') ++count;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数

    def root(self, x): #root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        else:
            while self.parent[x] >= 0 and self.parent[self.parent[x]] >= 0:
                self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
#        self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
            return (x if self.parent[x] < 0 else self.parent[x])

    def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]


n,m=[int(i) for i in input().split()]

A=[[int(i)-1 for i in input().split()] for _ in range(m)]

ans = [0]*(m+1)
a = n*(n-1)//2
ans[0] = a

uf = UnionFind(n)
for i in range(m):
    j = m-i-1
    v1 = A[j][0]
    v2 = A[j][1]
#    print(v1,v2)
    if not uf.issame(v1,v2):
#        print(uf.parent)
        a -= uf.size(v1) * uf.size(v2)
        uf.merge(v1,v2)

    ans[i+1]=a

for i in range(m):
    print(ans[m-i-1])
    
    
    
    
    
    





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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0)
	cout << (b - a) / 2 << endl; 
  else
	cout << min((a + b - 1) / 2, (n - a + n - b + 1) / 2) << endl;
}

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

int main(){
  long long int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  n=n-1;
  if(abs(b-a)>n*d){
    cout << "NO"<<endl;
    return 0;
  }
  if(n%2==0){
    long long int atari=abs(b-a)%(c+d);
    if(2*atari>(c+d)){atari=(c+d)-atari;}
    if(atari<=n*(d-c)/2){
      cout << "YES" <<endl;
    }else{
      cout << "NO" <<endl;
    }
    return 0;
  }else{
    long long int atari=abs(b-a)%(c+d);
    long long int datari = abs((d+c)-2*atari);
    if(datari<=n*(d-c)){
      cout << "YES" << endl;
    }else{
      cout << "NO" <<endl;
    }
    return 0;
  }
  return 0;
    
  
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define mt make_tuple
#define ldb double
#define pii pair<int,int>
#define pll pair<ll,ll>
template<typename T>void ckmn(T &a,T b){a=min(a,b);}
template<typename T>void ckmx(T &a,T b){a=max(a,b);}
int ri(){int x;scanf("%i",&x);return x;}
void rd(){}
template<typename...T>void rd(int &x,T&...args){scanf("%i",&x);rd(args...);}
template<typename...T>void rd(ll &x,T&...args){scanf("%lld",&x);rd(args...);}
template<typename...T>void rd(ldb &x,T&...args){scanf("%lf",&x);rd(args...);}
template<typename...T>void rd(pii &x,T&...args){scanf("%i %i",&x.first,&x.second);rd(args...);}
template<typename T>void rd(vector<T>&v){for(T&i:v)rd(i);}

const int mod=998244353;
int add(int a, int b){ a+=b;return a>=mod?a-mod:a;}
void ckadd(int &a, int b){ a=add(a,b);}
int sub(int a, int b){ a-=b;return a<0?a+mod:a;}
void cksub(int &a, int b){ a=sub(a,b);}
int mul(int a, int b){ return (ll)a*b%mod;}
void ckmul(int &a, int b){ a=mul(a,b);}
int powmod(int x, int k){ int ans=1;for(;k;k>>=1,ckmul(x,x)) if(k&1) ckmul(ans,x);return ans;}
int inv(int x){ return powmod(x,mod-2);}

const int N=305;
char s[N];
vector<int> sz;
int dp[N][N][N],tmp[N][N][N];
int main(){
	int k;
	scanf("%s %i",s+1,&k);
	int len=strlen(s+1);
	k=min(k,len);
	int cnt=0;
	sz.pb(-1);
	for(int i=1;i<=len;i++){
		if(s[i]=='0')sz.pb(cnt),cnt=0;
		else cnt++;
	}
	sz.pb(cnt);
	int n=(int)sz.size()-1;
	dp[n][0][0]=1;
	for(int i=n;i>=0;i--){
		for(int j=0;j<=k;j++){
			for(int z=j;z>=0;z--){
                //for(int o=0;o<=z;o++){
				//	ckadd(dp[i-1][j][z-o],dp[i][j][z]);
                //}
                ckadd(tmp[i][j][z],tmp[i][j][z+1]);
                ckadd(dp[i][j][z],tmp[i][j][z]);
                if(i!=0){
					ckadd(tmp[i-1][j][z],dp[i][j][z]);

					for(int p=1;p<=min(k-j,sz[i]);p++){
						ckadd(dp[i-1][j+p][z+p],dp[i][j][z]);
					}
                }

                //printf("i:%i j:%i z:%i  %i\n",i,j,z,dp[i][j][z]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=k;i++)ckadd(ans,dp[0][i][0]);
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 113468
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll inf = 1e11;
int main(){
    ll n,m; cin >> n >> m;
    vector<ll> a(m);
    rep(i,m) cin >> a[i];
    sort(a.rbegin(), a.rend());
    ll cnt[9] = {2,5,5,4,5,6,3,7,6};
    vector<ll> dp(n+1,-inf);
    dp[0] = 0;

    rep(i,n+1){
        rep(j,m){
            if(i >= cnt[a[j]-1]){
                dp[i] = max(dp[i - cnt[a[j]-1]] + 1,dp[i]);
            }
        }
    }

    ll now = n;
    
    rep(i,m){
        while(dp[now - cnt[a[i]-1]] == dp[now] - 1){
            cout << a[i];
            now -= cnt[a[i]-1];
        }
    }

    cout << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n);++i)
using namespace std;
int a[12][12];
const int INF=1145141919;
int main() {
    int n,m,x;
    cin >> n >> m >> x;
    vector<int>c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,m) {
            cin >> a[i][j];
        }
    }
    int ans=INF;
    rep(s,1<<n) {
        int cost=0;
        vector<int>d(m);
        rep(i,n){
            if(s>>i&1){
                cost+=c[i];
                rep(j,m) d[j]+=a[i][j];
            }
        }
        bool ok=true;
        rep(j,m) if(d[j]<x) ok=false;
        if(ok) ans=min(ans,cost);
    }
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;

    }

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
#include <limits.h>
#include<stdlib.h>


int main() {
	int l,r,d,a;
	int count = 0;
	scanf("%d", &l);
	scanf("%d", &r);
	scanf("%d", &d);

	a = d;
	while (a <= 100) {
		if (a >= l && a <= r) {
			count++;
		}
		a += d;
	}
	printf("%d\n", count);
	return 0;
}

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

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

#define PB push_back

#define MOD 1000000007LL
typedef long long ll;

char typ[1234];
bool opt[1234];
vector<int> ver[1234];

ll cnt(int, int);
ll cnt(int nw, int par){
	ll ret = 0;
	if(typ[nw]=='E'){
		ret = 1;
		REP(i, ver[nw].size()){
			int ch = ver[nw][i];
			if(ch==par) continue;
			ret*=cnt(ch, nw);
			ret%=MOD;
		}
	}else if(typ[nw]=='A'){
		ret = 0;
		REP(i, ver[nw].size()){
			int ch = ver[nw][i];
			if(ch==par) continue;
			ret+=cnt(ch, nw);
			ret%=MOD;
		}
	}else{
		ret = 1;
		REP(i, ver[nw].size()){
			int ch = ver[nw][i];
			if(ch==par) continue;
			ret*=cnt(ch, nw)+1;
			ret%=MOD;
		}
		ret--;
	}
	if(opt[nw]) ret++;
	return (ret+MOD*3)%MOD;
}
int main(){
	int n;
	scanf("%d", &n);
	REP(i, n){
		char s[4];
		scanf("%s", s);
		opt[i] = (strlen(s)==2);
		typ[i] = s[0];
	}
	REP(i, n-1){
		int a, b; scanf("%d%d", &a, &b); a--; b--;
		ver[a].PB(b);
		ver[b].PB(a);
	}
	
	printf("%lld\n", cnt(0, -1));
}

Measured memory_bytes: 3376
f x [] = 0
f x (a:as)
  | x<0&&(-x)<a || x>0&&(-x)>a = f (x+a) as
  | otherwise = abs (x+a)+1 + f (signum (-x)) as
main = do
  getLine
  (a:as) <- map read . words <$> getLine
  print $ if a == 0
    then f 1 as `min` f (-1) as + 1
    else f a as `min` (f (signum (-a)) as + abs a+1)

Measured memory_bytes: 54652
N = int(input())
a = [0] * N
b = [0] * N
c = [0] * N

for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
    if i > 0:
        a[i] += max(b[i-1], c[i-1])
        b[i] += max(a[i-1], c[i-1])
        c[i] += max(a[i-1], b[i-1])

print(max(a[N-1],b[N-1],c[N-1]))

Measured memory_bytes: 14924
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
int gcd(int a, int b) { return a ? gcd(b%a, a) : b; }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, K, A[101010];
//---------------------------------------------------------------------------------------------------
string ok = "POSSIBLE";
string ng = "IMPOSSIBLE";
string solve() {
    rep(i, 0, N) if (A[i] == K) return ok;
    int ma = A[N - 1];
    if (ma < K) return ng;
    
    int g = A[0];
    rep(i, 1, N) g = gcd(g, A[i]);

    if (g == 1) return ok;
    
    if (K % g == 0) return ok;
    return ng;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];
    sort(A, A + N);

    cout << solve() << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k, cnt =0;
    long long a[100005];
    cin >> n >> k;
    int d= k-1;
    for ( int i= 0; i< n; i++) cin >> a[i];
    for ( int i=0; i<n;){
        if (i+1 <n) cnt ++;
        if (i +d  < n ) i+=d;
        else break;
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

signed main(void){
    int a[4]={},t;
    REP(i,6){
        cin >> t;
        a[t-1]++;
    }
    sort(a,a+4);
    if(a[3]!=3){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}



Measured memory_bytes: 256
n = int(input())
s = []
for _ in range(n):
    s.append(input())

m = int(input())
t = []
for _ in range(m):
    t.append(input())

ans = 0
for i in set(s):   
    ans = max(ans,s.count(i) - t.count(i))
        
print(ans)

Measured memory_bytes: 38384
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
const int dx[] ={1,0,-1,0};
const int dy[] ={0,-1,0,1};
typedef pair<int,int> P;
const int INF =1e+9;
int H,W,N;
int d[1010][1010];
char board[1010][1010];
int sx,sy;
int gx,gy;
int ans;
void bfs(int y,int x,int k){
  for(int i = 1;i <=H;i++){
    for(int j = 1;j <=W;j++){
      d[i][j] =INF;
      if(board[i][j] == k+'0'){
	gx = j;
	gy = i;
      }
    }
  }
  d[y][x] = 0;
  queue<P> que;
  que.push(P(y,x));
  while(!que.empty()){
    P p = que.front();
    que.pop();

    if(p.first ==gy&&p.second ==gx)
      break;
    for(int i = 0;i < 4;i++){
      int nx = p.second+dx[i];
      int ny = p.first+dy[i];
      if(nx >=1&&nx <=W&&ny >=1&&ny <=H&&board[ny][nx] !='X'&&d[ny][nx] ==INF){
	que.push(P(ny,nx));
	d[ny][nx] =d[p.first][p.second]+1;
      }
    }
  }
  ans += d[gy][gx];
  if(k !=N)
    bfs(gy,gx,k+1);
}

int main()
{
  cin>>H>>W>>N;
  for(int i = 1;i <=H;i++){
    for(int j = 1;j <=W;j++){
      cin>>board[i][j];
    }
  }
  for(int i = 1;i <=H;i++){
    for(int j = 1;j <=W;j++){
      if(board[i][j] =='S'){
	sx = j;
	sy = i;
      }
    }
  }
  bfs(sy,sx,1);
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 6160
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define PB push_back
#define MP make_pair
#define ALL(V) V.begin(), V.end()
#define RALL(V) V.rbegin(), V.rend()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 100005;
constexpr int dx[] = { 0, 1, 0, -1 };
constexpr int dy[] = { 1, 0, -1, 0 };

int n, a, b;

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

    cin >> n >> a >> b;
    int x, ans = 0;
    cin >> x;
    for (int i = 1; i < n; ++i) {
        int t;
        cin >> t;
        if (b < (t - x) * a) {
            ans += b;
        } else {
            ans += (t - x) * a;
        }
        x = t;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int[] b = new int[a];
		for (int i = 0; i < a; i++)
			b[i] = scanner.nextInt();
		for (int i = b.length - 1; i >= 0; i--) {
			if (i == b.length - 1)
				System.out.print(b[i]);
			else
				System.out.print(" " + b[i]);
		}
		System.out.println();
	}
}



Measured memory_bytes: 26268
#include <algorithm>
#include <iostream>
using namespace std;
int T,N,K,X[100000+10], A[100000+10];

int main(){
 cin >> T;
 for (int t=0; t<T; ++t){
  int Sum;
  cin >> N;
  cin >> K;
  for (int i=0; i<N; ++i)
    cin >> X[i];
  for (int i=0; i+1<N; ++i) A[i] = X[i+1]-X[i];
  sort(A,A+N-1);
  for (int i=0; i<(N-1-(K-1)); ++i)
  Sum += A[i];
  cout << Sum << endl;
  Sum = 0;
  }
 } 

Measured memory_bytes: 1956
n=int(input())
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
s=[0]*(n+1)
for i in range(a,n+1):
  s[i]=max(s[i],s[i-a]+d-a)
for i in range(b,n+1):
  s[i]=max(s[i],s[i-b]+e-b)
for i in range(c,n+1):
  s[i]=max(s[i],s[i-c]+f-c)
n+=s[-1]
s=[0]*(n+1)
for i in range(d,n+1):
  s[i]=max(s[i],s[i-d]+a-d)
for i in range(e,n+1):
  s[i]=max(s[i],s[i-e]+b-e)
for i in range(f,n+1):
  s[i]=max(s[i],s[i-f]+c-f)
print(n+s[-1])


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9



int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int ans = B + min(C, A+B+1);
  cout << ans << endl;
  return 0;
}


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

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

    long long c1 = 0, c2 = 0, sum = 0;

    // even positive
    for(int i = 0; i < n; i++){
        sum += A[i];
        if(i % 2){
            if(sum >= 0){
                c1 += sum + 1;
                sum = -1;
            }
        }else{
            if(sum <= 0){
                c1 += 1 - sum; 
                sum = 1;
            }
        }
    }

    sum = 0;
    // odd positive
    for(int i = 0; i < n; i++){
        sum += A[i];
        if(i % 2){
            if(sum <= 0){
                c2 += 1 - sum;
                sum = 1;
            }
        }else{
            if(sum >= 0){
                c2 += sum + 1;
                sum = -1;
            }
        }
    }
    cout << min(c1, c2) << endl; 

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans=0,n,i,j,u,k,x,y,p,sum,st,ok=0,pos[605],dp[2][1205][1205],fac[605],inv2[605],invfac[605];
const ll mod=1e9+7;
ll pow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll col(ll a){return a>2*n?a-2*n:a;}
ll cont(ll a,ll b,ll c){return (c>=a&&c<=b)||(c+2*n>=a&&c+2*n<=b);}
int main()
{
	scanf("%lld%lld",&n,&k);
	fac[0]=1;dp[0][1][0]=1;
	for(i=1;i<=2*n;i++)fac[i]=fac[i-1]*i%mod;
	invfac[2*n]=pow(fac[2*n],mod-2);
	for(i=2*n-1;i>=0;i--)invfac[i]=invfac[i+1]*(i+1)%mod;
	inv2[2*n]=pow(pow(2LL,2*n),mod-2);
	for(i=2*n-1;i>=0;i--)inv2[i]=inv2[i+1]*2%mod;
	for(i=1;i<=k;i++)
	{
		scanf("%lld%lld",&x,&y);
		pos[x]=y;pos[y]=x;
	}
	for(i=2;i<=2*n;i+=2)
	{
		for(j=1;j<=2*n;j++)
		{
			sum=0;
			for(u=j;u<=j+i-1;u++)
			{
				st=col(u);
				if(!pos[st])sum++;
				else if(!cont(j,j+i-1,pos[st]))goto tag;
			}
			dp[0][j][j+i-1]=dp[1][j][j+i-1]=fac[sum]*inv2[sum/2]%mod*invfac[sum/2]%mod;
			for(u=j+1;u<j+i-1;u+=2)dp[1][j][j+i-1]=(dp[1][j][j+i-1]-dp[1][j][u]*dp[0][u+1][j+i-1]%mod+mod)%mod;
			tag:;
		}
	}
	for(i=1;i<=2*n;i++)
	{
		for(j=i+1;j<=2*n;j+=2)
		{
			p=j<2*n?j+1:1;
			ans=(ans+dp[1][i][j]*dp[0][p][p+(2*n-(j-i+1)-1)]%mod)%mod;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 14336
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.next();
		int N = S.length();
		String color[] = new String[N];
		int ans = 0;
		int count = 0;
		for (int i = 0; i < N; i++) {
			color[i] = S.substring(i, i + 1);
		}

		for (int i = 0; i < N; i++) {
			if (i % 2 == 0) {
				if (color[i].equals("0")) {
					count++;
				}
			} else {
				if (color[i].equals("1")) {
					count++;
				}
			}
		}
		ans = count;
		count = 0;

		for (int i = 0; i < N; i++) {
			if (i % 2 != 0) {
				if (color[i].equals("0")) {
					count++;
				}
			} else {
				if (color[i].equals("1")) {
					count++;
				}
			}
		}

		ans = Math.min(ans, count);

		sc.close();

		System.out.println(ans);
	}
};

Measured memory_bytes: 44004
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

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

  	int x;
  	cin >> x;

  	int low = 0;
  	int high = 100000;
  	for(int i = 0; i < 50; i++){
  		ll mid = (low + high) / 2;
  		ll ans = mid * (mid + 1);
  		if(ans >= 2*x){
  			high = mid;
  		}
  		else{
  			low = mid + 1;
  		}
  	}
  	if((low*(low+1) >= 2*x)){
  		cout << low << endl;
  	}
  	else{
  		cout << high << endl;
  	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  string s, t;
  std::cin >> s >> t;
  ll a, b;std::cin >> a >> b;
  string u;std::cin >> u;
  if(u==s) std::cout << a-1 << " " << b << '\n';
  else std::cout << a << " " << b-1 << '\n';
  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val A, B = Integer.parseInt(sc.next())

    if ((A - B) % 2 != 0) {
      println("IMPOSSIBLE")
    } else {
      println(Math.min(A, B) + Math.abs(A - B) / 2)
    }
  }
}

Measured memory_bytes: 25528
#include<stdio.h>
#define MAX 100000

typedef struct {
	char suit;
	int value;
} Card;

void swap(Card *A, Card *B) {
	Card temp;

	temp = *A;
	*A = *B;
	*B = temp;
}

Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(Card A[], int left, int mid, int right) {
	int i, j, k;
	int n1, n2;

	n1 = mid - left;
	n2 = right - mid;
	for (i = 0; i < n1; i++) {
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; i++) {
		R[i] = A[mid + i];
	}
	L[n1].value = R[n2].value = 20000000;
	i = j = 0;
	for (k = left; k < right; k++) {
		if (L[i].value <= R[j].value) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}

}

void mergeSort(Card A[], int left, int right) {
	int mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

//Quick Sort
int partiton(Card A[], int p, int r) {
	int i, j;
	Card x;

	x = A[r];
	i = p - 1;
	for (j = p; j < r; j++) {
		if (A[j].value <= x.value) {
			i++;
			swap(&A[i], &A[j]);
		}
	}
	swap(&A[i + 1], &A[r]);
	return i + 1;
}

void quickSort(Card A[], int p, int r) {
	int q;

	if (p < r) {
		q = partiton(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

//Sort方法の比較
int isStable(Card C1[], Card C2[], int n) {
	int i;

	for (i = 0; i < n; i++) {
		if (C1[i].suit != C2[i].suit) {
			return 0;
		}
	}
	return 1;
}

int main() {
	Card Cm[MAX], Cq[MAX];
	int n, i, v;
	char S[10];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", S);
		scanf("%d", &v);

		Cm[i].suit = Cq[i].suit = S[0];
		Cm[i].value = Cq[i].value = v;
	}

	mergeSort(Cm, 0, n);
	quickSort(Cq, 0, n - 1);

	if (isStable(Cm, Cq, n)) {
		printf("Stable\n");
	}
	else {
		printf("Not stable\n");
	}
	for (i = 0; i < n; i++) {
		printf("%c %d\n", Cq[i].suit, Cq[i].value);
	}

	return 0;
}


Measured memory_bytes: 4068
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  vi t(8);
  int r = 0;
  rep(i, n) {
    int a;
    cin >> a;
    a /= 400;
    if (a < 8) {
      t[a] = 1;
    } else {
      r++;
    }
  }
  int x = count(all(t), 1);
  cout << max(1LL, x) << ' ' << x + r << endl;
}


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

using namespace std;

int main()
{
	string s, p, p_clone1, p_clone2;
	string::iterator it1;
	string::iterator it2;
	string::iterator it3;
	bool cond = false;
	
	cin >> s >> p;
	
	for(it1 = s.begin(); it1 != s.end(); it1++)
	{
		it2 = it1;
		it3 = it1;
		p_clone1 = "";
		p_clone2 = "";
		
		for(int j = 0; j < p.size(); j++)
		{
			if(it2 == s.end())
				it2 = s.begin();
			if(it3 == s.begin())
				it3 = s.end()--;
			p_clone1 += *it2;
			p_clone2 += *it3;
			it2++;
			it3--;
		}
		if(p_clone1 == p || p_clone2 == p)
		{
			cond = true;
			break;
		}
	}
	if(cond)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}


Measured memory_bytes: 3204
#include <cstdio>
#include <cmath>
 
#define MAX 100000

bool prime[MAX + 1];
int count[MAX + 1];
int N, L, R;

int main() {
  // 素数配列をエラトステネスの篩を使って生成
  // 素数であれば false, 素数でなければ true
  for (int i = 2; i < sqrt(MAX); ++i)
    if (!prime[i])
      for (int j = i + i; j <= MAX; j += i)
        prime[j] = true;

  // N と (N + 1) / 2 が素数である要素配列を生成
  // 条件が成立すれば 1、成立しなければ 0
  for (int i = 3; i<= MAX; i += 2)
    if (!prime[i] && !prime[(i + 1) >> 1])
      count[i] = 1;

  // 累積和を生成
  for (int i = 3; i<= MAX; ++ i)
    count[i] += count[i - 1];

  scanf("%d", &N);
  while (N --) {
    scanf("%d%d", &L, &R);
    printf("%d\n", count[R] - count[L - 1]);
  }

  fflush(stdout);
  return 0;
}


Measured memory_bytes: 2156
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

namespace Test {
	//プロトタイプ宣言
	template<typename T>
	T max(T, T);

	//関数テンプレート
	template<typename T>
	T max(T x, T y) {
		return x > y ? x : y;
	}
}

int X, Y, Z;

int main() {
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}

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

int n;
int a[10000001];

int main( int argc, char *argv[] )
{
    long long count = 0;

    scanf( "%d", &n );

    for( int i=1; i<=n; i++ ) {
//        printf( "%d : %d (%d)\n", i, a[i], i*a[i] );
        int m = (n / i) * i;
        count += (long long)(i+m) * m / i / 2;
    }

    printf( "%lld\n", count );
}



Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    string s;
    cin >> s;

    string ans = "";
    
    rep (i, s.size()) {
        if (s[i] == '0') ans += "0";
        else if (s[i] == '1') ans += "1";
        else {
            if (ans.size()) ans.pop_back();
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  
  string res;
  res.reserve(2 * N);
  for (size_t n = 0; n < N; ++n) {
    res += S[n];
    res += T[n];
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, a[N], dp[N], k;

void readInput() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
}

void solve() {
	memset(dp, 63, sizeof dp);
	dp[0] = 0;
	for (int i = 1; i < n; i++)
		for (int j = 1; j <= k; j++)
			dp[i] = min(dp[i], dp[max(0, i - j)] + abs(a[i] - a[max(0, i - j)]));
	cout << dp[n - 1] << endl;
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 1024