akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		char s[]=(nextLine()).toCharArray();
		for(int i=0;i<s.length;i++)
			if(s[i]=='?')
				s[i]='D';
		for(int i=0;i<s.length;i++)
			out.print(s[i]);
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 36888
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
const char bn = '\n';
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T,typename S,typename U>
ostream& operator<<(ostream& os, tuple<T,S,U> const& P){
    os << "(";
    os << get<0>(P);
    os << ", ";
    os << get<1>(P);
    os << ", ";
    os << get<2>(P);
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
    for(auto e:M){
        os<<e;
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string S,T; int Q;
    cin >> S >> T >> Q;
    vector<pair<int,int>> cumsumS = {mp(0,0)}, cumsumT = {mp(0,0)};
    
    REP(i,S.size()){
        auto now = cumsumS.back();
        if(S[i] == 'A') now.first++;
        else now.second++;
        cumsumS.emplace_back(now);
    }

    REP(i,T.size()){
        auto now = cumsumT.back();
        if(T[i] == 'A') now.first++;
        else now.second++;
        cumsumT.emplace_back(now);
    }

    REP(_,Q){
        int a,b,c,d; cin >> a >> b >> c >> d;
        int A = ((cumsumS[b].first - cumsumS[--a].first) - (cumsumT[d].first - cumsumT[--c].first)); //S[a:b]のAの個数 と T[c:d]のAの個数の差
        int B = ((cumsumS[b].second - cumsumS[a].second) - (cumsumT[d].second - cumsumT[c].second)); //S[a:b]のBの個数 と T[c:d]のBの個数の差

        (A%=3)+=3;
        B += A*2;
        if(B%3==0) cout << "YES" << bn;
        else cout << "NO" << bn;

    }



}

Measured memory_bytes: 3012
input1 = input().split(" ")
input2 = input().split(" ")
input3 = input()
if input1[0] == input3 :
	print(str(int(input2[0])-1)+" "+input2[1])
elif input1[1] == input3:
    print(input2[0]+" "+str(int(input2[1])-1))

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

int main() {
	int p,q,r;
  	cin>>p>>q>>r;
  
  int teki=max(p,max(q,r));
  
  	cout<<p+q+r-teki<<endl;
}

Measured memory_bytes: 256
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 999999999999971;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int x;
    cin >> x;

    Int ans = 0;
    for (Int i = 1;; i++) {
        if (360 * i % x == 0) {
            ans = 360 * i / x;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto x : V) os << x << ", ";
  return os << "]";
}

//--------------------------------------------------//

int main() {
  use_cio();
  string s;
  cin >> s;
  sort(all(s));
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
    cout << "Yes\n";
  else
    cout << "No\n";
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,a[105],ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]),ans+=a[i];
    double k=ans*1.0/n;
    int pos=0;
    double s=abs(k-a[0]);
    for(int i=1;i<n;i++)
    {
        double kk=abs(a[i]-k);
        if(kk<s)
        {
            pos=i;
            s=kk;
        }
    }
    printf("%d\n",pos);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  string S;
  cin >> N >> S;

  set<string> first, second, third;
  for (auto c: S) {
    for (auto sec: second) third.insert(sec + c);
    for (auto fir: first) second.insert(fir+ c);
    string tmp;
    tmp += c;
    first.insert(tmp);
  }

  cout << third.size() << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
//https://blog.csdn.net/m0_46209312/article/details/105118253整理
//自己的线段树板子有问题 
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+10;

int n,q;
char s[maxn];
int pos;//更改的位置和字符 
char ch;
int x,y;
int tree[maxn<<2];

void build(int node,int l,int r){
	if(l==r){
		tree[node]=1<<(s[l]-'a');
		return ;
	}
	int mid=(l+r)>>1;
	build(node<<1,l,mid);
	build(node<<1|1,mid+1,r);
	tree[node]=tree[node<<1]|tree[node<<1|1];
}

void change(int node,int l,int r,int pos){
	if(l==r&&l==pos){
		tree[node]=1<<(ch-'a');
		return ;
	}
	int mid=(l+r)>>1;
	if(mid>=pos)change(node<<1,l,mid,pos);
	else change(node<<1|1,mid+1,r,pos);
	tree[node]=tree[node<<1]|tree[node<<1|1];
}

