akhauriyash/Code-Regression huggingface dataset:
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;

int main()
{
	sync;
	ll arr[5];
	input(arr,(ll)5);
	ll ind=0;
	for(ll i=0;i<5;i++)
	if(arr[i]%10!=0&&arr[i]%10<arr[ind]%10)
	ind=i;
	ll tim=0;
	for(ll i=0;i<5;i++)
	if(i==ind)
	tim+=arr[i];
	else
	tim+=10*ceil(arr[i]/10.0);
	cout<<tim;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, k; cin >> n >> k;
    V<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    ll ans = 1e9;
    for(int l = 0; l <= n - k; l++){
        ll r = l + k - 1;
        ans = min(ans, abs(v[l]) + abs(v[l] - v[r]));
        ans = min(ans, abs(v[r]) + abs(v[r] - v[l]));
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 4044
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int a = Integer.parseInt(line1[0]);
        int b = Integer.parseInt(line1[1]);
        int c = Integer.parseInt(line1[2]);
        int d = c - (a - b);
        if(d <= 0)  d = 0;
        System.out.println(d);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  const ll mod = 1000 * 1000 * 1000 + 7;
  const int maxValue = 100 * 1000 + 2;
  ll n, x;
  cin >> n >> x;
  vector<ll> s(n);
  for (int i = 0; i < n; ++i) cin >> s[i];
  sort(s.begin(), s.end());
  vector<ll> a(maxValue);

  for (int t = 0; t < maxValue; ++t) a[t] = t % s[0];

  for (ll i = 1; i < n; ++i) {
    vector<ll> b(maxValue);
    for (int t = 0; t < maxValue; ++t) {
      b[t] = (a[t % s[i]] + i * a[t]) % mod;
    }
    a = b;
  }

  cout << a[x] << endl;
  return 0;
}


Measured memory_bytes: 1904
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<ll> a(3*N);
    for(int i=0;i<3*N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    ll out=0;
    for(int i=0;i<N;i++){
        out += a[i*2+1];
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

int main(){
	string s;
	cin>>s;
	int ans=0;
	for(int r=0,l=s.size()-1;r<l;r++,l--){
		if(s[r]!=s[l]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

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

    map<ll, ll> m;
    m[0] = 1;
    ll cs = 0;
    ll ans = 0;
    REP(i, n){
        ll ai;
        cin >> ai;

        ans += m[cs + ai];
        cs += ai;
        m[cs]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll N;
    cin >> N;
    string A;
    cin >> A;
    string B;
    cin >> B;
    string C;
    cin >> C;
    ll count=0;
    vector<char> yose(N,' ');
    for(ll i=0;i<N;i++){
        if(A[i]==B[i])yose[i]=A[i];
        else if(B[i]==C[i])yose[i]=B[i];
        else yose[i]=A[i];
    ;}
    for(ll i=0;i<N;i++){
        if(A[i]!=yose[i])count++;
    ;}
    for(ll i=0;i<N;i++){
        if(B[i]!=yose[i])count++;
    ;}
    for(ll i=0;i<N;i++){
        if(C[i]!=yose[i])count++;
    ;}
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	a := make(map[string]int)

	for sc.Scan() {
		b := sc.Text()

		if b == "" {
			break
		}

		b = strings.ToLower(b)

		for _, v := range b {
			a[string(v)]++
		}
	}

	for i := 0; i < 26; i++ {
		fmt.Printf("%s : %d\n", string('a'+i), a[string('a'+i)])
	}
}



Measured memory_bytes: 1120
import math

def main():
    N = int(input())
    sqrt = math.sqrt(N)
    ans = len(str(N))
    for i in range(1, int(sqrt) + 2):
        if N % i == 0:
            a = i
            b = N // i
            ans = len(str(b))
        else:
            continue
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

#define     ll long long
#define     nl '\n'
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mod             100000000
#define     space           100005

vector<ll> pwx(61);
void cal(ll x){ pwx[0] = 1; for(ll i = 1; i < 61 ; i++)pwx[i] = x*pwx[i-1]; }

int main(){
    // boost;
    
    // cal(2);

    string s, t;
    cin >> s >> t;

    ll ans = 0;

    for(ll i = 0 ; i < s.length() ; i++){
        ans += (s[i] == t[i] ? 0 : 1);
    }

    cout << ans <<nl;

    return 0;
}

Measured memory_bytes: 3852
n=int(input())
s=input()
t=input()

if s==t:
    print(n)
    exit()

for i in range(1,n):
    sub_s=s[i:]
    sub_t=t[:-i]

    if sub_s==sub_t:
        print(n+i)
        exit()

print(n*2)

Measured memory_bytes: 9048
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

const int MAX_H = 100;
const int MAX_W = 100;
int H, W;
char a[MAX_H][MAX_W + 1];

void _main() {
  cin >> H >> W;
  rep(i, 0, H) cin >> a[i];

  string s(W + 2, '#');
  cout << s << "\n";
  rep(i, 0, H) cout << "#" << a[i] << "#" << "\n";
  cout << s << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vi p;
int ans = 0;

int main() {
    cin >> N;
    p.resize(N);
    rep(i, N) cin >> p[i];

    if (p[0] == 1) {
        swap(p[0], p[1]);
        ans++;
    }
    if (p[N - 1] == N) {
        swap(p[N - 2], p[N - 1]);
        ans++;
    }

    rep(i, 1, N - 1) {
        if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }

    write(ans);
}

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

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

int main() {
	int k;
	cin >> k;
	long long int ans=0;

	for(int i=1;i<=k;i++){
		for(int m=1;m<=k;m++){
			for(int n=1;n<=k;n++){
				ans = ans + gcd3(i,m,n);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = n % 10;
  if(ans == 3){
    cout << "bon" << endl;
  }else if(ans == 1 || ans == 0 || ans == 6 || ans == 8){
    cout << "pon" << endl;
  }else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include<string.h>
#include <algorithm>
#include<math.h>
#include<vector>
#include <queue>
#include <deque> 
#define ll long long
#define M 1000000007 
#define MM 998244353
using namespace std;
 
int main()
{
	int n; 
	cin >> n;

	if (n%1000 != 0)
	{
		cout << (((n/1000) + 1)*1000) - n;
	}
	else
	{
		cout << 0;
	}

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define Mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define lson root<<1
#define rson root<<1|1
#define Mid int mid=(l+r)>>1
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define MAXN 200100
using namespace std;
int n;
struct fc{
    int ans1,ans2;
    int l,r;
    int idl,idr;
    bool operator <(const fc &b)const{
        return b.ans1<ans1;
    }
};
struct Tree{
    int Min;
    int id;
};
Tree seg[2][MAXN<<2];
int a[MAXN];
void push_up(int root,int l,int r,int type){
    seg[type][root].Min=min(seg[type][lson].Min,seg[type][rson].Min);
    seg[type][root].Min==seg[type][lson].Min?seg[type][root].id=seg[type][lson].id:seg[type][root].id=seg[type][rson].id;
}
void build(int root,int l,int r,int type){
    if(l==r){
        seg[type][root].Min=a[2*l-type];
        seg[type][root].id=2*l-type;
        return ;
    }
    Mid;
    build(lson,l,mid,type);
    build(rson,mid+1,r,type);
    push_up(root,l,r,type);
}
priority_queue<fc>q;
Tree query(int root,int l,int r,int ql,int qr,int type){
    Tree res1,res2;
    if(l>=ql&&r<=qr){
        Tree tmp;
        tmp.id=seg[type][root].id;
        tmp.Min=seg[type][root].Min;
        return tmp;
    }
    if(l>qr||r<ql) return res1={inf,0};
    Mid;
    res1=query(lson,l,mid,ql,qr,type);
    res2=query(rson,mid+1,r,ql,qr,type);
    if(res1.Min<res2.Min)
        return res1;
    else return res2;
}
fc work(int l,int r){
    Tree res1,res2;
    if(l&1){
        res1=query(1,1,n/2,(l+1)/2,r/2,1);
        res2=query(1,1,n/2,(res1.id+1)/2,r/2,0);
    }
    else{
        res1=query(1,1,n/2,l/2,r/2,0);
        res2=query(1,1,n/2,res1.id/2+1,r/2+1,1);
    }
    fc tmp={res1.Min,res2.Min,l,r,res1.id,res2.id};
    return tmp;
}
int main() {
    //FREI;
    //FREO;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    build(1,1,n/2,0);
    build(1,1,n/2,1);
    Tree res1=query(1,1,n/2,1,n/2,1);
    Tree res2=query(1,1,n/2,(res1.id+1)/2,n/2,0);
    q.push((fc){res1.Min,res2.Min,1,n,res1.id,res2.id});
    int cnt=0;
    while(!q.empty()){
        fc tmp=q.top();
        q.pop();
        cnt+=2;
        if(cnt==n) printf("%d %d\n",tmp.ans1,tmp.ans2);
        else printf("%d %d ",tmp.ans1,tmp.ans2);
        int type=0;
        if(tmp.idl-1>tmp.l){
            //cout<<tmp.l<<' '<<tmp.idl-1<<endl;
            fc _tmp=work(tmp.l,tmp.idl-1);
            q.push(_tmp);
        }
        if(tmp.idr-1>tmp.idl+1){
            //cout<<tmp.idl+1<<' '<<tmp.idr-1<<endl;
            fc _tmp=work(tmp.idl+1,tmp.idr-1);
            q.push(_tmp);
        }
        if(tmp.r>tmp.idr+1){
            //cout<<tmp.idr+1<<' '<<tmp.r<<endl;
            fc _tmp=work(tmp.idr+1,tmp.r);
            q.push(_tmp);
        }
    }
    return 0;
}


Measured memory_bytes: 10740
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '1') {
				ans++;
			}
		}
		System.out.println(ans);
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 22868
import java.util.ArrayList;
import java.util.Scanner;

class Main{

	static int N;
	static int M;
	static 		ArrayList<ArrayList<Integer>> map;
	static boolean[] used;
	static int f = 0;
	static int s = 0;

	static int mindis = 1000000000;
	static ArrayList<Integer> saitan;




	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] b = new int[n+1];

		for(int i = 1;i <= n;i++){
			a[i] = sc.nextInt();
		}

		int num = 0;

		for(int i = 1;i <= (n+1)/2;i++){
		//	System.out.println(i);
			b[i] = a[n-2*(i-1)];
			num  = i;

		}

		if(n%2 == 0){
			int c = 0;
			for(int i = num+1;i < b.length;i++){
		//		System.out.println(i);
				b[i] = a[c*2+1];
				c++;

			}
		}else{
			int c = 0;
			for(int i = num+1;i < b.length;i++){
		//		System.out.println(i);
				b[i] = a[c*2+2];
				c++;

			}
			
		}

		for(int i = 1;i < b.length;i++){
			System.out.print(b[i]);
			System.out.print(" ");


		}
	}

}




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

int64_t N;
vector< pair<int64_t,int64_t> > S;
int main() {
  cin >> N;
  for (int64_t i=0;i<N;i++ ) {
    int64_t ain, bin;
    cin >> ain >> bin;
    S.push_back(make_pair(bin, ain));
  }
  sort(S.begin(), S.end());

  int64_t now = 0;
  int ng = 0;
  for (int64_t i=0; i<N; ++i ) {
    now += S[i].second;
    if ( now > S[i].first ) {
      ng = 1;
      break;
    }
  }
  if (ng == 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int k,l,m,n;cin>>k>>l>>m>>n;
    int a,b;
    a=k/n;
    if(k%n>0)a++;
    b=m/l;
    if(m%l>0)b++;
    if(b<=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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


int main(){
  string s;
  cin >> s;
  int n=s.size();
  int ans=0;
  for(int i=0;i<n-1;++i){
    if(s[i]!=s[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int i,j,n,m,t[50001],c[21];
  cin >> n >> m;
  for(i = 0; i < m; i++) cin >> c[i];
  for(j = 0; j <= n; j++) t[j] = 10001;
  t[0] = 0;
  
  for(i = 0; i < m; i++){
    for(j = c[i]; j <= n; j++){
      t[j] = min( t[j], t[j-c[i]] + 1 );
    }
  }

  cout << t[n] << endl;;

  return 0;
}

Measured memory_bytes: 1356
S = input().split()
tf7 = False
tf52 = False
count5 = 0
for x in S:
	if x == "5":
		count5 += 1
		if count5 == 2:
			tf52 = True
	if x == "7":
		tf7 = True
if tf7==True and tf52==True:
	print("YES")
else :
	print("NO")




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

int main(void){
  string s;
  cin>>s;
  int g,p;
  g=p=0;
  int res=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='g'){
      if(g==p){
        g++;
      }
      else{
        p++;
        res++;
      }
    }
    else{
      if(g==p){
        g++;
        res--;
      }
      else{
        p++;
      }
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 512
n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax:
        print(ans + h // amax + (h % amax > 0))
        break
    if h <= 0:
        print(ans)
        break
    h -= bi
    ans += 1
else:
    print(ans + h // amax + (h % amax > 0))


Measured memory_bytes: 84312
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

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

  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  int b[n];
  for(int i = 0; i < n; i++){
    b[i] = a[i] - (i + 1);
  }

  sort(b, b + n);
  int c = b[n / 2];
  ll sum = 0;
  for(int i = 0; i < n; i++){
    sum += abs(b[i] - c);
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	
	int k ;
	cin>>k;
	cin>>s;
	if(s.size() <= k)
	cout<<s;
	else
	{
	    cout<<s.substr(0,k) + "...";
	}
	
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    long c = long.Parse(input[2]);

    bool answer = true;

    if(c <= a+b) answer = false;
    else if(4*a*b >= (c-a-b)*(c-a-b)) answer = false;

		Console.WriteLine(answer?"Yes":"No");
	}
}

Measured memory_bytes: 11092
#include<stdio.h>
#define MAX 101
#define INFI 20000000

int M[MAX][MAX];


int min(int a,int b){
if(a>b){return b;}
else{return a;}
}


int matrix(int n,int R[],int C[]){
int temp,i,j,k;



for(k=1;k<n;k++){
 for(i=0;i<n-k;i++){if(i!=i+k)M[i][i+k]=INFI;
  for(j=i;j<i+k;j++){
   temp=M[i][j]+M[j+1][i+k]+R[i]*C[j]*C[i+k];
   M[i][i+k]=min(temp,M[i][i+k]);
  }
 }
}


return M[0][n-1];
}





int main(){
int n,i,j;
int R[MAX];
int C[MAX];
int x;

scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d %d",&R[i],&C[i]);/*0…行 1…列*/


for(i=0;i<n;i++)M[i][i]=0;


x=matrix(n,R,C);

printf("%d\n",x);

return 0;
}



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

int main()
{
	int A, B;
	string S,T,U;

	cin >> S >> T >> A >> B >> U;

	if (S == U)
	{
		A--;
	}

	else
	{
		B--;
	}

    cout << A <<" "<< B <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
        long long unsigned int X,Y;
        scanf("%llu %llu",&X, &Y);
        long long unsigned int field=X,afterfield=0,count=0,hozon=0;
        while(afterfield<=Y){
                hozon = field;
                afterfield = field*2;
                field = afterfield;
                count++;
        }
        printf("%llu\n", count);
        return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
main(void)
{
        int A, B, T;
        int count = 0;

        scanf("%d %d %d", &A, &B, &T);

        for (int i = A; i < T + 0.5; i += A)
                count += B;

        printf("%d", count);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
//#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
map<ll,int>ma;
vvi in;
int main(){
	int n;
	cin>>n;
	in=vvi(n);
	rep(i,n){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		in[i]=vi{a,b,c};
		ma[a*1000000001ll+b]=c;
	}
	ll a=0,b=1,sum,sx,sy,gx,gy,area,gc_d=1;
	rep(q,n){
		loop(x,-1,2)loop(y,-1,2)if(x!=0&&y!=0){
			sum=0;
			sx=min(in[q][0],in[q][0]+x);
			gx=max(in[q][0],in[q][0]+x);
			sy=min(in[q][1],in[q][1]+y);
			gy=max(in[q][1],in[q][1]+y);
			loop(i,sx,gx+1)loop(j,sy,gy+1)if(ma.count(i*1000000001ll+j))sum+=ma[i*1000000001ll+j];
			area=abs(x*y);
			gc_d=gcd(sum,area);
			sum/=gc_d;
			area/=gc_d;
			if(a*area<b*sum){
				a=sum;
				b=area;
			}
		}
	}
	cout<<a<<" / "<<b<<endl;
}

Measured memory_bytes: 14472
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int mod = 1e9 + 7;
const int inf = 2e9 + 7;

int n, k;
int w[N], s[N], a[N];
ll dp[1100][20200];
vi ans;
bool comp(int i, int j) {
	re w[i] + s[i] < w[j] + s[j];
}		

int main() {
	cin >> n; 
	for (int i = 0; i < n; i++)	
		scanf("%d%d%d", w + i, s + i, a + i);
	for (int i = 0; i < n; i++) ans.pb(i);
	sort(all(ans), comp);
	for (int i = 1; i <= n; i++) { 
		for (int j = 0; j < 20010; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= w[ans[i - 1]] && s[ans[i - 1]] >= j - w[ans[i - 1]]) 
				dp[i][j] = max(dp[i][j], a[ans[i - 1]] + dp[i - 1][j - w[ans[i - 1]]]);
		}
	}
	ll ans = 0;
	for (int i = 0; i < 20010; i++)
		ans = max(ans, dp[n][i]);
	cout << ans << endl;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    
    vector<vector<int>> A;
    A.resize(K);
    
    for ( int i = 0; i < K; ++i){
        int d;
        cin >> d;
        for ( int j = 0; j < d; ++j){
            int x;
            cin >> x;
            A.at(i).push_back(x-1);
        }
    }
    
    vector<int> ans(N,1);
    
    for ( int i = 0; i < K; ++i){
        for ( int j = 0; j < A.at(i).size(); ++j){
            ans.at(A.at(i).at(j)) = 0;
        }
    }
    
    
    int res = 0;
    for ( int i = 0; i < N; ++i){
        res += ans.at(i);
    }
    
    cout << res << endl;
    
    
    return 0;
}


Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		long[] list = new long[n];
		for(int i = 0; i < n; i++) {
			list[i] = sc.nextLong();
		}
		Arrays.sort(list);
		long ans = 0l;
		if(n > k) {
			for(int i = 0; i < n-k; i++) {
				ans += list[i];
			}
		}
		System.out.println(ans);

	}

	static  class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 53132
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int N;
	int A[100100];
	int ans;
	int noshort=0;
	cin>>N;
	A[0]=0;
	A[N+1]=0;
	for(int i=1;i<=N;i++){
		cin>>A[i];
	}
	for(int i=0;i<=N;i++){
		noshort+=abs(A[i]-A[i+1]);
	}
	for(int i=1;i<=N;i++){
		if(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])>abs(A[i-1]-A[i+1])){
			ans=noshort-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])-abs(A[i-1]-A[i+1]));
		}else{
			ans=noshort;
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while(true){
		c -= b;

		if(c <= 0){
			cout << "Yes";
			break;
		}

		a -= d;

		if(a <= 0){
			cout << "No";
			break;
		}		
	}

	return 0;
}

Measured memory_bytes: 3624
k = int(input())
x = 7
ans = 1
if k%2 == 0 or k%5 ==0:
  print(-1)
  exit()
elif 7%k == 0:
  ans = 1

else:
  for i in range (1,k):
    x = (x*10+7)%k

    if x%k == 0:
      ans = i+1
      break

print(ans)



Measured memory_bytes: 63020
// 042A
#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int _51 = 0;
    int  _7 = 0;
    int _52 = 0;

    if (a == 5 || b == 5 || c == 5) {
        _51 = 1;
        if (a == 5) {
            a = 0;
        } else if (b == 5) {
            b = 0;
        } else if (c == 5) {
            c = 0;
        }
    }

    if (a == 7 || b == 7 || c == 7) {
        _7 = 1;
        if (a == 7) {
            a = 0;
        } else if (b == 7) {
            b = 0;
        } else if (c == 7) {
            c = 0;
        }
    }

    if (a == 5 || b == 5 || c == 5) {
        _52 = 1;
        if (a == 5) {
            a = 0;
        } else if (b == 5) {
            b = 0;
        } else if (c == 5) {
            c = 0;
        }
    }

    puts( ((_51 == 1) && (_7 == 1) && (_52 == 1) && (a == 0) && (b == 0) && (c == 0)) ? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(n, m, i) for (i32 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i32 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i32 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n;
i32 cnt[100001];

i32 main()
{
    cin >> n;
    memset(cnt, 0, sizeof(cnt));
    i64 rest = 0;
    i64 ans = 0;
    times(n, i) {
        i32 a; cin >> a;
        if (cnt[a] == 0) {
            ans++;
        } else {
            rest++;
        }
        cnt[a]++;
    }
    if (odd(rest)) {
        cout << ans - 1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

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

void sort(int a, int b, int c){
   int min,mid,max;
   if( b <= a && b <= c && a<=c){
       min = b;
       mid = a;
       max = c;
    }else if(b <= a && b <= c && c<=a){
        min = b;
        mid = c;
        max = a;
    }else if(c<=a && c<=b && a<=b){
        min = c;
        mid = a;
        max = b;
    }else if(c<=a && c<=b && b<=a){
        min = c;
        mid = b;
        max = a;
    }else if(a<=b && a<=c && b<=c){
        min = a;
        mid = b;
        max = c;
    }else{
        min = a;
        mid = c;
        max = b;
    }
    printf("%d %d %d\n", min,mid,max);
     
  }
int main(){
    int a,b,c;
    int min,mid,max;

    cin >> a >> b >> c;
    sort(a,b,c);
    
    return 0;

}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int up(long long a,long long b){
	return (a+b-1)/b;
}
int main(){
	int T;
	cin>>T;
	while(T--){
		int x,y,a,b;
		cin>>a>>b>>x>>y;
		int l=up(max(a,b),min(a,b)+1);
			int le=0,r=min(a,b);
			int res=0;
			while(le<=r){
				int mid=le+r>>1;
				if(up(b-mid,l)<=a-mid*l&&a-mid*l<max(up(b-mid,l),1)+l){
					res=mid;
					break;
				}
				else{
					if(a-mid*l<up(b-mid,l)) r=mid-1;
					else le=mid+1;
				}
			}
			int tmpa=a-res*l-up(b-res,l)+1,tmpb=(b-res-1)%l+1,re1=res,re2=(b-res-tmpb)/l;
		//	cout<<tmpa<<" "<<tmpb<<" "<<re1<<" "<<re2<<endl;
			int fir=(l+1)*re1,sec=fir+tmpa,thi=sec+tmpb,fou=thi+(l+1)*re2;
			for(int i=x;i<=min(fir,y);i++) if(i%(l+1)) cout<<"A";else cout<<"B";
			for(int i=max(x,fir+1);i<=min(sec,y);i++) cout<<"A";
			for(int i=max(x,sec+1);i<=min(thi,y);i++) cout<<"B";
			for(int i=max(x,thi+1);i<=y;i++) if((i-thi)%(l+1)!=1) cout<<"B"; else cout<<"A";
			cout<<endl;
	}
} 

Measured memory_bytes: 764
n = int(input())
st = []
for i in range(n):
    x,l = map(int,input().split())
    st.append([x-l,x+l])

st.sort(key=lambda x:x[1])
t0 = st[0][1]
cnt = n
for s,t in st[1:]:
    if t0 <= s:#もし終わりが次の始まりより早かったら
        t0 = t
    else:
        cnt -=1
print(cnt)


Measured memory_bytes: 21336
#include "bits/stdc++.h"
using namespace std;

int main(void) {
	int n, m, x, y,i,a;
	int sup,inf;
	scanf("%d %d %d %d", &n, &m, &x, &y);
	vector<int> v;
	vector<int> w;
	for (i = 0; i<n; ++i) {
		cin >> a;
		v.push_back(a);
	}
	for (i = 0; i<m; ++i) {
		cin >> a;
		w.push_back(a);
	}
	sort(v.begin(), v.end());
	sort(w.begin(), w.end());
	sup = v[n - 1];
	inf = w[0];
	if(min(y,inf)-max(x,sup)<=0){
      printf("War\n");
    }
	else {
		printf("No War\n");

	}
	return 0;
}

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

int main(){

        int n;
        cin>>n;

        int* b = new int [n-1];

        int s = 0;

        for(int i = 0; i < n-1; i++)cin>>b[i];

        for(int i = 0; i < n; i++){
                if( i == 0 ) s+=b[i];
                else if( i == n-1) s+= b[i-1];
                else {
                        if(b[i] > b[i-1])s+=b[i-1];
                        else s+=b[i];
                }
        }

        cout<<s<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=0
B=0
C=0
ans=0
for _ in range(0,N):
    s=input()
    if s[0]=='B':
        B+=1
    if s[-1]=='A':
        A+=1
    if s[-1]=='A' and s[0]=='B':
        C+=1

    for i in range(0,len(s)-1):
        if s[i]=='A' and s[i+1]=='B':
            ans+=1

if A!=C or B!=C:
    print(ans+min(A,B))
else:
    if A==0:
        print(ans)
    else:
        print(ans+C-1)



Measured memory_bytes: 45784
/*
Author: Xjrjyy
LANG: C++
PROG: agc003_b.cpp
Mail: admin@xjrjyy.com
Blog: https://blog.xjrjyy.cn/
*/

#include <cstdio>
#include <cctype>
#include <vector>
#include <iostream>

#define MAXN (100005)

int n;
int s[MAXN];
long long ans;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &s[i]);
    }
    for (int i = 0; i < n; ++i)
    {
        if (s[i] & 1 && s[i + 1])
        {
            ++s[i];
            --s[i + 1];
        }
        ans += s[i] >> 1;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 4196
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	int a, b, sum;

	while(1){
		cin >> a >> b;
		
		if(cin.fail()){
			break;
		}

		sum = a + b;

		if(sum >= 1000000){
			cout << 7 << endl;
		}
		else if(sum >= 100000){
			cout << 6 << endl;
		}
		else if(sum >= 10000){
			cout << 5 << endl;
		}
		else if(sum >= 1000){
			cout << 4 << endl;
		}
		else if(sum >= 100){
			cout << 3 << endl;
		}
		else if(sum >= 10){
			cout << 2 << endl;
		}
		else if(sum >= 1){
			cout << 1 << endl;
		}
		else{
			cout << 0 << endl;
		}
	}
	

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
	int N;
	cin>>N;
	vint A(N+1);rep(i,N+1)cin>>A[i];
	int ans=0;
	rep(i,N){
		int b;cin>>b;
		int tmp=min(b,A[i]);
		b-=tmp;
		ans+=tmp;
		tmp=min(b,A[i+1]);
		ans+=tmp;
		A[i+1]-=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#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() {
  string s;
  cin >> s;
  if(s=="ABC") cout << "ARC";
  else cout << "ABC";
  
  return 0;

}

Measured memory_bytes: 3624
//include
//------------------------------------------
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

int main(void){
  int a,b,c;
  int ans =3;
  scanf("%d %d %d",&a,&b,&c);
  if(a == b) ans--;
  if(b == c) ans--;
  if(a == c) ans--;
  if(ans <=0)ans = 1;
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int A,B,C,D;
cin >> A >> B >> C >> D;
if(min(B,D) - max(A,C) > 0) {
cout << min(B,D) - max(A,C) << endl;
} else cout << 0 << endl;


return 0;
}

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

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

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  string s;
  cin>>s;

  if(n==1){
    cout<<(s[0]=='W')<<endl;
    return 0;
  }

  Int ans=0,dec=0;
  auto dp=make_v<Int>(2,n);
  fill_v(dp,0);
  vector<Int> ok(n,0);
  vector<Int> cnt(n,0);
  
  function<void(Int, Int)> dfs=[&](Int v,Int p)->void{
    cnt[v]=(p!=-1);
    ok[v]=s[v]=='W';

    using P = pair<Int, Int>;
    vector<P> vp1,vp2;
    vp1.emplace_back(0,-1);
    vp2.emplace_back(0,-1);
    vp1.emplace_back(0,-1);
    vp2.emplace_back(0,-1);
    
    for(Int u:G[v]){
      if(u==p) continue;
      dfs(u,v);
      if(!ok[u]) continue;
      ok[v]=1;
      chmax(dp[0][v],dp[0][u]+(cnt[u]%2 != (s[u]=='W')));
      chmax(dp[1][v],dp[1][u]);
      vp1.emplace_back(dp[0][u]+(cnt[u]%2 != (s[u]=='W')),u);      
      vp2.emplace_back(dp[1][u],u);
      ans+=2;      
      cnt[v]++;      
    }    
    if(!ok[v]) return;
    //cout<<v<<":"<<dp[0][v]<<" "<<dp[1][v]<<endl;
    
    for(Int i=0;i<(Int)vp2.size();i++){
      if(vp2[i].second<0) continue;
      vp2[i].first+=(cnt[v]%2 != (s[v]=='W'));
    }
    
    dp[1][v]+=(cnt[v]%2 != (s[v]=='W'));
    if(cnt[v]%2 != (s[v]=='W')) ans++;
    //cout<<v<<":"<<cnt[v]<<" "<<s[v]<<":"<<(cnt[v]%2 != (s[v]=='W'))<<endl;
    
    sort(vp1.rbegin(),vp1.rend());
    sort(vp2.rbegin(),vp2.rend());

    //cout<<v<<":"<<vp1[0].first<<" "<<vp2[0].first<<endl;
    //cout<<v<<":"<<vp1[0].first+vp2[vp1[0].second==vp2[0].second].first<<endl;
    //cout<<v<<":"<<vp2[0].first+vp1[vp1[0].second==vp2[0].second].first<<endl;
    
    chmax(dec,vp1[0].first+vp2[vp1[0].second==vp2[0].second].first);
    chmax(dec,vp2[0].first+vp1[vp1[0].second==vp2[0].second].first);
  };

  Int r=-1;
  for(Int i=0;i<n;i++){
    if(s[i]=='B') continue;
    dfs(r=i,-1);
    break;
  }

  //cout<<ans<<endl;
  cout<<ans-dec*2<<endl;
  return 0;
}


Measured memory_bytes: 38640
n = input()

for i in range(2 ** 3):
    i2 = bin(i)[2:].zfill(3)
    i3 = n[0]
    total = int(n[0])
    for j in range(3):
        if i2[j] == '1':
            # plus
            total += int(n[j+1])
            i3 += '+'
        else:
            # minus
            total -= int(n[j+1])
            i3 += '-'
        i3 += n[j+1]

    if total == 7:
        break

print(i3 + '=7')


Measured memory_bytes: 3188
import java.util.*;
public class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		long x=s.nextLong();

		//for(x=1;x<100;x++) {
			long count=(x/11)*2;
			//System.out.printf("%3d ",x);
			if(x%11==0) {
				System.out.println(count);
			}else if (x%11<=6) {
				System.out.println(count+1);
			}else {
				System.out.println(count+2);
			}
		//}
	}
}


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


int main()
{
	int i,j,k,l;
	int n,m;
	char a[257][257];
	char b[257][257];
	int p=0; //空いていれば１

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{scanf("%s",a[i]);}

	scanf("%d",&m);
	for(i=0;i<m;i++)
	{scanf("%s",b[i]);}

	for(i=0;i<m;i++)
		{
			int c=0; 
			for(j=0;j<n;j++)
			{
				if(strcmp(b[i],a[j])==0)
				{
					if(p==0){printf("Opened by %s\n",b[i]);p=1;c++;break;}
					else{printf("Closed by %s\n",b[i]);p=0;c++;break;}
				}
			}
			if(c==0)
			{
				printf("Unknown %s\n",b[i]);
			}
		}
	return 0;
}
	

Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
double abss(double x,double y)
{
	if(x>y)
	{
		return x-y;
	}
	else
	{
		return y-x;
	} 
}
int main()
{
	double a,b,h,m;
	scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
	double jh=360.0*h/12.0+30*m/60;
	double jm=360.0*m/60.0;
	double cha=abss(jh,jm);
	double ans=sqrt(b*b+a*a-2*b*a*cos(cha/180.0*3.1415926535898));
	printf("%.11lf\n",ans);
	return 0;
} 

Measured memory_bytes: 2592