akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a,b,k;
  cin>>a>>b>>k;
 // cout<<a<<" "<<b<<" "<<k<<"\n";
  if(a>=k){a=a-k;k=0;}
  else {k=k-a;a=0;}
  // cout<<a<<" "<<b<<" "<<k<<"\n";
  if(k>=b){k=k-b;b=0;}else{b=b-k;k=0;}
   //cout<<a<<" "<<b<<" "<<k<<"\n";
  cout<<a<<" "<<b;  
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int count[] = new int[4];
		for(; scanner.hasNext();)
		{
			String input = scanner.next();
			String[] words = input.split(",");
			
			switch(words[1])
			{
				case "A":
					count[0] ++;
					break;
				case "B":
					count[1] ++;
					break;
				case "AB":
					count[2] ++;
					break;
				case "O":
					count[3] ++;
					break;
			}
		}
		
		for(int i=0; i<4; i++)
		{
			System.out.println(count[i]);
		}
	}
}

Measured memory_bytes: 25784
def main():
    H, N = map(int, input().split())
    dam, mp = [0] * N, [0] * N
    for i in range(N):
        dam[i], mp[i] = map(int, input().split())

    # dp[i magic][j damage] := min mp
    H_MAX = H + max(dam)
    INF = float('inf')
    dp = [[INF] * (H_MAX + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(H_MAX + 1):
            if j - dam[i] >= 0:
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - dam[i]] + mp[i])
            else:
                dp[i + 1][j] = dp[i][j]

    print(min(dp[N][H:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 305544
(loop repeat (read)
      with count = 0
      with current = 0
      with last = 0
      for height = (read)
      do (if (> last height)
             (setf current last
                   count (+ count (- last height)))
             (setf last height))
      ;;do (print (list last height))
            finally (format t "~A~%" count))

Measured memory_bytes: 77008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = ll>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    char c = in<char>();
    c += 1;
    cout << c << "\n";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

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

	rep(i,0,k+1){
	    rep(j,0,k+1){
            if(0 <= s-i-j && s-i-j <= k)ans++;
	    }
    }
    cout << ans << endl;
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

int main (void)
{
	int a,b,c,n,cou;

	cin >> a >> b >> c >> n;

	cou = 0;

	for (int i = 0; i < a + 1; i++)
	{
		for (int j = 0; j < b + 1; j++)
		{
			for (int k = 0; k < c + 1; k++)
			{
				if (n == (500 * i) + (100 * j) + (50 * k))
				{
					cou += 1;
				}
			}
		}
	}

	cout << cou << endl;
}

Measured memory_bytes: 256
#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;
    vint a(N);
    REP(i,N) cin>>a[i];

    vint b=a;
    sort(ALL(b));

    int c1=0,c2=0;
    REP(i,N){
        int j=lower_bound(ALL(b),a[i])-b.begin();
        if(j%2==1 and i%2==0) c1++;
        if(j%2==0 and i%2==1) c2++;
    }
    cout<<c1<<endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

ll memo[100001]={0};

ll rec(ll n);

int main(void) {
    string s;
    int w;
    cin >> s;
    cin >> w;
    
    for(int i=0; i<s.size(); i+=w)
        cout << s[i];
    
    
        
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    if a[i]%2==1:
        b[i]=(a[i]+1)//2
    else:
        b[i]=(a[i]+1)/2
from itertools import accumulate
ac=list(accumulate(b))
ans=0
for i in range(n-k+1):
    if i==0:
        tmp=ac[k-1]
    else:
        tmp=ac[i+k-1]-ac[i-1]
    ans=max(tmp,ans)
print(ans)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    lint a, b, k; cin >> a >> b >> k;
    lint taka, aoki;
    if(k <= a){
        taka = a - k;
        aoki = b;
    }
    else if(k <= (a + b)){
        taka = 0;
        aoki = b - (k - a);
    }
    else{
        taka = 0;
        aoki = 0;
    }
    cout << taka << " " << aoki << endl;
}

Measured memory_bytes: 888
def resolve():
    S = input()
    c = list(S)
    count = len(c)
    if count == 1 or count % 2 != 0:
        print('No')
        return

    if count == 2 and S != 'hi':
        print('No')
        return

    for i in range(0, count - 2, 2):
        if ''.join(c[i:i + 2]) != 'hi':
            print('No')
            return
    print('Yes')


resolve()

Measured memory_bytes: 3060
// package com.patra.cp.atcoder.practice.dp;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static int solve(int[] arr, int[] dp, int currPos, int K) {
        if(currPos >= arr.length) {
            return Integer.MAX_VALUE;
        }
        if(dp[currPos] != -1) {
            return dp[currPos];
        }
        int count = 0;
        int res = Integer.MAX_VALUE;
        if(currPos == arr.length - 1) {
            res = 0;
        }
        for(int i = currPos + 1; i < arr.length; i++) {
            if(count == K) {
                break;
            }
            count++;
            int temp = solve(arr, dp, i, K);
            res = Math.min(res, temp + Math.abs(arr[currPos] - arr[i]));
        }
        dp[currPos] = res;
        return dp[currPos];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] splits = line.split(" ");
        int N = Integer.parseInt(splits[0]);
        int K = Integer.parseInt(splits[1]);
        int[] arr = new int[N];
        int[] dp = new int[N];
        Arrays.fill(dp, -1);
        line = sc.nextLine();
        splits = line.split(" ");
        for(int i=0; i<N; i++) {
            arr[i] = Integer.parseInt(splits[i]);
        }
        System.out.println(solve(arr, dp, 0, K));
    }
}


