akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

Measured memory_bytes: 256
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return (3*n+1)

def ff(a1, history, n):
    a2 = f(a1)
    n += 1
    if a2 in history:
        return n

    history.append(a2)

    return ff(a2, history, n)

s = int(input())
print(ff(s,[s],1))

Measured memory_bytes: 3060
N, K = map(int, input().split())
P = list(map(int, input().split()))
sum_i = [0]
for pi in P:
    s = (pi * (1 + pi)) / 2 / pi
    sum_i += [s + sum_i[-1]]
# print(sum_i)
ans = 0
for i in range(N-K+1):
    ans = max(ans, sum_i[i+K] - sum_i[i])
print(ans)

Measured memory_bytes: 76040
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int m,k;
  cin>>m>>k;
  if (k >= (1 << m)) {
    cout << -1 << endl;
    return 0;
  }
  if (m == 1) {
    if (k == 1) {
      cout << -1 << endl;
    } else {
      cout << "0 0 1 1" << endl;
    }
    return 0;
  }
  int n = 1<<m;
  REP(i,n) {
    if (i == k) continue;
    cout << i << ' ';
  }
  cout << k << ' ';
  for (int i=n-1; i>=0; --i) {
    if (i == k) continue;
    cout << i << ' ';
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
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 (a>b) { a=b; return 1; } return 0; }

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

    int n, m; cin >> n >> m;
    ve_vei a(n, vei(m)); rep(i,n) rep(j,m) cin >> a[i][j];
    vei b(m), c(n,0); rep(i,m) cin >> b[i];

    rep(i,n) {
        rep(j,m) c[i] += a[i][j] * b[j];
        cout << c[i] << endl;
    }
}


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

public class Main {
    public static void main(String[] args) {
        InputStream in = System.in;
        OutputStream out = System.out;
        FastScanner fs = new FastScanner(in);
        PrintWriter pw = new PrintWriter(out);
        int A = fs.nextInt(), B = fs.nextInt(), K = fs.nextInt();
        List<Integer> list = new ArrayList<>();
        if(A < B) {
            B += A;
            A = B - A;
            B = B - A;
        }
        for(int i = 1; i <= A; i++) {
            if(A % i == 0 && B % i == 0) {
                list.add(i);
            }
        }
        pw.println(list.get(list.size() - K));
        pw.close();
    }
}

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: 21204
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[3];
signed main(){
	rep(i,3)cin>>a[i];
	int Min=INT_MAX;
	do{
		Min=min(Min,abs(a[1]-a[0])+abs(a[2]-a[1]));
	}while(next_permutation(a,a+3));
	cout<<Min<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,i;
char c[20];
for(i=0;i<9;i++){
scanf("%s %d %d\n",c,&a,&b);
printf("%s %d %d\n",c,a+b,a*200+b*300);
}
return 0;
}


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

int main() {

int X;
  cin >>X;
  int N500,N5,mon;
  N500=X/500;
  N5=(X-N500 * 500)/5;
  mon = N500*1000 + N5*5;
  cout<<mon<<endl;
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
inline int roundup(int a, int b) { return (((a + (b -1)) / b)); }
using namespace std;

signed main(void) {
    int sum = 0;
    string n;
    cin >> n;
    for (int  i = 0; i < (int)n.size(); ++i)
    {
        sum += (n.at(i) - '0');
    }
    cout << ((sum % 9 == 0 || sum == 0)? "Yes": "No") << endl;
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
using vi = vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0


bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}


int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    
    int n, k; cin >> n >> k;
    
    if (k > (n - 1) * (n - 2) / 2) {cout << -1 << endl; return 0;}
    
    //complete graph
    int m = n * (n - 1) / 2;
    int table[101][101] = {0};
    
    rep3(i, 1, n + 1) {
        rep3(j, i + 1, n + 1) {
            table[i][j] = 1;
        }
    }
    
    cout << m - k << endl;
    
    int breakflg = 0;
    if (k == 0) breakflg = 1;
    rep3(i, 1, n) {
        if (breakflg) break;
        rep3(j, i + 1, n) {
            table[i][j] = 0;
            k--;
            if (k == 0) {
                breakflg = 1;
                break;
            }
        }
    }
    
    //完全グラフから辺落とす際、1頂点に関しては全部と繋がってたら
    //最短距離2が担保されそう
    if (k) {cout << -1 << endl; return 0;}
    
    rep3(i, 1, n + 1) {
        rep3(j, i + 1, n + 1) {
            if (table[i][j]) cout << i << " " << j << endl;
        }
    }
    return 0;
    
    
    
    
}
//cast caution



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
main() {
 int N, M;
 cin >> N >> M;
 int total = 0;
  
 vector<int> A(N);
  for (int i=0; i<N; i++){ 
    cin >> A.at(i);
    total += A.at(i);
  }
  
  if (total <= N)
    cout << N - total <<endl;
  else
    cout << "-1" <<endl;

}

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

