akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#define ll long long
using namespace std;

bool judge(vector <int> A,int goal,bool orx);

int main(){
  int N;cin>>N;
  vector <int> A(0);
  A.push_back(-1);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A.push_back(a);
  }
  int ans=0;

  sort(A.begin(),A.end());

  int cnt=0;

  for(int i=1;i<N+1;i++){
    

    if(A[i] != A[i-1] and i!=1){

      ans += A[i-1]<=cnt ? cnt - A[i-1] : cnt;

      cnt = 0;

      if(i==N){
        ans++;
        break;
      }

    }

    cnt++;

    if(i==N){
       ans += A[i]<=cnt ? cnt - A[i] : cnt;

    }

  }

  cout<<ans<<endl;



  return 0;
}
  


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    int ans=1;
    while(ans*2<=N) ans*=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int A = nextInt();
        int B = nextInt();

        System.out.println(A*B);

    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32528
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            int[] arr = new int[10];
            for (int j = 0; j < 10; j++) {
                arr[j] = sc.nextInt();
            }
            Stack<Integer> st1 = new Stack<>(), st2 = new Stack<>();
            String res = solve(arr, 0, st1, st2) ? "YES" : "NO";
            System.out.println(res);
        }
    }

    public static int[][] dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

    public static boolean solve(int[] arr, int cur, Stack<Integer> st1, Stack<Integer> st2) {
        if (cur >= arr.length) return true;
        int num = arr[cur];
        boolean res = false;
        if (st1.empty() || num > st1.peek()) {
            st1.push(num);
            res = solve(arr, cur + 1, st1, st2);
            if (res) return true;
            st1.pop();

        } else if(st2.empty() ||num>st2.peek()){
            st2.push(num);
            res = solve(arr, cur+1, st1,st2);
            if(res) return true;
            st2.pop();
        }
        return false;

    }

}


Measured memory_bytes: 26308
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String[] str = lines[0].split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);
        
           while(a > 0 && c > 0){
               c = c - b;
                if (c <= 0){
                    System.out.println("Yes");
                    break;
                }
               a = a - d;
                if (a <= 0){
                    System.out.println("No");
                    break;
                }
           } 
               
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}

Measured memory_bytes: 27044
#pragma warning(disable:4786)  // VisualC++6.0の警告対策
#include<string>
#include<map>
#include<iostream>
#include<cstdio>

using namespace std;