Measured memory_bytes: 60592
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        double[] abx = doublea();
        abx[2] /= abx[0];
        double a = abx[0];
        double b = abx[1];
        double x = abx[2];
        double ans = 0;
        if(x / a >= b / 2){
            ans = Atan((b-(x/a)) / (a/2));
        }else{
            ans = Atan((b/2)/(x/b));
        }
        ans *= 180/PI;
        WriteLine(ans);
    
    
    
    
    }
    static long pricemid(long midd,long read0,long read1){
        long temp = midd;
        int countk = 0;
        while(temp > 0){
            temp/=10;
            countk++;
        }
        return (midd*read0) + (countk*read1);
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    static long[] longa(){
        string[] read_str_array = ReadLine().Split(' ');
        long[] return_long_array = new long[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_long_array;
    }
    static double[] doublea(){
        string[] read_str_array = ReadLine().Split(' ');
        double[] return_double_array = new double[read_str_array.Length];
        for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_double_array[countup_i] = long.Parse(read_str_array[countup_i]);
        }
        return return_double_array;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
}


Measured memory_bytes: 13140
def get_primes(n):
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

from itertools import accumulate
import sys
input = sys.stdin.readline

MAX = 100_000
primes = set(get_primes(MAX))
like = [0]*MAX
for n in range(MAX):
    if n in primes and (n+1)//2 in primes:
        like[n] = 1
like = list(accumulate(like))

Q = int(input())
for _ in [0]*Q:
    l, r = map(int, input().split())
    print(like[r] - like[l-1])


Measured memory_bytes: 14140
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
using namespace std;


int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h)*(W - w) << endl;


	return 0;
}

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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] b = nextInts();

		LinkedList<Integer> list = new LinkedList<>();
		for(int i=0;i<b.length;i++){
			list.add(b[i]);
		}
		ArrayList<Integer> ans = new ArrayList<>();
		for(int i=N;i>0;i--){
			boolean flg=false;
			for(int k=i-1;k>=0;k--){
				if(list.get(k)==k+1){
					list.remove(k);
					ans.add(k+1);
					flg=true;
					break;
				}
			}
			if(!flg){
				System.out.println(-1);
				return ;
			}

		}
		for(int i=N-1;i>=0;i--){
			System.out.println(ans.get(i));
		}
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 23380
while True:
	a, b = [int(n) for n in raw_input().split()]
	if a == 0 and b == 0: break
	x = b - a
	res = []
	for c in (1000, 500, 100):
		res += [str(int(x / c))]
		x %= c
	print " ".join(reversed(res))

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

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> p(n);
  iota(p.begin(), p.end(), 0);
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    x--;
    pos[x] = i;
  }
  function<int(int)> root = [&](int x) {
    return x == p[x] ? x : (p[x] = root(p[x]));
  };
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--; y--;
    x = root(x);
    y = root(y);
    p[x] = y;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (root(i) == root(pos[i]));
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  string str;
  cin >> n >> str;
  if(str.size() <= n) cout << str << endl;
  else {
    str = str.substr(0, n);
    cout << str << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main() {
	cin>>a>>b>>c;
	if(a==b && b==c)
		printf("No\n");
	else if(a==b || b==c || a==c)
		printf("Yes\n");
	else printf("No\n");
	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    double x;cin>>x;
    double r = (1.01);
    int i = 0;
    double ini = 100;
    while(!isgreaterequal(ini*r,x)){
        ini = floor(ini*r);
        i++;
    }
    cout<<i+1<<endl;

} 

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define tr(container, it) \
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(), c.end()
#define sum(v) accumulate(all(v),0LL)
#define rep(i,s,n) for (int i=s; i<n; i++)
#define lli long long int
#define MOD 1000000007
#define pii pair <int,int> 
#define pll pair <lli, lli>
#define endl '\n'
#define debugv(c) for(auto hnvx : c) cout << hnvx <<" "; cout << endl;
#define debug(c) cout<<#c<<" := "<<c<<endl;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    int dp[s1.length()+1][s2.length()+1];
    dp[0][0]=0;
    rep(i,0,s1.length()+1) dp[i][0]=0;
    rep(i,0,s2.length()+1) dp[0][i]=0;
    rep(i,1,s1.length()+1)
    rep(j,1,s2.length()+1) if(s1[i-1]==s2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
    else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    stack <char> ans;

    int temp = dp[s1.length()][s2.length()];
    //int temp2=temp;
    int p=s1.length(),q=s2.length();
    while (temp)
    {
        if (dp[p][q]-1==dp[p-1][q-1] && s1[p-1]==s2[q-1]){ans.push(s1[p-1]);p--;q--;}
        else if (dp[p][q]==dp[p-1][q]) p--;
        else q--;
        temp = dp[p][q];
    }
    while (!ans.empty()) {cout<<ans.top(); ans.pop();}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __f{
    __f(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
};

int main(){

    int x, y;
    scanf("%d%d", &x, &y);

    int m = 0;
    if(x == 3) m += 100'000;
    if(y == 3) m += 100'000;
    if(x == 2) m += 200'000;
    if(y == 2) m += 200'000;
    if(x == 1) m += 300'000;
    if(y == 1) m += 300'000;
    if(x == 1 and y == 1) m += 400'000;
    ppp(m);
    
    
    




    return 0;
}


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

using namespace std;
using nagai = long long;
#define sz(x) int((x).size())

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(count(s.begin(),s.end(),'x')<=7)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	string st;
	cin >> st;
	int i = 0;
	vector<int> vs;
	while(i<n){
		int c = st[i];
		int w = 0;
		while(i<n and st[i]==c) ++w, ++i;
		vs.push_back(w);
	}
	while(k--){
		if(len(vs)<=2){
			cout << n-1 << endl;
			return 0;		
		}
		int w = vs.back(); vs.pop_back();
		w += vs.back(); vs.pop_back();
		w += vs.back(); vs.pop_back();
		vs.push_back(w);
	}
	int ans = 0;
	for(auto x:vs) ans += x-1;
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

int main()
{

    ll L, N;
    cin>>L>>N;
    vector<ll> clock;
    vector<ll> counterClock;
    vector<ll> sum_a(N+1, 0);
    vector<ll> sum_b(N+1, 0);
    clock.resize(N);
    counterClock.resize(N);

    for(ll i=0; i<N; ++i)
    {
        ll num;
        cin>>num;
        counterClock[i]=num;
    }

    for(ll i=0; i<N; ++i)
        clock[i]=(L-counterClock[N-1-i]);

    //まずは計算量節約のために合計を計算する
    for(ll i=0; i<N; ++i)
        sum_a[i+1] = sum_a[i] + counterClock[i];

    for(ll i=0; i<N; ++i)
        sum_b[i+1] = sum_b[i] + clock[i];

    ll ans=0; //答えを格納する箱

    //kkを半時計回りと時計回りの本数差とする
    //方針としては反時計周りで当たる本数をLとしてこのLの総当りでやっていく
    //まずは半時計回りスタートとして考える
    for(ll kk=0; kk<N; ++kk)
    {
        //まずは中心点を求める
        long p=(N-kk)/2;
        ll sum=0; //毎回のループの結果を格納

        //周回する場合は2種類あり、ひとつは半時計回りが多めに回る場合と半時計回りと時計回りが同じ場合の2種類がある
        if((N-kk)%2==0)//周回数が同じ
        {
            sum += (sum_a[kk+p]-sum_a[kk])*2; //反時計回りの場合の歩く距離
            //時計回りで終了するので
            sum += ((sum_b[p-1])*2+clock[p-1]);
        }
        else//半時計回りで終了する場合
        {
            sum += (sum_a[kk+p]-sum_a[kk])*2+counterClock[kk+p];
            sum += ((p>0)? sum_b[p]*2 : 0);
        }

        if(sum>ans)
            ans = sum;
    }

    //次に時計回りスタートの場合を考える
    for(ll kk=0; kk<N; kk++)
    {
        //まずは中心点(行ける最大値までを求める)
        //kkはスタート位置として考えても良い
        long p= (N-kk)/2;
        ll sum = 0;

        if((N-kk)%2==0)
        {
            /*
             * この場合clockwiseはp+1までいけてcounterClockWiseはpまでいける。
             * ただし半時計回りで終了するので半時計回りの方は最後は片道分だけをたせばok
             */
            sum += (sum_b[kk+p]-sum_b[kk])*2;
            sum += ((sum_a[p-1])*2+counterClock[p-1]);
        }
        else
        {
            /*
             * この場合は時計回りのほうがpまで行って終了する
             */
            sum+= (sum_b[kk+p]-sum_b[kk])*2 + clock[kk+p];
            sum += (p>0 ? (sum_a[p])*2 : 0);
        }

        if(sum>ans)
            ans = sum;
    }


    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 6528
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var ND = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            Console.WriteLine(Math.Ceiling(ND[0]/(ND[1]*2.0+1)));
        }
    }
}


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

int main() {
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
      cin >> A[i];
  }

  int max_dist = 0;
  max_dist = A[0] + K - A[N-1];
  for(int i=0;i<N-1;i++){
      max_dist = max(max_dist, A[i+1] - A[i]);
  }
  cout << K - max_dist << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int n;

    cin >> n;

    int tasks[n][3];
    int points[n][3];

    for(int i = 0; i < n; i++) {
        cin >> tasks[i][0] >> tasks[i][1] >> tasks[i][2];
    }

    points[0][0] = tasks[0][0];
    points[0][1] = tasks[0][1];
    points[0][2] = tasks[0][2];

    for(int i = 1; i < n; i++) {
        points[i][0] = tasks[i][0] + max(points[i - 1][1], points[i - 1][2]);
        points[i][1] = tasks[i][1] + max(points[i - 1][0], points[i - 1][2]);
        points[i][2] = tasks[i][2] + max(points[i - 1][0], points[i - 1][1]);
    }

    cout << max(points[n - 1][0], max(points[n - 1][1], points[n - 1][2])) << endl;

    return 0;
}