int query(int node,int L,int R,int l,int r){
	if(L<=l&&R>=r){
		return tree[node];
	}
	int mid=(l+r)/2,ans=0;
	if(mid>=L)ans=ans|query(node<<1,L,R,l,mid);
	if(mid<R)ans=ans|query(node<<1|1,L,R,mid+1,r);
	return ans;
}

int main()
{
	cin>>n>>s+1>>q;
	build(1,1,n);//从1开始建立1-n树 
	int opt;
	while(q--){
		cin>>opt;
		if(opt==1){
			cin>>pos>>ch;
			if(s[pos]!=ch){
				change(1,1,n,pos);//更改以1位根节点的1-n区间的pos位置
				s[pos]=ch;
			}
		}
		else{
			cin>>x>>y;
			cout<<__builtin_popcount(query(1,x,y,1,n))<<endl;//计算以1为根节点1-n区间内的x-y 的数量 
		}
	}
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, ll>> x(m);
    vector<string> xx(m);
    for (int i = 0; i < m; i++)
    {
        cin >> x.at(i).first >> x.at(i).second;
        x.at(i).second=x.at(i).second*1000000+i;
    }
    sort(x.begin(), x.end());
    string s;
    string ans;
    int memo;
    int ccc = 1;
    for (int i = 0; i < m; i++)
    {
        ans = "";
        s = to_string(x.at(i).first);
        memo = s.size();
        for (int i = 0; i < 6 - s.size(); i++)
        {
            ans += "0";
        }
        ans += s;
        if (i == 0)
        {
            ans += "000001";
        }
        else
        {
            if (x.at(i).first == x.at(i - 1).first)
            {
                ccc++;
                s = to_string(ccc);
                memo = s.size();
                for (int i = 0; i < 6 - s.size(); i++)
                {
                    ans += "0";
                }
                ans += s;
                //cout<<"k";
            }
            else
            {
                ccc = 1;
                ans += "000001";
                
            }
        }
        xx.at(x.at(i).second%1000000)=ans;
    }
    for(int i=0;i<m;i++){
        cout<<xx.at(i)<<endl;
    }
}


Measured memory_bytes: 10112
D = int(input())
c = list(map(int, input().split()))
s_matrix = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]
last = [0] * 26
satis = 0

for i in range(D):
    test = t[i] - 1
    satis += s_matrix[i][test]
    last[test] = i + 1
    for j in range(26):
        satis -= c[j] * (i+1 - last[j])
    print(satis)


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


int main(){
  int n;
  cin >> n;
  vector<int> ans(n+1,0);
  for(int x=1;x*x<=n;++x){
    for(int y=1;y*y<=n;++y){
      for(int z=1;z*z<=n;++z){
        int tmp=x*x+y*y+z*z+x*y+z*y+x*z;
        if(tmp>n)continue;
        if(x==y && y==z && z==x){
          ans[tmp]=ans[tmp]+1;
        }else if(x!=y && x!=z && z!=y){
          ans[tmp]=ans[tmp]+1;
        }else{
          ans[tmp]=ans[tmp]+1;
        }
      }
    }
  }
  for(int i=1;i<=n;++i){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3568
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
#print(c)
all_comb = 0

for i in c.values():
    all_comb += i * (i-1) // 2

for a in A:
    print(all_comb - c[a] + 1)



Measured memory_bytes: 87756
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> l(n + 1), r(n + 1);
  for (int i = 0; i < n; ++i) {
    l[i + 1] = __gcd(l[i], a[i]);
  }
  for (int i = n - 1; i >= 0; --i) {
    r[i] = __gcd(r[i + 1], a[i]);
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    res = max(res, __gcd(l[i], r[i + 1]));
  }
  cout << res << '\n';
}

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

typedef long long ll;

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

    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    for(int x=sx;x<tx;x++) ans.push_back('R');
    for(int y=sy;y<ty;y++) ans.push_back('U');
    for(int x=sx;x<tx;x++) ans.push_back('L');
    for(int y=sy;y<ty;y++) ans.push_back('D');
    ans.push_back('D');
    for(int x=sx;x<tx+1;x++) ans.push_back('R');
    for(int y=sy;y<ty+1;y++) ans.push_back('U');
    ans.push_back('L');
    ans.push_back('U');
    for(int x=sx;x<tx+1;x++) ans.push_back('L');
    for(int y=sy;y<ty+1;y++) ans.push_back('D');
    ans.push_back('R');
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		char[] inputs = line.toCharArray();
		int ans = inputs.length;

		int cnt = 0;
		for(int i = 0; i < inputs.length; i++) {
			if(i%2 == 0 && inputs[i] == '1')cnt++;
			if(i%2 == 1 && inputs[i] == '0')cnt++;
		}
		ans = ans < cnt ? ans : cnt;
		
		cnt = 0;
		for(int i = 0; i < inputs.length; i++) {
			if(i%2 == 0 && inputs[i] == '0')cnt++;
			if(i%2 == 1 && inputs[i] == '1')cnt++;
		}
		ans = ans < cnt ? ans : cnt;

		System.out.println(ans);
	}
}