int main(void){
	map<int,string>ward;

	string in,out,siz,space;
	string::size_type poi=0;
	int x,j,i=0;
	int cnt=0,data=0;
	
	space=' ';
	//mapを使って入力
	while((cin>>in)!=0){
		ward.insert(map<int,string>::value_type(i,in));
		i++;
	}
	poi=ward[i].size();
	siz=ward[i];
	for(j=0;j<i-1;j++){
		if(poi<ward[j].size()){
			poi=ward[j].size();
			siz=ward[j];
		}
		for(x=1;x<i;x++){
			if(ward[j]==ward[x])	cnt++;
		}
		if(data<cnt){
			out=ward[j];
			data=cnt;
		}
		cnt=0;
	}
	
	cout<<out<<space<<siz<<endl;

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s;
int sum[501][501];

int getsum(int t, int b, int l, int r){
  return sum[b][r] - sum[b][l - 1] - sum[t - 1][r] + sum[t - 1][l - 1];
}

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(h, w);
    if(!(h | w))break;
    rep(i, h + 1)rep(j, w + 1)sum[i][j] = 0;

    rep(i, h){
      cin >> s;
      rep(j, w)if(s[j] == '*')sum[i + 1][j + 1] = 1;
    }

    rep(i, h + 1)rep(j, w)sum[i][j + 1] += sum[i][j];
    rep(i, h)rep(j, w + 1)sum[i + 1][j] += sum[i][j];

    int res = 0;
    rep(i, h)rep(j, i + 1){ // sum:h:[j + 1, i + 1]
      int l = 1, r = 1, tmp;
      for(;;){
        if(r > w)break;
        tmp = getsum(j + 1, i + 1, l, r);
        if(tmp != 0){
          l = ++r;
        }else{
          res = max(res, (i - j + 1) * (r - l + 1));
          ++r;
        }
      }
    }

    pri(res);

//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 4096
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    val ans = mutableListOf<Int>()
    while (n != 0) {
        n = if ((n - 1) % -2 == 0) {
            ans.add(1)
            (n - 1) / -2
        } else {
            ans.add(0)
            n / -2
        }
    }
    println(if (ans.isEmpty()) "0" else ans.reversed().joinToString(""))
}


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

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

  int a, ans = 0;
  for(int i = 0;i < n;i++){
    cin >> a;
    if(a % 2 == 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3124
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
n = ip()                                     #入力整数1つ
#h,m= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a.sort()
c = 1
cnum = a[0]
s = []
for i in range(1,n):
    if a[i] != cnum:
        if c > 1:
            s.append(cnum)
        if c > 3:
            s.append(cnum)
        c = 1
        cnum = a[i]
    else:
        c+=1
if c > 1:
    s.append(cnum)
if c > 3:
    s.append(cnum)
s.sort(reverse=True)
if len(s) < 2:
    print(0)
else:
    print(s[0]*s[1])


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

int main()
{
    string str;
    cin >> str;
    str.pop_back();
    if (str.size() % 2 != 0)
        str.pop_back();

    for (;;) {
        int l = str.size();
        if (str.substr(0, l/2) == str.substr(l/2, l/2)) {
            cout << str.size() << endl;
            return 0;
        } else if (str.size() == 0) {
            exit(1);
        } else {
            str.pop_back();
            str.pop_back();
        }
    }
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << S[i][j];
    }
    cout << endl;
    
    for (int j = 0; j < W; j++) {
      cout << S[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
	int m[4]={0},tmp1,tmp2,i,j,k;
	/*input*/
	for(i=1;i<=10;i++){
		scanf("%d",&tmp1);
		j=2;
		while(j>=0 && m[j]<tmp1){
			m[j+1] = m[j];
			j--;
		}
		m[j+1] = tmp1;
	}
	/*output*/
	for(k=0;k<3;k++){
		printf("%d\n",m[k]);
	}
	return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976
#define MAX_N 100010

int main(){
	lint a[3];rep(i,3)cin>>a[i];
	lint *p=max_element(a,a+3);
	lint k;cin>>k;
	rep(i,k)*p*=2;
	cout<<a[0]+a[1]+a[2]<<endl;
}

//sub-EOF


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

int main(){
	int n;
	cin >> n;
	vector<int>data(n);
	for(auto &a:data) cin >> a;
	int count = 0;
	for(int i = 0; i < n; i++){
		int mini = i;
		for(int j = i; j < n; j++){
			if(data[j] < data[mini]) mini = j;
		}
		if(i != mini){
			count++;
			swap(data[i],data[mini]);
		}
	}
	for(int i = 0; i < n; i++){
		if(i!=0) cout << " ";
		cout << data[i];
	}
	cout << endl;
	cout << count << endl;
	return 0;
}	

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

int main(){

int n,b,f,r,v;
int ans[4][3][10]={0};
cin>>n;

for(int i=0;i<n;i++){
    cin>>b>>f>>r>>v;
    ans[b-1][f-1][r-1]+=v;
}

for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
        for(int k=0;k<10;k++){
            cout<<" "<<ans[i][j][k];
        }
        cout<<endl;
    }
    if(i!=3){
        cout<<"####################"<<endl;
    }
}

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> price(n);
	for(int i=0; i<n; i++){
      cin >> price.at(i) ;
    }
  sort(price.begin(),price.end());
  price.at(n-1) /= 2;
    
    int pay=0;
   for(int i=0; i<n ; i++){
     pay += price.at(i);
   }
  cout << pay;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  long n, a, b;
  cin >> n >> a >> b;
  long result;
  if ((b-a) % 2 == 0) {
    result = (b-a)/2;
  } else {
    long dst = b-1 > n-a ? n-a : b-1;
    long tmp = n-b > a-1 ? a-1 : n-b; 
    long dst2 = ((b-a+1)/2) + tmp;
    result = dst2 > dst ? dst : dst2;
  }
  cout << result << endl;
  return 0;
}

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

int main(){
	int n;cin>>n;
	int p[4],t[4];
	for(int i=0;i<4;i++){
		cin>>p[i];
	}
	for(int i=0;i<4;i++){
		cin>>t[i];
	}

	int dp[10205];
	for(int i=0;i<10205;i++){
		dp[i]=100000000;
	}
	dp[0]=0;

	for(int j=0;j<4;j++){
		for(int i=0;i<10005;i++){
			dp[i+t[j]]=min(dp[i+t[j]],dp[i]+p[j]);
			//dp[i+p[j]]=min(dp[i]+t[j],dp[i+p[j]]);
		}

	}
	int ans=1000000;
	for(int i=n;i<=10000;i++){
		ans=min(ans,dp[i]);
	}

	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, H, W);
	bool xr[200] = {}, yr[200] = {};
	vector<vector<char>> m;
	loop(y, H) {
		vector<char> t;
		string s;
		cin >> s;
		loop(x, W) {
			char c = s[x];
			t.push_back(c);
			if (c == '#') {
				xr[x] = true;
				yr[y] = true;
			}
		}
		m.push_back(t);
	}
	loop(y, H) {
		if (yr[y]) {
			loop(x, W) {
				if (xr[x])
					std::cout << m[y][x];
			}
			std::cout << std::endl;
		}
	}
}

Measured memory_bytes: 256
import sys

#+++++
		
def main():
	m1,d1 = map(int, input().split())
	m2,d2 = map(int, input().split())
	ret = 1 if m1!=m2 else 0
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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 int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> xx(n);
  rep(i, n) {
    cin >> x[i];
    xx[i] = x[i];
  }

  sort(ALL(xx));

  ll a = xx[n/2 -1];
  ll b = xx[n/2];

  rep(i, n) {
    if (x[i] <= a) {
      cout << b << endl;
    } else if (x[i] >= b) {
      cout << a << endl;
    }
  }

  return 0;
}


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