Measured memory_bytes: 2560
mod = 10**9+7
N = int(input())
x = list(map(int,input().split()))
fact = [1]*(N+1)
for i in range(N):
    fact[i+1] = (i+1)*fact[i]
    fact[i+1] %= mod
inv = [1]*(N+1)
for i in range(N):
    inv[i] = pow(i,mod-2,mod)

x1 = []
for m in range(1,N-1):
    x1.append(x[m]*m*inv[m+1]%mod)
x2 = []
for n in range(N-2):
    x2.append(x[n]*(N-n-2)*inv[N-n-1]%mod)
x3 = []
for n in range(N-1):
    x3.append((x[N-1]-x[n])*inv[N-n-1])
ans = fact[N-1]*(sum(x1)-sum(x2)+sum(x3))
ans %= mod
print(ans)

Measured memory_bytes: 85528
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		if(s[i]=='C')
		  for(int j=i+1;j<len;j++)
		     if(s[j]=='F')
		     {
				 cout<<"Yes"<<endl;
				 return 0;
			 }
	}
	cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K;
    cin >> N >> K;
    vector<int> A;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        A.emplace_back(tmp);
    }

    sort(A.begin(), A.end());
    vector<int> cnt;
    int num = 0;
    int v = 0;
    vector<int>::iterator itr;
    for (int i : A)
    {
        if (i != num)
        {
            num = i;
            cnt.emplace_back(0);
            itr = cnt.end();
            itr--;
            v += 1;
        }
        *itr += 1;
    }
    sort(cnt.begin(), cnt.end());

    long long sum = 0;
    int i = 1;
    while (v > K)
    {
        sum += (long long)cnt[i - 1];
        i++;
        v--;
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 2548
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define rep(j, n) for (int i = j; i < n; i++)
#define repd(j, n) for (int i = j; i > n; i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int main() {
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for(int i=m/n;i>=1&&ans==0;i--) {
		if (m%i==0) {
			ans = i;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=410,Mod=1e9+7;
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second
#define inf 1e17
int n;
ll dp[N][N],a[N];
ll sum(int l,int r)
{
  ll s=0;
  for(int i=l;i<=r;i++) s+=a[i];
  return s;
}
ll f(int l,int r)
{
  if(l==r) return dp[l][r]=0;
  if(l==(r-1)) return dp[l][r]=a[l]+a[r];
  if(dp[l][r]!=inf) return dp[l][r];
  for(int k=l;k<r;k++) dp[l][r]=min(f(l,k)+f(k+1,r)+sum(l,r),dp[l][r]);
  return dp[l][r];
}
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dp[i][j]=inf;
  f(1,n);
  cout<<dp[1][n]<<endl;
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	
	int sum1=a+b+c,sum2=a+b;
	if (k==sum1)
		cout<<a-c<<endl;
	else if (k>sum2)
		cout<<a-(k-sum2)<<endl;
	else if (k>a)
		cout<<a<<endl;
	else
		cout<<k<<endl;
}

Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N,K,L = map(int, input().split())
    class UnionFind():
        #n個の要素を番号0~n-1で管理する
        #parents:要素の親(1つ上), 要素が根の場合サイズを表す
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        #要素xの根を返す, その過程で経路圧縮も行う
        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)
            if x == y:
                return
            #それぞれのsizeで比べる
            if self.parents[x] > self.parents[y]:
                x, y = y, x
            self.parents[x] += self.parents[y]
            self.parents[y] = x #根をくっつける(片方を親にする)

        #xが属するグループのsize
        def size(self, x):
            return -self.parents[self.find(x)]

        #xとyが同じグループかどうか
        def same(self, x, y):
            return self.find(x) == self.find(y)

        #xが属するグループの要素全てを返す
        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]
        
    douro = UnionFind(N+1)
    tetudou = UnionFind(N+1)
    for _ in range(K):
        p,q = map(int, input().split())
        douro.union(p,q)
    for _ in range(L):
        r,s = map(int, input().split())
        tetudou.union(r,s)
    dic = {}
    parlis = []
    for i in range(1, N+1):
        p1 = douro.find(i)
        p2 = tetudou.find(i)
        parlis.append((p1,p2))
        if (p1,p2) in dic:
            dic[(p1,p2)] += 1
        else: 
            dic[(p1,p2)] = 1
    print(' '.join([str(dic[parlis[i]]) for i in range(N)]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 62492
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

struct edge{ int to, cost;};

int N, M;
vector<vector<edge> >G(128);
int d[2][128];

void dfs(int n, int c, int sum){
  //  printf("%d %d %d\n", n, c, sum);
  if(d[c][n] <= sum) return;
  d[c][n] = sum;

  rep(i, G[n].size()){
    edge e = G[n][i];
    int next = e.to;
    //    printf("%d\n", next);
    dfs(next, c, sum + e.cost);

    if(c){
      rep(i, G[next].size())
	dfs(G[next][i].to, 0, sum);
    }
  }
}

int main(){
  while(scanf("%d%d", &N, &M) && N+M){
    rep(i, 2) rep(j, N) d[i][j] = INF;
    rep(i, N) G[i].clear();
    rep(i, M){
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c); a--; b--;
      //      printf("%d %d\n", a, b);
      edge e;
      e.to = a; e.cost = c;
      G[b].PB(e);
      e.to = b;
      G[a].PB(e);
    }
    /*    rep(i, N){
      rep(j, G[i].size()) printf("%d ", G[i][j].to); puts("");
      }*/
    dfs(0, 1, 0);
    /*    rep(i, 2){
      rep(j, N) printf("%d ", d[i][j]);puts("");
      }*/
    printf("%d\n", min(d[0][N-1], d[1][N-1]));
  }
  return 0;
}

Measured memory_bytes: 1224
#pragma GCC optimize("Ofast")

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

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

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

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

int N;
int A[50], B[50], C[50];

int main() {
	cin >> N;
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];
	REP(i, N - 1) cin >> C[i];
	C[N - 1] = 0;
	int ans = 0;
	REP(i, N) ans += B[i];
	REP(i, N - 1) {
		if ((A[i + 1] == A[i] + 1))
		{
			ans += C[A[i] - 1];
		}
	}
	cout << ans << endl;
}


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 998244353;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