Measured memory_bytes: 28108
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <iomanip>


int main()
{
	char a, b;

	std::cin >> a >> b;

	if (a == b) {
		std::cout << 'H' << std::endl;
	} else {
		std::cout << 'D' << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, q = (int(i) for i in input().split())  
s = input()
t = [0] * (n+1)

for i in range(n):
  if s[i:i+2] == "AC":
    t[i+1] = t[i] + 1
  else:
    t[i+1] = t[i]
    
for i in range(q):
  l, r = (int(i) for i in input().split())
  print(t[r-1] - t[l-1])



Measured memory_bytes: 6060
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
 
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const int MOD = 1000000007;
const ll INF = 1e18;
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N, K;
	cin >> N >>K ;
	vl H(N);
	F0R(i,N) cin >> H[i];
	sort(all(H));
	ll sum =0;
	if  (K<=N)
	{
	F0R(i,N-K) sum+=H[i];
	cout<<sum<<endl;
	}
	else cout<<0<<endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((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())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    string s;
    cin >> s;

    VI c(26,0);
    REP(i,s.length()){
        c[s[i]-'a']++;
    }

    REP(i,26){
        if(c[i]%2!=0){
            cout << "No" << ENDL;
            return 0;
        }
    }

    cout << "Yes" << ENDL;
    
    return 0;
}

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

bool PrimeCheck(int a) {
	if (a == 1) return false;
	if (a == 2) return true;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	int X;
	cin >> X;
	while (!PrimeCheck(X)) {
		X++;
	}
	cout << X << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	long long int i,j,a=0,b,c[100],d[1001][21];
	scanf("%lld",&b);
	for(i=0;i<b;i++){
		scanf("%lld",&c[i]);
	}

	for(i=0;i<21;i++){
		for(j=0;j<=1000;j++){
			d[j][i]=0;
		}
	}
	d[0][c[0]]=1;
	for(i=0;i<b-2;i++){
		for(j=0;j<=20;j++){
			if(j+c[i+1]<=20){
				d[i+1][j+c[i+1]]=d[i][j]+d[i+1][j+c[i+1]];
			}
			if(j-c[i+1]>=0){
				d[i+1][j-c[i+1]]=d[i][j]+d[i+1][j-c[i+1]];
			}
		}
	}
	printf("%lld\n",d[b-2][c[b-1]]);
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define pri(x) (printf("%d", x))
#define prll(x) (printf("%lld", x))
#define sci(x) (scanf("%d", &x))
#define scll(x) (scanf("%lld", &x))
#define endl printf("\n");
typedef long long ll;

int
main(int argc, char *argv[])
{
int x[10][10];
int n, d;
sci(n); sci(d);
for(int i = 0; i < n; i++){
for(int j = 0; j < d; j++){
sci(x[i][j]);
}
}

int D;
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++){
D = 0;
for(int k = 0; k < d; k++){
D += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
}
if((int)sqrt((double)D) * (int)sqrt((double)D) == D) ans++;
}
}

pri(ans);
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

/*

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}

int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}

int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	return B;
}

vector<ll> prime_factor(int64_t n) {
	//map< ll, ll > ret;
	vector<ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			//ret[i]++;
			ret.push_back(i);
			n /= i;
		}
	}
	if (n != 1)ret.push_back(n);// ret[n] = 1;
	return ret;
}

const int MAX = 1000000;
const int MOD = 1000000007;
ll 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;
	}
}
ll 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;
}

struct edge {
	ll to;
	ll cost;
};

*/

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int A, B;
	cin >> A >> B;
	for (int i = 0; i <= 10000; i++) {
		if (floor((double)i * 0.08) == A &&
			floor((double)i * 0.10) == B) {
			cout << i << endl;
			goto ProgramEndPointLabel;
		}
	}
	cout << -1 << endl;

ProgramEndPointLabel:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG


	return 0;
}




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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> st;
  for (int i = 0; i < s.size(); i++) {
    if (!st.empty() && st.top() == '(' && s[i] == ')') {
      st.pop();
      continue;
    }
    st.push(s[i]);
  }

  int r = 0, l = 0;
  while (!st.empty()) {
    if (st.top() == '(')
      r++;
    else
      l++;
    st.pop();
  }

  for (int i = 0; i < l; i++) cout << "(";
  cout << s;
  for (int i = 0; i < r; i++) cout << ")";
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct SegmentTree {
  using T = int;
  static T op(const T& x, const T& y) { return min(x, y); }
  static constexpr T e() { return 2e9; }
  using U = int;
  static void ap(const U& f, T& x) { x = min(x, f); }
  static void cp(const U& g, U& f) { f = min(f, g); }
  static constexpr U id() { return 2e9; }

  const int n;
  V<T> t;
  V<U> u;
  SegmentTree(int n) : n(n), t(2 * n, e()), u(n, id()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
  void push() { for (int i = 1; i < n; ++i) push(i); }
  void apply(const U& f, int i) {
    ap(f, t[i]);
    if (i < n) cp(f, u[i]);
  }
  void push(int i) {
    if (u[i] == id()) return;
    apply(u[i], 2 * i);
    apply(u[i], 2 * i + 1);
    u[i] = id();
  }
  void push(int l, int r) {
    for (int hl = __lg(l + n), hr = __lg(r - 1 + n); hr > 0; --hl, --hr) {
      int al = l + n >> hl, ar = r - 1 + n >> hr;
      if (al < n) push(al);
      if (ar != al) push(ar);
    }
  }
  T acc(int l, int r) {
    push(l, r);
    T resl = e(), resr = e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = op(resl, t[l++]);
      if (r & 1) resr = op(t[--r], resr);
    }
    return op(resl, resr);
  }
  T get(int i) { return acc(i, i + 1); }
  void act(int l, int r, const U& f) {
    push(l, r);
    for (int i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) apply(f, i++);
      if (j & 1) apply(f, --j);
    }
    l = l + n >> __builtin_ctz(l + n);
    while (l >>= 1) t[l] = op(t[2 * l], t[2 * l + 1]);
    r = r + n >> __builtin_ctz(r + n);
    while (r >>= 1) t[r] = op(t[2 * r], t[2 * r + 1]);
  }
  void set(int i, const T& x) {
    push(i, i + 1);
    t[i += n] = x;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  V<> s(n), t(n), x(n); for (int i = 0; i < n; ++i) cin >> s[i] >> t[i] >> x[i], s[i] -= x[i], t[i] -= x[i];
  V<> d(q); for (auto&& e : d) cin >> e;
  auto xs = s;
  xs.insert(end(xs), begin(t), end(t));
  xs.insert(end(xs), begin(d), end(d));
  sort(begin(xs), end(xs));
  xs.erase(unique(begin(xs), end(xs)), end(xs));
  auto zip = [&](int e) -> int { return lower_bound(begin(xs), end(xs), e) - begin(xs); };
  int m = xs.size();
  SegmentTree st(m + 1);
  for (int i = 0; i < n; ++i) {
    st.act(zip(s[i]), zip(t[i]), x[i]);
  }
  for (int i = 0; i < q; ++i) {
    int res = st.get(zip(d[i]));
    if (res == SegmentTree::e()) res = -1;
    cout << res << '\n';
  }
}

Measured memory_bytes: 13780
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	int N, X[105];
	ll mn = 1e18;

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

	for (int p = 1; p <= 100; p++) {
		ll s = 0;
		for (int i = 0; i < N; i++) {
			s += (X[i] - p) * (X[i] - p);
		}
		mn = min(mn, s);
	}

	cout << mn << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int d = 0;
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

		for (int i = 0; i < n; i++) {
			d = Integer.parseInt(sc.next());
			if (map.containsKey(d)) {
				map.put(d, map.get(d) + 1);
			} else {
				map.put(d, 1);
			}
		}

		int m = sc.nextInt();
		int[] t = new int[m];
		for (int i = 0; i < m; i++) {
			t[i] = Integer.parseInt(sc.next());
		}

		String ans = "YES";
		for (int te : t) {
			if (map.containsKey(te)) {
				if (map.get(te) == 1)
					map.remove(te);
				else
					map.put(te, map.get(te) - 1);
			} else {
				ans = "NO";
				break;
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 99652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
using ll = long long;
ll dp[3001][3001];

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

    int ns = s.size();
    int nt = t.size();

    for (int i=1; i<=ns; i++) {
        for (int j=1; j<=nt; j++) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else {
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
            }
        }
    }

    //cout << dp[ns][nt] << endl;

    int y = ns;
    int x = nt;
    string ans = "";
    while (y > 0 && x > 0) {
        if (s[y-1] == t[x-1]) {
            y--;
            x--;
            ans += s[y];
        }
        else {
            if (dp[y-1][x] > dp[y][x-1]) {
                y--;
            }
            else {
                x--;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 70656
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

int main()
{
    IOS();
 
    ll n,m,k,i,j;
    string s[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string ss;
    cin>>ss;
    f(i,0,7)
    {
    	if(s[i]==ss)
    	{
    		break;
      	}

    }
    f(j,0,7)
    {
    	if(i+j==7)
    		break;
    }

    cout<<j;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	int N, K;
	cin >> N >> K;

	vector<int> sunuke(N, 0);
	for (int i = 0; i < K; i++) {
		int temp_d;
		cin >> temp_d;
		for (int j = 0; j < temp_d; j++) {
			int temp_A;
			cin >> temp_A;
			sunuke[temp_A - 1] = 1;
		}
	}

	//calculation
	int output = 0;
	for (int i = 0; i < N; i++) {
		if (!sunuke[i]) {
			output++;
		}
	}

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef complex<double> cmplx;
const double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = (int)1e+9 + 7;
const double eps = 1e-8;
const int N = 300'000;

int n, m, k;
int a[100];

void solve()
{
    int x;
    cin >> n >> x;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    bool has = false;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= x) {
            ++ans;
            x -= a[i];
        }
        else {
            has = true;
        }
    }
    if (x != 0 && !has)
        --ans;
    cout << ans;
}

void precalc()
{
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    precalc();
    int test = 1;
    //cin >> test;
    for (; test; --test)
        solve();
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){

	string s;
	cin >> s;
	
	for (int i = s.length() - 2; i >= 0; i -= 2) {
		//cout << s.substr(0, i / 2) << endl;
		//cout << s.substr(i / 2, i/2) << endl;
		if (s.substr(0, i/2) == s.substr(i/2, i/2)) {

			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


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

int main() {
  int o0 = 0, o1 = 0, o2 = 0, o3 = 0; // 全三角形, 鋭角, 直角, 鈍角のカウンタ
  while (true) {
    int a, b, c;
    cin >> a >> b >> c;
    // aを最長とする
    if (a < b) {
      int temp = b;
      b = a;
      a = temp;
    }
    if (a < c) {
      int temp = c;
      c = a;
      a = temp;
    }
    if (fabs(b - c) < a && a < b + c) {
      o0++;
      // 余弦定理から判定
      if (a * a > b * b + c * c) {
	o3++;
      } else if (a * a < b * b + c * c) {
	o1++;
      } else {
	o2++;
      }
    } else {
      // 終了
      break;
    }
  }
  cout << o0 << " " << o2 << " " << o1 << " " << o3 << endl;
  return 0;
}


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

typedef long long ll;

int main() {
    int N, b = 0, c = 0;
    cin >> N;
    vector<int> a(N);
    rep(i, N) {
        cin >> a[i];
        if (a[i] % 4 == 0) b++;
        else if (a[i] % 2 == 0) c++;
    }
    if (c == N) cout << "Yes\n";
    else if (c == 0 && b >= N / 2) cout << "Yes\n";
    else if (b * 2 + c >= N) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 640
n = int(input())
a = [list(input()) for i in range(n)]

for i in range(n):
    a[i].sort()

a.sort()

ans = 0
same_n = 0
for i in range(1, n):
    if a[i] != a[i - 1]:
        same_n = 0
    else:
        same_n += 1
    ans += same_n

print(ans)


Measured memory_bytes: 98008
use std::io::{self, BufRead};

fn main() {
	let stdin = io::stdin();
    let mut ns = stdin.lock().split(b' ').map(|r| String::from_utf8(r.unwrap()).unwrap().trim_right().parse().unwrap());
    let n: u32 = ns.next().unwrap();
    let m = ns.next().unwrap();
    let k = ns.next().unwrap();

    // x,yが存在して Nx + My - 2xy = K <=> Yes
    let mut numer = k;
    let mut denom = n;
    for _ in 0..n {
    	// x = (K-My)/(N-2y)
        if numer % denom == 0 && numer / denom <= m {
        	println!("Yes");
            return;
        }
        if denom <= 2 { break; }
        numer -= m;
        denom -= 2;
    }

	// y = N/2
    if denom == 2 && m*n == k {
    	println!("Yes");
        return;
    }

    println!("No");
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
const int N = 505;
int n , m , a , b;
int A[N];
int B[N];
void make(int arr[] , int n , int a){
	int val = (n / a) + 1;
	for(int i = 1 ; i <= n ; ++i){
		if(i % a){
			arr[i] = val;
		}
		else{
			arr[i] = val * (1 - a) - 1;
		}
	}
}
void rip(int arr[] , int n , int a){
	for(int i = 1 ; i <= n ; ++i){
		if(i % a){
			arr[i] = 0;
		}
		else{
			arr[i] = -1;
		}
	}
}
int main(){
	cin >> n >> m >> a >> b;
	if((n % a) == 0 && (m % b) == 0){
		printf("No\n");
		return 0;
	}
	if(n % a){
		make(A , n , a);
		rip(B , m , b);
	}
	else{
		make(B , m , b);
		rip(A , n , a);
	}
	printf("Yes\n");
	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= m ; ++j){
			printf("%d%c" , -A[i] * B[j] , " \n"[j == m]);
		}
	}
}

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

int N,K;

int used[100][100];
  
int main(){
  cin>>N>>K;
  if( N*(N-1)/2 < K*(N-1) ){
    cout<<-1<<endl;
    return 0;
  }

  vector<int> a,b;
  for(int i=0;i<N/2;i++){
    a.push_back(0);
    b.push_back(i+1);
  }
  
  for(int i=1;i<N/2;i++){
    a.push_back(N/2);
    b.push_back(N/2+i);
  }
  
  for(int tc=0;tc<K;tc++){
    if(tc)cout<<endl;
    
    if(N%2==1){
      cout<<N<<' '<<tc+1<<endl;
      //      used[N][tc+1]++;
    }
    
    for(int i=0;i<(int)a.size();i++){
      cout<<a[i]+1<<' '<<b[i]+1<<endl;
      //      used[ a[i]+1 ][ b[i]+1 ]++;
      
      a[i]++;
      a[i]%=N/2*2;
      b[i]++;
      b[i]%=N/2*2;
    }

  }
  /*
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      cout<<' ';
      cout<<used[i][j];
    }
    cout<<endl;
  }
  */
  return 0;
}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

class dijkstra{
public:
	int n;
	vvector<pll> edges;
	vector<ll> fast;
	dijkstra(int N):n(N){
		edges.resize(n);
	}

	void add_edge(int from, int to, ll cost){
		edges[from].emplace_back(to, cost);
	}

	void solve(int start){
		priority_queuer<pll> pq;
		fast.assign(n, INFLL);
		pq.emplace(0, 0);
		fast[start] = 0;
		pq.emplace(0, start);
		while(pq.size()){
			pll d = pq.top();
			pq.pop();
			if(d.first!=fast[d.second])continue;
			foreach(i, edges[d.second]){
				ll next_time = d.first + i.second;
				int to = i.first;
				if(fast[to] <= next_time)continue;
				fast[to] = next_time;
				pq.emplace(next_time, to);
			}
		}
	}
};


int main(){
	int n;
	cin >> n;
	dijkstra dij(n);
	rep(i, n){
		int from;
		cin >> from;
		int time;
		cin >> time;
		rep(j, time){
			int to;
			ll cost;
			cin >> to >> cost;
			dij.add_edge(from, to, cost);
		}
	}
	dij.solve(0);
	rep(i, n){
		output(i);
		output(dij.fast[i]);
		outendl();
	}
	return 0;
}



Measured memory_bytes: 11872
#include <iostream>
#include <vector>

const int limit = 1000000;
std::vector<int> q;

int main(){
    q.push_back(2);
    for(int i = 3; i < limit; i += 2){
        bool f = true;
        for(auto it = q.begin(); it != q.end(); it++){
            int p = *it;
            if(i < p*p) break;
            if(i % p == 0){ f = false; break; }
        }
        if(f) q.push_back(i);
    }
    int n;
    while(std::cin >> n){
        int l = 0, r = q.size()-1, c = -1;
        while(l <= r){
            c = (l + r)/2;
            if(q[c] < n){ l = c + 1; continue; }
            if(q[c] > n){ r = c - 1; continue; }
            break;
        }
        if(l > r) c = r;
        std::cout << c + 1 << std::endl;
    }
}

Measured memory_bytes: 1592
#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>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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 T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }


int a[8];
int main() {
    for (int i = 0; i < 8; ++i) cin >> a[i];
    int A = 0, B = 0;
    for (int i = 0; i < 4; ++i) A += a[i], B += a[i+4];
    cout << max(A, B) << endl;
    
    return 0;
}


Measured memory_bytes: 1160
#include <stdio.h>
#define MAX 45
  
int answer(int);
int fib[MAX];
  
int main(){
  int x;
  
  scanf("%d" ,&x);
  printf("%d\n" ,answer(x));
  return 0;
}
  
int answer(int x){
  if(fib[x] > 0){
    return fib[x];
  }
 
  if(x <= 1){
    return 1;
  }
 
  else{
    return fib[x] = answer(x-1) + answer(x-2);
  }
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main(){
	
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(a > 0 && c > 0){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if(a <= 0){
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3624
from itertools import permutations

N,M=map(int,input().split())
E=[[0]*(N+1) for _ in range(N+1)]

for _ in range(M):
    a,b=map(int,input().split())
    E[a][b]=1
    E[b][a]=1

P=permutations([x for x in range(2,N+1)])

K=0
for p in P:
    Q=[1]+list(p)

    F=1
    for k in range(N-1):
        F*=E[Q[k]][Q[k+1]]

    K+=F
print(K)


Measured memory_bytes: 70108
///答え見ました
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  
vector<int>ac(N),wa(N);
  for(int i=0; i<M; i++){
    int p;
    string S;
    cin >> p >> S;
    p--;
    
    if(ac[p]==1) continue;
    if(S == "AC") ac[p]=1;
    else wa[p]++;
  }
  
  int AC=0 ,WA=0;
  
  for(int i=0; i<N; i++){
    AC+=ac[i];
    if(ac[i]==1) WA+=wa[i];
    
  }
  
  cout << AC << " " << WA << endl;
  
}
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S2, T;
  cin >> S2 >> T;
  if (T.size() > S2.size()){
    cout << "UNRESTORABLE";
  } else {
    bool res = false;
    for (int i = S2.size() - T.size(); i >= 0; i--){
      vector<char> T2(S2.size(), '?');
      for (int j = i; j < i + T.size(); j++){
        T2[j] = T[j - i];
      }
      string S;
      for (int j = 0; j < S2.size(); j++){
        if (S2[j] != '?' && T2[j] != '?' && S2[j] != T2[j]){
          break;
        } else if (S2[j] == '?' && T2[j] == '?'){
          S.push_back('a');
        } else if (S2[j] == '?'){
          S.push_back(T2[j]);
        } else {
          S.push_back(S2[j]);
        }
      }
      if (S.size() == S2.size()){
        res = true;
        cout << S;
        break;
      }
    }
    if (!res){
      cout << "UNRESTORABLE";
    }
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();

        int ans = 0;
        int j = 0;
        for (int i = 0; i < N; i++) {
            if (in.i() == i + 1) {
                j++;
            } else if (j > 0) {
                ans += (j + 1) / 2;
                j = 0;
            }
        }
        ans += (j + 1) / 2;

        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 35476
/*
    [Gnana Deepak]
    [August 01, 2020 10:21 PM]
    [G - Longest Path]
    [https://atcoder.jp/contests/dp/tasks/dp_g]
    [2000 ms]
    [1024 MB]
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using ld = long double;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define F first
#define S second
#define orderKey order_of_key
#define findOrder find_by_order
#define s(x) set<x>
#define um(x, y) unordered_map<x, y>
#define m(x, y) map<x, y>
#define p(x, y) pair<x, y>
#define v(x) vector<x>
#define min_heap(t) priority_queue<t, vector<t>, greater<t>>
#define max_heap(t) priority_queue<t>
#define ordered_set(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define eb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define ss(v) stable_sort(all(v))
#define fori(i, a, b) for (int i = a; i <= b; i++)
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define stprs(x) cout << fixed << setprecision(x);
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define bs binary_search
#define deb(x) cout << #x << "=" << x << '\n';
#define scn(v1)        \
    for (auto &x : v1) \
        cin >> x;
#define R(x) reverse(all(x));
#define lb lower_bound
#define ub upper_bound
const char nl = '\n';
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const ld PI = acos(-1);
const int N = 1e5;
const int M = 1e5;
const int imx = LLONG_MAX;
v(int) adj[N + 1];
int vis[N + 1];
int in_degree[N + 1];
int answer = 0;
int dist[N + 1];
void dfs(int i)
{
    vis[i] = 1;
    for (int child : adj[i])
    {
        dist[child] = max(dist[child], dist[i] + 1);
        --in_degree[child];
        if (in_degree[child] == 0)
        {
            dfs(child);
        }
    }
}
void accio_ac(void)
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int u, v;
        cin >> u >> v;
        adj[u].emplace_back(v);
        in_degree[v] += 1;
    }
    fori(i, 1, n) if (vis[i] == 0 and in_degree[i] == 0)
    {
        dfs(i);
    }
    int answer = 0;
    fori(i, 1, n) if (answer < dist[i])
    {
        answer = dist[i];
    }
    cout << answer << endl;
}
int32_t main(void)
{
    fastio;
    int __ = 1;
    // cin >> __;
    while (__--)
    {
        accio_ac();
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string X;
  cin >> X;
  stack<char> st;
  int res = 0;
  for (char s : X) {
    if (s == 'S') {
      st.push(s);
    } else {
      if (!st.empty()) {
        st.pop();
      } else {
        res++;
      }
    }
  }
  cout << res + st.size() << '\n';
  return 0;
}


Measured memory_bytes: 720
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

count = 0
for i in range(n):
    defeated = min(A[i], B[i])
    count += defeated
    A[i] -= defeated
    B[i] -= defeated

    defeated = min(A[i+1], B[i])
    count += defeated
    A[i+1] -= defeated
    B[i] -= defeated

print(count)

Measured memory_bytes: 18624
/*******************************
* BASMILLAHHIR RAHMANNIR RAHIM *
* MD SHAHINUR RAHMAN           *
* DATE: 16/sep/2020            *
* DEPT. OF CSE                 *
* LEADING UNIVERSITY, SYLHET   *
*******************************/
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
#include<stdlib.h>
#include<math.h>
#define shahin std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
const int nax=1000*1007;
const int mod = 1e9 + 7;
 
using namespace std;
char wcz[nax];
 
bool fu(int a, int b){
    return (a>b);
}
int gcd(int x,int y){
    return x?gcd(y%x, x):y;
}
 
void fun(){
   string s;
   cin>> s;
   int len = s.size();
  // cout << len<<endl;
   if(s[len-1]=='s')cout << s << "es";
   else cout << s<<"s";
 
}
int main()
{
    shahin
  /*  int tc,i=1;
    cin >> tc;
    while(tc--)
    {
    //cout << "Case " << i << ": ";
        fun();
    //i++;
    }*/ 
    fun();
   
}

Measured memory_bytes: 3572