#define int long long int

int f(int n) {
  if(n == 1)
  	return 1;
  return 1 + (2 * f(n / 2));
}

signed main() {
  int n;
  cin >> n;
  cout << f(n);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;

//140 D
int main(void) {
	ll n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<ll> hoge = vector<ll>();
	char c = s[0];
	ll ans = 0;
	bool isChange = false;
	rep(i, 1, n) {
		if (c == s[i]) {
			ans++;
		}
		else {
			if (c == 'L')hoge.push_back(0);
			else hoge.push_back(1);
			c = s[i];
		}
	}
	if (c == 'L')hoge.push_back(0);
	else hoge.push_back(1);
	
    isChange = true;
	ll count = 0;
	if (hoge.size() == 2) ans += 1;
	else {
		ll fuga = (ll)(hoge.size() - 1) / (ll)2;
		if (s[0] == s[n - 1]) {
			ans += min(fuga, k) * 2;
		}
		else {
			if (k - fuga >= 1) {
				ans += fuga * 2 + 1;
			}
			else {
				ans += k * 2;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1528
from functools import reduce
from math import ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
a.sort()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

start = 0
a_max = a[-1]
while a_max * (start + 0.5) <= m:
    flag = True
    for i in range(len(a)-1):
        num = (a_max * (start + 0.5) / a[i]) - 0.5
        if num.is_integer():
            continue
        else:
            flag = False
            break
    if flag:
        break
    else:
        start += 1

if a_max * (start + 0.5) > m:
    print(0)
    exit()

ans = 0
base_num = int(a_max * (start + 0.5))

d = reduce(lcm, a)
ans = int(1 + ((m - base_num) // d))
print(ans)




Measured memory_bytes: 65644
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
import bisect
for i in range(n-2):
    for j in range(i+1, n-1):
        ab = l[i]+l[j]
        idx = bisect.bisect_left(l, ab)
        ans += max(0, idx-j-1)
print(ans)

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

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        int[] d = new int[N];
        for (int i = 0; i < N; i++) {
            d[i] = int.Parse(Console.ReadLine());
        }

        int[] newArray = d.Distinct().ToArray();

        Console.WriteLine(newArray.Length);
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<string> S(N);
    for(int i = 0; i <N; i++) {
        cin >> S[i];
    }
    string ans;
    bool isposs = 1;
    for(int i = 0; i < N; i++) {
        if (A + B + C == 2 && i != N-1) {
            if (S[i+1] != S[i]) {
                if (A == 1 && B == 1 && C == 0) {
                    if (S[i] == "AB" && S[i+1] == "BC") {
                        B++;
                        A--;
                        ans += "B";
                        i++;
                    }
                    else if (S[i] == "AB" && S[i+1] == "AC") {
                        A++;
                        B--;
                        ans += "A";
                        i++;
                    }
                }
                else if (A == 1 && B == 0 && C == 1) {
                    if (S[i] == "AC" && S[i+1] == "AB") {
                        A++;
                        C--;
                        ans += "A";
                        i++;
                    }
                    else if (S[i] == "AC" && S[i+1] == "BC") {
                        C++;
                        A--;
                        ans += "C";
                        i++;
                    }
                }
                else if (A == 0 && B == 1 && C == 1) {
                    if (S[i] == "BC" && S[i+1] == "AB") {
                        B++;
                        C--;
                        ans += "B";
                        i++;
                    }
                    else if (S[i] == "BC" && S[i+1] == "AC") {
                        C++;
                        B--;
                        ans += "C";
                        i++;
                    }
                }
            }
        }

        if (S[i] == "AB") {
            if (A >= B) {
                A--;
                B++;
                ans +=  "B";
            }
            else {
                A++;
                B--;
                ans +=  "A";
            }
        }
        else if (S[i] == "AC") {
            if (A >= C) {
                A--;
                C++;
                ans +=  "C";
            }
            else {
                C--;
                A++;
                ans +=  "A";
            }
        }
        else {
            if (B >= C) {
                B--;
                C++;
                ans +=  "C";
            }
            else {
                B++;
                C--;
                ans +=  "B";
            }
        }

        if (A < 0 || B < 0 || C < 0 || isposs == 0) {
            isposs = 0;
            break;
        }
    }
    if (isposs) {
        cout << "Yes\n";
        for(int i = 0; i < (int)ans.length(); i++) {
            cout << ans[i] << "\n";
        }
    }
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 6676
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a, a + n);
    int bef = a[n - 1];
    while (1)
    {
        for (int i = n - 1; i > 0; i--)
        {
            if (a[i - 1] != 0)
                a[i] = a[i] % a[i - 1];
        }
        sort(a, a + n);
        if (bef == a[n - 1])
            break;
        bef = a[n - 1];
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] != 0)
        {
            printf("%d\n", a[i]);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n;
  cin >> n;
  vector<int> a(n + 2, 0);
  for (int i = 1; i <= n; i++)
    cin >> a[i];



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

  cout << res << endl;
  for (int i = 2; i <= n; i++){
    res += abs(a[i-1] - a[i-2]) + abs(a[i-1] - a[i+1]) - abs(a[i] - a[i-2]) - abs(a[i] - a[i+1]);
    cout << res << endl;
  }
  

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
} 


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

int main() {
	string S, T;
	cin >> S >> T;
	char alphabet[26];
	for (int i = 0;i < 26;++ i) alphabet[i] = 0;
	for (int i = 0;i < S.size();++ i) {
		if (alphabet[S[i] - 'a'] == 0) alphabet[S[i] - 'a'] = T[i]; // まだ変換規則が無ければ設定
		else if (alphabet[S[i] - 'a'] != T[i]) {
			cout << "No";
			return 0;
		}
	}
	sort(alphabet, alphabet+26);
	for (int i = 0;i < 25;++ i) {
		if (alphabet[i] != 0 && alphabet[i] == alphabet[i + 1]) { // 同じ文字に変換もダメですよー
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

これが不可能な場合として、あるS_i, S_jでS_i=S_jとなるようなものであって、T_i≠T_jが存在する場合
それが無ければ大丈夫
よって、各アルファベットについて必ず一致するか調べれば良い
*/

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int c[n];
    int a[n][m];
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    bool ok = false;
    ll ans = 1e18;
    int end = (1 << n) - 1;
    ll sum[m];
    for (int i = 0; i < m; i++) {
        sum[i] = 0;
    }
    ll coin = 0;
    for (int i = 0; i <= end; i++) {
        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {
                for (int k = 0; k < m; k++) {
                    sum[k] += a[j][k];
                }
                coin += c[j];
            }
        }

        bool ok2 = true;
        for (int j = 0; j < m; j++) {
            if (sum[j] < x) {
                ok2 = false;
                break;
            }
        }
        if (ok2) {
            ok = true;
            ans = min(coin, ans);
        }
        coin = 0;
        for (int i = 0; i < m; i++) {
            sum[i] = 0;
        }
    }

    if (ok) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

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

#define int long long

signed main(void){
    int n; cin >> n;
    string s; cin >> s;
    int r=0,l=0;
    for(int i=0;i<n;i++){
        if(s[i]=='('){
            r++;
        }else{
            if( 0<r){
                r--;
            }
        }
    }
    for(int i=n-1;0<=i;i--){
        if(s[i]==')'){
            l++;
        }else{
            if( 0<l){
                l--;
            }
        }
    }
    string r_bracket(r,')'), l_bracket(l,'(');
    // cout << r_bracket << ' ' << l_bracket << endl;
    s = l_bracket + s + r_bracket;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import math

# print('input >>')
A, B, H, M = map(int,(input().split()))

PI = math.pi

tan_deg = H / 12 * (2 * PI) + M / 60 * (PI / 6) 
chou_deg = M / 60 * (2 * PI)

kakudo = abs(chou_deg-tan_deg)

C2 = A**2 + B**2 - 2*A*B * math.cos(kakudo)

ans = math.sqrt(C2)

# print('-----output-----')
print(ans)

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

double dp[3001][3001];

double solve(std::vector<double>& ar, int i, int x)
{
	//base case
	if (x == 0)
		return 1;
	if (i == 0)
		return 0;
	if (dp[i][x] > -0.9)//double should be avoided while comparing with -1
		return dp[i][x];
	return dp[i][x] = ar[i] * solve(ar, i - 1, x - 1) + (1 - ar[i]) * solve(ar, i - 1, x);
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	memset(dp, -1, sizeof dp);
	std::vector<double> ar(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> ar[i];
	cout << fixed << setprecision(19) << solve(ar, n, ((n + 1) / 2));
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll x, y;
	//ll a, b, c;
	ll k;
	string s, t;
	ll l_ans = 0;
	float f_ans = 0;
	string s_ans;

	cin >> n;

	ll c0, c1, c2, c3;
	c0 = c1 = c2 = c3 = 0;
	vector<string> st(n);
	rep(i, n) {
		cin >> st[i];
		if (st[i] == "AC") c0++;
		else if (st[i] == "WA") c1++;
		else if (st[i] == "TLE") c2++;
		else if (st[i] == "RE") c3++;
	}

	cout << "AC x " << c0 << "\n";
	cout << "WA x " << c1 << "\n";
	cout << "TLE x " << c2 << "\n";
	cout << "RE x " << c3 << "\n";

}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_b();

	return 0;
}


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

int main()
{
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin>>a.at(i).at(j);
    }
  }

  vector<int> t(h),y(w);


  for(int j=0;j<h;j++){
    for(int i=0; i<w; i++){
    if(a.at(j).at(i)=='#'){
      t[j]=1;
    }
   }
  }

  for(int i=0;i<w;i++){
    for(int j=0; j<h; j++){
    if(a.at(j).at(i)=='#'){
      y[i]=1;
    }
   }
  }

  /**/
  /*for(int i=0;i<w;i++){
    cout<<y[i];
  }
  cout<<endl;

  for(int i=0;i<h;i++){
    cout<<t[i];
  }
  cout<<endl;*/


  for(int j=0;j<h;j++){
    for(int i=0;i<w; i++){
      if(t[j]!=0 && y[i]!=0){
        cout<<a.at(j).at(i);
      }
    }
    if(t[j]!=0){
      cout<<endl;
    }
    
  }


  
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();

		int ans = Math.max(A1, Math.max(A2, A3)) - Math.min(A1, Math.min(A2, A3));
		System.out.println(ans);
	}
}

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


int main(){
  string s;
  string t;
  cin >>s;
  cin >>t;
  int x =s.length();
  bool flag = true;
  rep(i,x){
    if(s[i]!=t[i]){
      flag = false;
    }
  }
  if(flag)cout<<"Yes";
  else cout <<"No";
  return 0;

}


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

int main(){
    int x, a;
    cin >> x >> a;
    if(x<a) cout << 0 << endl;
    else cout << 10 <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[100000];
    int n;
    scanf("%d",&n);
    int i = 1;
    while(n --)
    {
        cin >> arr[i];
        i ++;
    }
    int m;
    cin >> m;
    while(m --)
    {
        int p, x;
        cin >> p >> x;
        int c;
        c = arr[p];
        arr[p] = x;
        int sum = 0;
        for(int j = 1; j < i; j ++)
        {
            sum += arr[j];
        }
        cout << sum <<endl;
        arr[p] = c;
    }
    return 0;
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         1000005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;
vll adj[MAXN];
ll vis[MAXN],dp[MAXN];
map<pair<ll,ll>,ll>  mm;
bool isCycle(ll u){
	vis[u]=1;
	bool fl=false;
	for(auto it:adj[u]){
		if(vis[it]==0) fl|=isCycle(it);
		else if(vis[it]==1) return true;
	}
	vis[u]=2;
	return fl;
}
void dfs(ll u){
	vis[u]=1;
	dp[u]=1;
	for(auto it:adj[u]){
		if(!vis[it]){
			dfs(it);
		}
		dp[u]=max(dp[u],1+dp[it]);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n;
	rep(i,1,n+1){
		rep(j,i+1,n+1) mm[mp(i,j)]=(++cnt);
	}
	set<pair<ll,ll> > e;
	rep(i,1,n+1){
		pll v;
		rep(j,0,n-1) {
			cin>>k;
			v.pb(mp(min(i,k),max(i,k)));
		}
		rep(j,0,v.size()-1){
			adj[mm[v[j]]].pb(mm[v[j+1]]);
		}
	}	
	n=cnt;
	rep(i,1,n+1){
		if(!vis[i] && isCycle(i)) ret(-1)
	}
	memset(vis,0,sizeof(vis));
	rep(i,1,n+1){
		if(!vis[i]) dfs(i);
	}
	ret(*max_element(dp+1,dp+n+1));
	return 0;
}

Measured memory_bytes: 84224
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
     cin.tie(0);
        ios::sync_with_stdio(false);
        int R,G,B,n; int ans=0;
        cin >> R >> G >> B >> n;
        for(int r=0;r<=n/R;r++){
            for(int g=0;g<=n/G;g++){
              if(n>=g*G+r*R){
               int x=n-G*g-r*R;
              if(x % B==0) ans++;
              }
            }
        }
     cout <<ans<<endl;
}

Measured memory_bytes: 256
s = input()
t = input()

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i][j] + 1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = []
i = len(s) - 1
j = len(t) - 1
while True:
    if i < 0 or j < 0:
        break
    if dp[i+1][j+1] == dp[i+1][j]:
        j -= 1
    elif dp[i+1][j+1] == dp[i][j+1]:
        i -= 1
    elif dp[i+1][j+1] == dp[i][j] + 1:
        ans.append(t[j])
        i -= 1
        j -= 1

print("".join(ans)[::-1])

Measured memory_bytes: 113372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  cout<<fixed<<setprecision(20);
  cin.tie(0);ios::sync_with_stdio(false);
  ll x;
  cin>>x;
  int i=0;
  for(;i*(i+1)/2<x;i++){}
  cout<<i<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int tmp,D[100]={},ans;
void north(){
    tmp=D[0];
    D[0]=D[1];
    D[1]=D[5];
    D[5]=D[4];
    D[4]=tmp;
}
void south(){
    tmp=D[0];
    D[0]=D[4];
    D[4]=D[5];
    D[5]=D[1];
    D[1]=tmp;
}
void east(){
    tmp=D[0];
    D[0]=D[3];
    D[3]=D[5];
    D[5]=D[2];
    D[2]=tmp;
}
void west(){
    tmp=D[0];
    D[0]=D[2];
    D[2]=D[5];
    D[5]=D[3];
    D[3]=tmp;
}
void around(){
    tmp=D[1];
    D[1]=D[3];
    D[3]=D[4];
    D[4]=D[2];
    D[2]=tmp;
}
void serch(int a){
    for(int k=0;k<6;k++){
        if(a==D[k]){
            ans=k;
            break;
        }
    }
    if(ans==1){
        north();
    }
    else if(ans==2){
        west();
    }
    else if(ans==3){
        east();
    }
    else if(ans==4){
        south();
    }
    else if(ans==5){
        south();
        south();
    }
}
int main(){
    int a,b,d[100]={};
    for(int i=0;i<6;i++){
        cin>>D[i];
    }
    for(int i=0;i<6;i++){
        cin>>d[i];
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                around();
                if(D[0]==d[0] && D[1]==d[1] && D[2]==d[2] && D[3]==d[3] && D[4]==d[4] && D[5]==d[5]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
            west();
        }
        north();
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  cin >> N;

  cout << 0 << "\n";
  string p;
  int pos = 0;
  cin >> p;
  if(p[0] == 'V'){
    cout << 0 << "\n";
    return 0;
  }

  int le = N+1;
  int ri = 0;
  while(1){
    int mid = (ri+le)/2;
    cout << mid << "\n";
    string s;
    cin >> s;
    if(s[0] == 'V'){
      return 0;
    }

    if(abs(pos-mid)%2 == 0){
      if(s == p) ri = mid;
      else le = mid;
    }else{
      if(s != p) ri = mid;
      else le = mid;
    }
  }

  return 0;
}

Measured memory_bytes: 976
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define NA -1

int main()
{
	int H, W, N;

	while (true)
	{
		cin >> W >> H >> N;

		if (W == 0 && H == 0) { break; }

		vector<int> X(N);
		vector<int> Y(N);

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

		vector<vector<int> > dp(H, vector<int>(W, 0));

		for (int i = 0; i < N; i++)
			dp[Y[i] - 1][X[i] - 1] = NA;

		for (int i = 0; i < H; i++)
		{
			if (dp[i][0] == NA)
			{
				break;
			}

			dp[i][0] = 1;
		}

		for (int j = 0; j < W; j++)
		{
			if (dp[0][j] == NA)
			{
				break;
			}

			dp[0][j] = 1;
		}

		for (int i = 1; i < H; i++)
		{
			for (int j = 1; j < W; j++)
			{
				if (dp[i][j] != NA)
				{
					dp[i][j] += max(dp[i - 1][j], 0);
					dp[i][j] += max(dp[i][j - 1], 0);
				}
			}
		}

		cout << dp[H - 1][W - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,r;cin>>n>>r;
  if(n>9) print(r);
  else print(r+100*(10-n));
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    string ans= "";
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '0')
        {
            ans += '0';
        }
        else if(s[i] == '1')
        {
            ans += '1';
        }
        else if(s[i] == 'B' && ans != "")
        {
            ans.pop_back();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define fi first
#define sc second
using namespace std;
typedef pair<int, int> P;
typedef priority_queue<P, vector<P> > PQ;

int n;
int ans = -10000;
int z[300][300],p[300][300];
int tate[300][300], yoko[300][300];

int main(){
	scanf("%d",&n);
	rep(i,n)rep(j,n)scanf("%d",&z[i][j]);
	rep(i,n)rep(j,n){
		p[i][j] = z[i][j];
		tate[i][j] = p[i][j];
		yoko[i][j] = p[i][j];
	}
	rep(i,n) for(int j = 1; j < n; j++) yoko[i][j] += yoko[i][j-1];
	rep(i,n) for(int j = 1; j < n; j++) p[i][j] += p[i][j-1];
	for(int i = 1; i < n; i++) rep(j,n) tate[i][j] += tate[i-1][j];
	for(int i = 1; i < n; i++) rep(j,n) p[i][j] += p[i-1][j];
	
	rep(i,n) rep(j,n){
		for(int k = j; k < n; k++){
			if(j != 0) ans = max(ans,yoko[i][k]-yoko[i][j-1]);
			else ans = max(ans,yoko[i][k]);
		}
	}
	
	rep(i,n) rep(j,n){
		for(int k = i; k < n; k++){
			if(i != 0) ans = max(ans,tate[k][j]-tate[i-1][j]);
			else ans = max(ans,tate[k][j]);
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			PQ que;
			if(i == 0){
				for(int k = 0; k < n; k++){
					int x;
					if(k != 0) x = p[j][k]-p[j-1][k-1]+p[i][k-1];
					else x = p[j][k];
					que.push(P(x,k));
				}
			} else{
				for(int k = 0; k < n; k++){
					int x;
					if(k != 0) x = p[j][k]-p[i-1][k]-p[j-1][k-1]+p[i][k-1];
					else x = p[j][k]-p[i-1][k];
					que.push(P(x,k));
				}
			}
			for(int k = 0; k < n; k++){
				while(true){
					if(que.size() == 0) break;
					if(que.top().sc <= k) que.pop();
					else break;
				}
				if(que.size() == 0) break;
				int t = que.top().sc;
				if(i == 0){
					if(k == 0){
						ans = max(ans,yoko[j][t]+tate[j][t]+tate[j][k]+yoko[i][t]-z[j][t]-z[j][k]-z[i][k]-z[i][t]);
					} else{
						ans = max(ans,yoko[j][t]+tate[j][t]+tate[j][k]+yoko[i][t]-yoko[j][k-1]-yoko[i][k-1]-z[j][t]-z[j][k]-z[i][k]-z[i][t]);
					}
				} else if(k == 0){
					ans = max(ans,tate[j][t]+yoko[j][t]+tate[j][k]+yoko[i][t]-tate[i-1][t]-tate[i-1][k]-z[j][t]-z[j][k]-z[i][k]-z[i][t]);
				} else{
					ans = max(ans,tate[j][t]-tate[i-1][t]+yoko[j][t]-yoko[j][k-1]+tate[j][k]-tate[i-1][k]+yoko[i][t]-yoko[i][k-1]-z[j][t]-z[i][t]-z[j][k]-z[i][k]);
				}
			}
		}
	}
	printf("%d\n",ans);
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

i32 dp[2][200010];

signed main() {
  i32 n;
  string s;
  cin >> n >> s;
  REP(i, n) {
    if (s[i] == '#') {
      dp[0][i + 1] = dp[0][i] + 1;
      dp[1][i + 1] = min(dp[0][i], dp[1][i]);
    } else {
      dp[0][i + 1] = dp[0][i];
      dp[1][i + 1] = min(dp[0][i], dp[1][i]) + 1;
    }
  }
  i32 ans = min(dp[0][n], dp[1][n]);
  cout << ans << endl;
}


Measured memory_bytes: 3732
# pythonではpow(x, y, mod)で同様のことができるので
# 今後、実装は不要
def pow(x, y):
    if y == 0:
        return 1
    if y % 2 == 0:
        ans = pow(x ** 2 % INF, y // 2)
    else:
        ans = (pow(x ** 2 % INF, y // 2) * x) % INF
    return ans

def comb_big(m, k):
    x, y = 1, 1
    for i in range(k):
        x = x * (m - i) % INF
        y = y * (k - i) % INF
    return x * pow(y, INF - 2) % INF

INF = 10 ** 9 + 7
n, a, b = map(int, input().split())

ans = pow(2, n) - 1 - comb_big(n, a) - comb_big(n, b)
print((ans + INF) % INF)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vvl dp(n+1, vl(k+1));  // dp[i+1][j] : i人目の子供(iは0-index)まででj個の飴を分け合う方法の数
    dp[0][0] = 1;
    rep(i, n) {
        exrep(j, 1, k) {
            dp[i][j] += dp[i][j-1];
            dp[i][j] %= mod;
        }
        rep(j, k+1) {
            ll R = dp[i][j];
            ll L = 0;
            if(j > a[i]) {
                L = dp[i][j - a[i] - 1];
            }
            dp[i+1][j] = (R - L + mod)%mod;
        }
    }

    out(dp[n][k]);
    re0;
}

Measured memory_bytes: 80256
import java.util.*;
 
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int [] N = new int[3];
    int nmax = 0;
    int goukei = 0;
    String ans = "No";

    for(int i = 0 ; i < N.length ; i ++){
      N[i] = sc.nextInt();
      nmax = Math.max(nmax,N[i]);
      goukei = goukei + N[i];
    }
    
    ans = (goukei == nmax * 2 ) ? "Yes" : "No";

    System.out.println(ans);
  }
}


Measured memory_bytes: 21712