void test_case() {
	
}


int main() {
	fastio;
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif // !ONLINE_JUDGE
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; ++i) {
		for (int j = 0; j <= x; ++j) {
			if (i * 2 + j * 4 == y && i + j == x) {
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}


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


// ローリングハッシュ
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp of S[a:] and S[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }

    // get lcp of S[a:] and T[b:]
    inline int getLCP(const RollingHash &T, int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != T.get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};


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

    // ロリハ
    RollingHash rh(S);

    // 求める
    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            int lcp = rh.getLCP(i, j);
            lcp = min(lcp, j-i);
            res = max(res, lcp);
        }
    }   
        
    cout << res << endl;
}

Measured memory_bytes: 3736
N = int(input())

f = [0 for i in range(N)]

for x in range(1, int(N**0.5)+1) :
  for y in range(1, int(N**0.5)+1) :
    for z in range(1, int(N**0.5)+1) :
      n = x*x + y*y + z*z + x*y + y*z + z*x
      if n > N :
        break
      else :
        f[n-1] += 1
        
        
        
for i in range(N) :
  print(f[i])


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

typedef long long ll;

vector<pair<ll,ll>> primeFactorial(ll n){
    vector<pair<ll,ll>> res;
    for (ll i = 2;i*i<=n;i++){
        int r = 0;
        while (n%i == 0){
            r++;
            n /= i;
        }
        res.emplace_back(i,r);
    }
    if (n > 1) {
        res.emplace_back(n,1);
    }
    return res;
}