int main(){
  long long n,m,ans=0;
  cin>>n>>m;
  if(n>=m/2){
    ans=m/2;
  }else{
    ans+=n;
    m-=n*2;
    ans+=m/4;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int a,b,c,d;
LL ans;
int main()
{
	cin>>a>>b>>c>>c>>d;
	//acd
	if(a&&c&&d)ans=max(ans,3ll+b+(a-1)/2*2+(c-1)/2*2+(d-1)/2*2);
	
	//no acd
	ans=max(ans,0ll+b+a/2*2+c/2*2+d/2*2);
	printendl(ans);
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream
using namespace std;
using ll = long long;
const int mod = 1000000007;
 
ll gcd(ll a, ll b){return b ? gcd(b,a%b) : a;};//最大公約数
ll lcm(ll a, ll b){return a*b/gcd(a,b);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
typedef pair<string,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];
 
 
int main(){
   ll a,b,c;
  cin>>a>>b>>c;
 ll d=c-a-b;
  
  if(d>0 && d*d>4*a*b){
    cout<<"Yes";
  }else{cout<<"No";}
  return 0;
}

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

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].second >> a[i].first;
  }
  sort(a.begin(), a.end());
  vector<ll> s(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    s[i] = a[i - 1].second + s[i - 1];
  }
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (s[i + 1] > a[i].first) {
      flag = false;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> PII;
typedef vector<int> VI;

const int N=2e5+10;
int a[N];

int main() {
	int n;
	scanf("%d",&n);
	ll tot=0;
	rep(i,0,n) {
		scanf("%d",&a[i]);
		tot+=a[i];
	}
	ll ans = 1e18,soma=0;
	ll prim=tot;
	rep(i,0,n-1) {
		soma+=a[i]; prim-=a[i];
		ans=min(ans,abs(soma-prim));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		long num = 1000000007;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		
	 		long n = Long.parseLong(st.nextToken());
	 		long a = Long.parseLong(st.nextToken());
	 		long b = Long.parseLong(st.nextToken());
 		long ans = power((long)(2), n, num);
 		long nca = 1;
 		for(long k = n;k>n-a;k--){
 			nca = nca*k;
 			nca = nca%num;
 		}
 		for(long k = 1;k<=a;k++){
 			nca = nca*power(k, num-2, num);
 			nca = nca%num;
 		}
 		
 		long ncb = 1;
 		for(long k = n;k>n-b;k--){
 			ncb = ncb*k;
 			ncb = ncb%num;
 		}
 		for(long k = 1;k<=b;k++){
 			ncb = ncb*power(k, num-2, num);
 			ncb = ncb%num;
 		}
 		
 		ans = ans-nca;
 		ans = (ans%num+num)%num;
 		ans = ans-ncb;
 		ans = (ans%num+num)%num;
	 	out.println(Math.max(0, ans-1));
 		out.close();
 		
 		
 		
 	}
	public static int power(long x, long y, long mod){
		long ans = 1;
		while(y>0){
			if (y%2==1)
				ans = (ans*x)%mod;
			x = (x*x)%mod;
			y/=2;
		}
		return (int)(ans);
	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 26196
#include <iostream>

int main()
{
    int n;
    std::string str;
    std::cin >> n >> str;
    int max = 0;
    for (int i = 0; (i < (n - 1)); ++i) {
        int cnt = 0;
        for (int c = 'a'; (c <= 'z'); ++c) {
            bool xx = false;
            for (int x = 0; (x <= i); ++x) {
                if (str[x] == c) xx = true;
            }
            bool yy = false;
            for (int y = i + 1; (y < n); ++y) {
                if (str[y] == c) yy = true;
            }
            if (xx && yy) ++cnt;
        }
        max = std::max(max, cnt);
    }
    std::cout << max << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans;
int a[1000];
string s, t;

int main() {
    cin >> s;
    cin >> t;
    bool judge = true;
    rep(0, s.length())  {
        if (s[i] != t[i]) judge = false;
    }

    if (judge) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 3644
#include <stdio.h>

char s[11];
char a[11];


int main(void)
{
    int len=0, lena=0;
    scanf("%s", &s);

    while(s[len]) {
        if(s[len]=='B') {
            if(lena>0) a[--lena]=0;
        }
        else {
            a[lena++]=s[len];
        }
        len++;
    }

    printf("%s", a);

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

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

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

  int max = 0;
  for (int i = 0; i < n; ++i) {
    int sum = a[0][i] + a[1][i];
    if (sum > max) max = sum;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>  /* setprecision() */

int main(void){
    /* input */
    int numA = 0;
    int numB = 0;
    std::cin >> numA >> numB;
    
    /* culclate & output */
    std::cout << static_cast<int>(numA / numB) << " "
              << static_cast<int>(numA % numB) << " "
              << std::fixed << std::setprecision(5)
              << static_cast<double>(numA) / numB << std::endl;
    
    return 0;
}

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

int main() {
    int a,b;
    char op;
    cin >> a >> op >> b;
    if(op == '+')
    {
        cout << a+b << endl;
    }
    else
    {
        cout << a-b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
#define mod 1000000007
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define loop(x,y,z) for(int x=y;x<z;x++)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=0;
    if(d>0){
        ll k=min(a,d);
        ans+=k;
        d-=k;
    }
    if(d>0){
        ll k=min(b,d);
        d-=k;
    }
    if(d>0){
        ll k=min(c,d);
        ans-=k;
        d-=k;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3664
def check(List):
    List.sort()
    List.reverse()
    if List[0]**2 == List[1]**2+List[2]**2:
        return "YES"
    else:
        return "NO"

N = input()
    
for i in range(N):
    list = map(int, raw_input().split())
    print check(list)

Measured memory_bytes: 6416
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int mod = 998244353;
const int N = 3010;

ll fpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

ll dp[N];

int main() {
    int n, s; cin >> n >> s;
    int inv2 = fpow(2 ,mod - 2);
    dp[0] = fpow(2, n);
    for (int i = 0; i < n; i++) {
    	int x; cin >> x;
    	for (int j = s; j >= x; j--)
    		dp[j] = (dp[j] + dp[j - x] * inv2) % mod;
    }
    cout << dp[s] << "\n";
}

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

int main() {
	vector<int> menu(5);
	int maxTimeNum = 10;
	int ans = 0;
	for(int i = 0; i < 5; i++)
	{
		cin >> menu.at(i);
		int itiNoKurai = menu.at(i) % 10;
		if (!(itiNoKurai == 0)) {
			maxTimeNum = min(itiNoKurai, maxTimeNum);
		}
	}
	
	for(int i = 0; i < 5; i++)
	{
		if (menu.at(i) % 10 >= 1) {
			ans += ((menu.at(i) / 10) + 1) * 10;
		} else {
			ans += menu.at(i);
		}
	}
	
	ans -= 10 - maxTimeNum;

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long k = sc.nextLong();

		long[] num = new long[100_000 + 1];

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

		int ans = 0;
		long sum = 0;
		for (int i = 0; i < num.length; i++) {
			sum += num[i];
			if (sum >= k) {
				ans = i;
				break;
			}
		}

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


Measured memory_bytes: 65448
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
typedef long long LL;
int main()
{
    LL l,r;
    scanf("%lld%lld",&l,&r);
    if(l==r){puts("1");return 0;}
    int w;
    for(w=59;w>=0;w--) if((l>>w)!=(r>>w)) break;
    for(int i=w-1;i>=0;i--) if((r>>i)&1)
    {
        for(int j=0;j<i;j++) r|=(1LL<<j);
        break;
    }
    LL l2=l|(1LL<<w),r2=l|((1LL<<(w+1))-1);
    if(l2>r)printf("%lld",r-l+1+r2-l2+1);
    else printf("%lld",r2-l+1);
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc100/tasks/abc100_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

// 二乗法によるべき乗
int ipow(int base, int exp) {
    int result = 1;
    while (exp) {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        base *= base;
    }

    return result;
}
int main(void) {
    int a, b;
    cin >> a >> b;
    if (b >= 100)
        b++;
    cout << ipow(100, a) * b << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N;
ll ans;

void solve() {
    cin >> N;
    vector<int> a(N);
    for (auto& i : a) cin >> i;
    for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += a[i] * a[j];	
		}
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll testCases = 1; // cin >> testCases;
    while (testCases--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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

int main(){
	int N,BA,BX,XA,ans;
	cin >> N;
	BA = 0;
	BX = 0;
	XA = 0;
	ans = 0;
	vector <string> str(N);
	for(int i=0;i<N;i++){
		cin >> str[i];
	}
	for(int i=0;i<N;i++){
		for (int j=0;j<str[i].size()-1;j++){
			if (str[i][j] == 'A' && str[i][j+1] == 'B'){
				ans++;
			}
		}
		if(*(str[i].begin()) == 'B' && *(str[i].end()-1) == 'A'){
			BA++;
		}
		else if(*(str[i].end()-1) == 'A' && *(str[i].begin()) != 'B'){
			XA++;
		}
		else if(*(str[i].begin()) == 'B' && *(str[i].end()-1) != 'A'){
			BX++;
		}
	}
	
	if(BA == 0 && XA!=0 && BX !=0){
		ans += min(XA,BX);
	}
	else if(BX == 0 && XA!=0 && BA!=0){
		ans += BA;
	}
	else if(XA == 0 && BX!=0 && BA!=0){
		ans += BA;
	}
	else if(XA == 0 && BX == 0 && BA!=0){
		ans += BA-1;
	}
	else{
		ans += min(XA,BX)-1;
		ans += BA+1;
	}

	cout << ans;
	cin >> N;
}

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

typedef long long lli;
const int MAX_S = 100001;
const int M = 100000007;

int f1[MAX_S];
int f2[MAX_S];
int g1[MAX_S];
int g2[MAX_S];

void init() {
  for(int i=1,p=1; i <= 5; ++i,p*=2) f1[i] = p;
  for(int i = 6; i < MAX_S; ++i) {
    f1[i] = (f1[i-1] + f1[i-2] + f1[i-3] + f1[i-4] + f1[i-5]) % M;
  }
  for(int i=1,p=1; i <= 3; ++i,p*=2) f2[i] = p;
  for(int i = 4; i < MAX_S; ++i) {
    f2[i] = (f2[i-1] + f2[i-2] + f2[i-3]) % M;
  }
  for(int i = 1; i < MAX_S; ++i) {
    g1[i] = f1[i];
    g2[i] = f2[i];
    if(i > 3) g2[i] = (g2[i] + g2[i-3]) % M;
    if(i > 5) g1[i] = (g1[i] + g1[i-5]) % M;
  }
}

int main() {
  init();
  string line;
  while(getline(cin, line) && line != "#") {
    int cnt = 1;
    int ans = 1;
    for(int i = 0; i < line.size(); ++i) {
      if(i+1 == line.size() || line[i] != line[i+1]) {
	if(line[i] == '8' || line[i] == '0') {
	  ans = (lli)ans*g2[cnt]%M;
	} else {
	  ans = (lli)ans*g1[cnt]%M;
	}
	cnt = 1;
      } else {
	++cnt;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2704
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)
#define mp make_pair

class UnionFind{
public:
    V par,rank;// parent,rank
    UnionFind(int n);
    int Find(int x);
    void Unite(int x,int y);
    bool Same(int x,int y);
};
UnionFind::UnionFind(int n){
    par.resize(n);rank.resize(n);
    REP(i,n){par[i]=i;rank[i]=0;}
}
int UnionFind::Find(int x){
    
    return (par[x]==x?x:Find(par[x]));
}
void UnionFind::Unite(int x,int y){
    x=Find(x);y=Find(y);//parent
    
    if(x==y)return;//end
    if(rank[x]<rank[y])par[x]=y;
    else{
        par[y]=x;
        if(rank[x]==rank[y])rank[x]++;
    }
}
bool UnionFind::Same(int x,int y){
    return (Find(x)==Find(y));
}

int main(){

    CIN(n,m);V k(n);vector<V> l(n);
    REP(i,n){
        cin>>k[i];
        l[i].resize(k[i]);
        REP(j,k[i]){CIN(t);l[i][j]=t-1;}
    }
    vector<V> vec(m);
    REP(i,n){
        FOREACH(x,l[i]){
            vec[x].pb(i);
        }
    }
    UnionFind union_(n);
    REP(i,m){
        int gen=-1;
        REP(j,vec[i].size()){
            if(j==0)gen=vec[i][j];
            else union_.Unite(vec[i][j],gen);
        }
    }
    bool flag=true;
    int ttt=union_.par[0];
    FOREACH(tt,union_.par)if(!union_.Same(ttt,tt)){flag=false;break;}
    YES(flag);
    

    return 0;
}


Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(abs(a - b) % 2 == 0)
  {
    cout << abs(a - b) / 2 + min(a, b);
  }
  else
  {
    cout << "IMPOSSIBLE";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

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

    int ans=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i])ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3772
N,D = list(map(int,input().split()))
ans = 0
s = 0
L = []
for i in range(N):
  A = list(map(int,input().split()))
  L.append(A)
#print(L)
#print(L[0],L[0][0])
#print(L[0][0],L[1][0],L[0][1],L[1][1])
for j in range(N):
  #print("j="+str(j))
  for k in range(j+1,N):
    s = 0
    #print("k="+str(k))
    for l in range(D):
      #print("l="+str(l))
      dif = abs(L[j][l]-L[k][l])
      dif2 = dif**2
      #print(dif2)
      s = s + dif2
      #print("s="+str(s))
    s2 = s**(1/2)
    #print("s2="+str(s2))
    if float.is_integer(s2) == True:
      ans += 1
        
print(ans)

Measured memory_bytes: 3188
import sys

def bb097():
    x = int(input())

    if x <= 3:
        print(1)
        sys.exit()

    # 事前にべき乗数DBを作っておく・・
    s = set()
    for i in range(2,31+1): # sqrt(1000) = 31.6...
        r = i*i
        while r <= 1000:
            s.add(r)
            r *= i
    t = list(s)
    t.sort()
    t.reverse()

    for i in t:
        if i <= x:
            print(i)
            sys.exit()

bb097()


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

int main(){
  long int n,train=1;
  long int div = pow(10,9)+7;
  cin >> n;
  for(int i=1;i<=n;i++){
//    int tmp = train%div;    
//    train = tmp*i;
//    if(i==100) cout << train << endl;
    train *= i;
    train %= div;
  }
  cout << train << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int a=0,b=0,c=0,d,i;
    for(i=0;i<10;i++){
        scanf("%d",&d);
        if(d>c){
            c=d;
            if(d>b){
                c=b;
                b=d;
                if(d>a){
                     b=a;
                     a=d;
                }
            }
        }
    }
    printf("%d\n%d\n%d\n",a,b,c);
return 0;
}

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;

	bool ans = true;
	if(N % 2 == 0) {
		rep(i, N / 2) {
			if(S[i] != S[i + N / 2])
				ans = false;
		}
	} else {
		ans = false;
	}

	if(ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks
//A
#include <bits/stdc++.h>
using namespace std;

const long long INF = 1LL << 60;
int N;
long long h[100010];
long long dp[100010];

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

int main(){
    const long long INF = 1LL << 60;

    cin >> N;
    for(int i = 0;i<N;i++) {cin >> h[i]; dp[i] = INF;}
    dp[0] = 0;
    for(int i = 0;i<N;i++){
        chmin(dp[i],dp[i-1] + abs(h[i] - h[i-1]));
        if ( i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABiscuitGenerator {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int t = in.nextInt();
            out.println(t / a * b);
        }

    }
}



Measured memory_bytes: 23508
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

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

  ll r1=0, r2=0;
  ll s1=0, s2=0;
  rep(i, n) {
    s1 += a[i];
    if (i%2==0&&s1<=0) { r1 += abs(s1)+1; s1 = 1; }
    else if (i%2==1&&s1>=0) { r1 += abs(s1)+1; s1 = -1; }
  }
  rep(i, n) {
    s2 += a[i];
    if (i%2==1&&s2<=0) { r2 += abs(s2)+1; s2 = 1; }
    else if (i%2==0&&s2>=0) { r2 += abs(s2)+1; s2 = -1; }
  }

  ll result = min(r1, r2);
  cout << result << endl;
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int c[n], s[n], f[n];
	for(int i = 0; i < n-1; i++){
		cin >> c[i] >> s[i] >> f[i];
	}

	int currentPosition;
	int currentTime;
	for(int i = 0; i < n; i++){
		currentTime = 0;
		currentPosition = i;
		while(currentPosition < n-1){
			if(currentTime < s[currentPosition]){
				currentTime = s[currentPosition];
			}
			if(currentTime % f[currentPosition] != 0){
				currentTime += (f[currentPosition] - currentTime % f[currentPosition]);
			}
			currentTime += c[currentPosition];
			currentPosition++;
		}
		cout << currentTime << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define irep(i,a,b) for(int i=int(a);i>=int(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/**
void comb(vector<vector <ll> > &v) {
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

int main() {
	string s;
	cin>>s;
	ll p0=0;
	ll p1=0;
	rep(i,0,s.size())  {
		if(s[i]=='0') p0++;
		else p1++;
	}
	cout<<2*min(p0,p1);

}

Measured memory_bytes: 1020
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

struct d{
        ll a;
        ll b;
    };
    bool asc( const d& left, const d& right ) {
     return left.a < right.a;
    }

int main() {
    
    
    ll n,m;
    d dd[100010];
    std::cin >> n>>m;
    for (int i = 0; i < n; i++) {
        std::cin >> dd[i].a>>dd[i].b;
    }
    sort(dd,dd+n,asc);
    ll result = 0;
    ll now_count = m;
    for (int i = 0; i < n; i++) {
        ll kau = min(dd[i].b,now_count);
        result += kau*dd[i].a;
        now_count -= kau;
        if(now_count == 0){
            break;
        }
    }
    std::cout << result << std::endl;
    
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long tot,k,a[200100],le,ri,mi;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	le=1;ri=1e9;
	while(le<ri){
		mi=(le+ri)/2LL;
		tot=0;
		for(int i=1;i<=n;i++) tot+=(a[i]+mi-1)/mi-1;
		if(tot<=k) ri=mi;
		else le=mi+1; 
	}
	cout<<le<<endl;
	return 0;
}


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

  int N; cin >> N;
  map<long long,int> A;
  for(int i = 0;i < N;i++){
    long long a; cin >> a;
    A[a]++;
  }

  long long first_max = 0;
  long long second_max = 0;
  long long max1_s = 0;
  long long max2_s = 0;

  for(auto itr = A.end();;itr--){
    if(itr == A.end())continue;

    if(itr->second >= 2){
      if(first_max == 0)first_max = itr->first;
      else if(second_max == 0){
        second_max = itr->first;
        max2_s = first_max * second_max;
      }

      if(max1_s == 0 && itr->second >= 4)max1_s = itr->first * itr->first;
    }

    if(itr == A.begin())break;
  }


  cout << max(max1_s,max2_s) << endl;



  return 0;
}


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

using namespace std;

bool keymap[26] = {
	0, 0, 0, 0, 0, 0, 0,
	1, 1, 1, 1, 1, 1, 1,
	1, 1, 0, 0, 0, 0, 1,
	0, 0, 0, 1, 0
};
int main(){
	for(string s; cin >> s, s != "#";){
		int res = 0;
		for(int i = 0; i < s.size() - 1; i++){
			if(keymap[s[i] - 'a'] != keymap[s[i + 1] - 'a']) res++;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define max2(a,b) ((a)>(b)?(a):(b))   
#define min2(a,b) ((a)<(b)?(a):(b)) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef pair<ll,ll>     pll;
typedef pair<int,int>   pii;
typedef vector<ll>      vll;
typedef vector<int>      vi;
typedef vector< pll >  vpll;
typedef vector< pii >  vpii;
typedef set<ll>         sll;
typedef set<int>         si;
typedef set< pll >     spll;
typedef set< pii >     spii;
clock_t clk=clock();       

ll i,j,k;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
// #define cerr if(0)cerr

void solve()
{
	char a,b,c,d; cin>>a>>b>>c>>d;
	bool pos;
	if(a==b && c==d && a!=c) pos=1;
	else if(a==c && b==d && a!=b) pos=1;
	else if(a==d && b==c && a!=b) pos=1;
	else pos=0;
   
   if(pos) cout<<"Yes\n";
   else cout<<"No\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    
    if(a==b && a==c && b==c){
      System.out.println(1);
    }
    else if(a==c && c!=b && a!=b) {
      System.out.println(2);
    }else if(b==c && c!=a && a!=b){
      System.out.println(2);
    }else if(a==b && a!=c && b!=c){
      System.out.println(2);
    }else if(a!=b && a!=c && b!=c){
      System.out.println(3); 
    }
  }
}

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

int main(){
    int N, K; scanf("%d%d",&N,&K);
    if(K==0) return !printf("%lld\n", 1LL*N*N);
    long long ans = 0;
    for(int b=K+1;b<=N;b++){
        // a%b>=K
        int x = (N+1)/b, y = (N+1)%b;
        ans += 1LL*x*(b-K);
        if(y>=K+1) ans += y-K;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for i in range(h)]
cnt = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            cnt += 1
if cnt == h + w - 1:
    print("Possible")
else:
    print("Impossible")


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 1

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
inline long long digitsum(long long v){long long d=0;while(v){d+=v%10;v/=10;}return d;};
//}

int n,ans;
map<int,int> a;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int dis;
		cin>>dis;
		if(a.count(dis)==0){
			a.insert(mp(dis,1));
		}else{
			a[dis]++;
		}
	}
	for(auto ite=a.begin();ite!=a.end();ite++){
		ans+=(ite->second)%2;
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 4992
r = gets.split("")
 k = (r[0].to_s+r[1].to_s).to_i
 t = (r[2].to_s+r[3].to_s).to_i
 kk = 0 < k && k <=12
 tt = 0 < t && t <=12
 
 if tt && kk
     puts "AMBIGUOUS"
 elsif tt 
    puts "YYMM"
 elsif kk
    puts "MMYY"
else
    puts "NA"
end

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

int main(){
  string S;
  cin>>S;
  if(S.at(0)=='A'&&S.at(1)=='A'&&S.at(2)=='A'){
    cout<<"No"<<endl;
  }
  else if(S.at(0)=='B'&&S.at(1)=='B'&&S.at(2)=='B'){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  int n;
  cin >> n;
  vector<int> s(1 << n);
  for (int i = 0; i < (1 << n); i++) cin >> s[i];
  sort(s.rbegin(), s.rend());
  if (s[0] == s[1]) {
    cout << "No" << endl;
    return 0;
  }
  multiset<int> st;
  for (int i = 1; i < (1 << n); i++) st.insert(s[i]);
  multiset<int> cur = {s[0]};
  for (int i = 0; i < n; i++) {
    vector<int> tmp;
    for (auto v : cur) {
      auto itr = st.lower_bound(v);
      if (itr == st.begin()) {
        cout << "No" << endl;
        return 0;
      }
      itr--;
      tmp.push_back(*itr);
      st.erase(itr);
    }
    //cout << tmp.size() << endl;
    for (auto v : tmp) cur.insert(v);
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 14080
import math
from enum import Enum, auto

class TwoCircle(Enum):
    DISTANT = auto()
    CIRCUMCSCRIBING = auto()
    INTERSECTING = auto()
    INSCRIBING = auto()
    CONTAINING = auto()

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def distance(self, pnt):
        return math.sqrt((self.x - pnt.x)**2 + (self.y - pnt.y)**2)

class Circle():
    def __init__(self, x, y, r):
        self.c = Point(x, y)
        self.r = r

    def is_intersected(self, cir):
        d = self.c.distance(cir.c)
        if d > self.r + cir.r:
            return TwoCircle.DISTANT
        elif d == self.r + cir.r:
            return TwoCircle.CIRCUMCSCRIBING
        elif d == abs(self.r - cir.r):
            return TwoCircle.INSCRIBING
        elif d < abs(self.r - cir.r):
            return TwoCircle.CONTAINING
        else:
            return TwoCircle.INTERSECTING

x1, y1, r1 = list(map(int, input().split(' ')))
x2, y2, r2 = list(map(int, input().split(' ')))
cir1 = Circle(x1, y1, r1)
cir2 = Circle(x2, y2, r2)

judged = cir1.is_intersected(cir2)
if judged == TwoCircle.DISTANT: print(4)
elif judged == TwoCircle.CIRCUMCSCRIBING: print(3)
elif judged == TwoCircle.INTERSECTING: print(2)
elif judged == TwoCircle.INSCRIBING: print(1)
elif judged == TwoCircle.CONTAINING: print(0)


Measured memory_bytes: 6384
n = int(input())
a = list(map(int,input().split()))
n1 = 0
n2 = 0
n4 = 0
for i in a:
    if i%2 != 0:
        n1 += 1
    elif i%4 == 0:
        n4 += 1
    else:
        n2 += 1
        
if n2 == 0:
    if n1 <= n4+1:
        ans = 'Yes'
    else:
        ans = 'No'
else:
    if n1 <= n4:
        ans = 'Yes'
    else:
        ans = 'No'

print(ans)

Measured memory_bytes: 15020
from sys import stdin


def main():
    readline = stdin.readline
    readline()
    *A, = map(int, readline().split())
    *B, = map(int, readline().split())
    B.append(0)
    ans = 0
    pre = 0
    for a, b in zip(A, B):
        brave = pre + b
        if brave < a:
            ans += brave
            pre = 0
        elif a < pre:
            ans += a
            pre = b
        else:
            ans += a
            pre = brave - a
    if A[-1] < pre:
        ans += A[-1]
    else:
        ans += pre
    print(ans)
    return


main()


Measured memory_bytes: 19376