int main() {
    ll N, P;
    cin >> N >> P;
    vector<pair<ll,ll>> f;
    f = primeFactorial(P);
    ll ans = 1;
    for (int i=0;i<f.size();i++){
        ll r = f[i].second/N;
        while (r>0){
            ans *= f[i].first;
            r--;
        }
    }
    cout << ans << "\n";
}

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

const int MAXK = 1e5 + 10;
const int MAXN = 1e3 + 10;

int A[MAXN],dp[MAXK],N,K;

int solve(int k){

	if(dp[k] != -1) return dp[k];

	if(k == 0) return dp[k] = 0;

	int ans = 0;
	for(int i = 1;i<=N;i++){
		if(A[i] > k) continue;
		if(solve(k - A[i]) == 0){
			ans = 1;
			break;
		}
	}

	return dp[k] = ans;

}

int main(){

	memset(dp,-1,sizeof(dp));
	cin >> N >> K;
	for(int i = 1;i<=N;i++){
		cin >> A[i];
	}

	if(solve(K)) printf("First\n");
	else printf("Second\n");

	return 0;

}

Measured memory_bytes: 7052
#include<iostream>
using namespace std;
int main ()
{
int a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7)
	{
		cout<<"YES"<<endl;
	}
	else if (a==5&&b==7&&c==5){
		cout<<"YES"<<endl;
	}
	
		else if (a==7&&b==5&&c==5){
		cout<<"YES"<<endl;

		}
	else{
		cout<<"NO"<<endl;
	}
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    ll n, x;
    cin >> n;
    vector<ll>v(n+1);
    for (ll i = 1; i <= n; i++) {
        cin >> v[i];
    }

    vector<ll>f(n+1, 0), l(n+2, 0) ;
    l[n+1] = 0;
    for (ll i = 1; i <= n; i++) {
        f[i] = gcd(f[i-1], v[i]);
    }
    for (ll i = n ; i >= 1; i--) {
        l[i] = gcd(l[i+1], v[i]);
    }
    ll mn = 0;

    for (ll i = 1; i <= n ; i++) {
        mn = max (mn, gcd(f[i-1], l[i+1]));
    }
    cout << mn << endl;
}


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

long r;
long c;
long new_x;
long new_y;
long res;
string input;
vector<vector<long>> candidate = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
vector<vector<char>> _map;
set<vector<long>> already;
queue<vector<long>> que;

long bfs(long x, long y, long cnt){
    already.insert({x, y});
    if(x == c && y == r){
        return cnt;
    }
    for(vector<long> candi: candidate){
        new_x = x + (long)candi[0];
        new_y = y + (long)candi[1];
        new_x = max(min(new_x, c), (long)0);
        new_y = max(min(new_y, r), (long)0);
        if(_map[new_y][new_x] == '.' && already.find({new_x,new_y}) == already.end()){
            que.push({new_x, new_y, cnt + 1});
            already.insert({new_x, new_y});
        }
    }
    if(que.size() == 0){
        return -1;
    }
    new_x = que.front()[0];
    new_y = que.front()[1];
    cnt = que.front()[2];
    que.pop();
    res = bfs(new_x, new_y, cnt);
    return res;
}

int main(){
    long count=0;
    cin >> r >> c;
    _map.resize(r);
    for(int i=0; i<r; i++){
        _map[i].resize(c);
        cin >> input;
        for(int j=0; j<c; j++){
            _map[i][j] = input[j];
            if(input[j] == '#'){
                count++;
            }
        }
    }
    r--;
    c--;
    res = bfs(0, 0, 0);
    if(res < 0){
        cout << res << endl;
    } else {
        cout << (r + 1) * (c + 1) - count - res - 1 << endl;
    }
}

Measured memory_bytes: 896
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int ta = in.nextInt();
			int ha = in.nextInt();
			if((ta|ha)==0)
				return;
			int a[]=new int[ta];
			int b[]=new int[ha];
			int ans1=-1;
			int ans2=-1;
			boolean  flag=false;
			for(int i=0; i<ta;i++)
				a[i]=in.nextInt();
			for(int j=0; j<ha;j++)
				b[j]=in.nextInt();
			int min=Integer.MAX_VALUE;

			for(int i=0;i<ta;i++)
			{
				
				for(int j=0; j<ha;j++)
				{
					int sa=0;
					int sb=0;
					int tmp=a[i];
					a[i]=b[j];
					b[j]=tmp;
					for(int k=0; k<ta;k++)
						sa+=a[k];
					for(int m=0; m<ha;m++)
						sb+=b[m];
					if(sa==sb&&min>b[j]+a[i])
					{
						 ans1=b[j];
						 ans2=a[i];
						 min=a[i]+b[j];
						//System.out.println(b[j]+" "+a[i]);
						flag=true;
					}
					int tmp2=b[j];
					b[j]=a[i];
					a[i]=tmp2;
				}
			}
			
			if(!flag)
				System.out.println(-1);
			else
				System.out.println(ans1+" "+ans2);
		}
	}
}

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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  map<string, int> cnt;
  for(int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    cnt[s] += 1;
  }
  for(auto s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " x " << cnt[s] << '\n';
  }
}

Measured memory_bytes: 3676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] stringArray = br.readLine().split("\\s");

        // 後に入れたものを先に抜き出す（いわゆるLIFO）
        Stack<Integer> que = new Stack<Integer>();
        int a = 0;
        int b = 0;
        for (int i = 0; i < stringArray.length; i++) {
            if (stringArray[i].equals("+")) {
                a = que.pop();
                b = que.pop();
                que.add(b + a);
                continue;
            }
            if (stringArray[i].equals("-")) {
                a = que.pop();
                b = que.pop();
                que.add(b - a);
                continue;
            }
            if (stringArray[i].equals("*")) {
                a = que.pop();
                b = que.pop();
                que.add(b * a);
                continue;
            }
            if (stringArray[i].equals("/")) {
                a = que.pop();
                b = que.pop();
                que.add(b / a);
                continue;
            }
            // 演算子以外はstackに登録する
            que.push(Integer.parseInt(stringArray[i]));
        }
        System.out.println(que.pop());
    }
}



Measured memory_bytes: 24468
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int main(){
	int n,m;scanf("%d%d",&n,&m);
	if(n==1 && m==1)return puts("1"),0;
	if(n==1)return printf("%d\n",m-2),0;
	if(m==1)return printf("%d\n",n-2),0;
	printf("%lld\n",1ll*(n-2)*(m-2));

	return 0;
}


Measured memory_bytes: 256
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){  
                                                        for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    long n;
    cin>>n;
    long a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long maxx=N+1,ans=0;
    for(int i=0;i<n;i++){
        maxx=min(maxx,a[i]);
        if(maxx>=a[i])
            ans++;
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;

int main() {
  vector<int> V(3);
  for (int i=0; i<3; i++) {
    cin >> V[i];
  }
  sort(V.begin(), V.end());
  if (V[0]+V[1]==V[2]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

ll gcd(ll x , ll y){
  if(x<y){
    swap(x,y);
  }
  ll r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main() {
  int n; cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];

  ll ans = v[0];
  for(int i=1; i<n; i++){
    ans =  gcd(ans, v[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define pii pair<int, int>
ld const pi = 3.141592653589793238462;
int const mod = 1e9+7;

int power(int a,int b){
    int f=1;
    while(b>0){
        if(b&1){
            f=f*a;
        }
        a=a*a;
        b=b/2;
    }
    return f;
}

vector<pair<pair<string, int> ,int> > v;

bool cmp(pair<pair<string, int> ,int> a ,pair<pair<string, int> ,int> b)
{
    if(a.ff.ff < b.ff.ff) return true;
    else if(a.ff.ff == b.ff.ff){
        if(a.ff.ss >= b.ff.ss) return true;
        else return false;
    }
    else return false;
}

int const N = 11;
vector<int> s[N];


int32_t main(){
    IOS;
    int n,m,i,j,l;
    cin>>n>>m;
    for(i=0;i<m;i++){
        int x;
        cin>>x;
        for(j=0;j<x;j++){
            cin>>l;
            s[i+1].pb(l);
        }
    }
    int p[m+1];
    for(i=1;i<=m;i++) cin>>p[i];
    int ans=0;

    for(i=0;i<power(2,n);i++){
        int x = i;
        int st[n+1]={0};
        for(j=1;j<=n;j++){
            st[j] = x%2;
            x=x/2;
        }
        //cout<<i<<endl;
        
        int on=0;
        //cout<<i<<endl;
        for(j=1;j<=m;j++){
            int u=0;
            //cout<<j<<" ";
            for(l=0;l<s[j].size();l++){
                if(st[s[j][l]]==1) u++;
                //cout<<s[j][l]<<" ";
            }
            //cout<<endl;
            if(u%2==p[j]%2) on++;
        }
        //cout<<i<< " "<<on<<endl;
        if(on==m) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int d;
	cin >> d;
	
	if(d==25)cout << "Christmas" << endl; 
	else if(d==24)cout << "Christmas Eve " << endl; 
	else if(d==23)cout << "Christmas Eve Eve" << endl; 
	else if(d==22)cout << "Christmas Eve Eve Eve" << endl; 
	
	return 0;
}


Measured memory_bytes: 256