akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
  	switch (input[0]){
      case 'A':
    	console.log('T');
        break;
      case 'C':
    	console.log('G');
        break;
      case 'G':
    	console.log('C');
        break;
      case 'T':
        console.log('A');
        break;
                 }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                PrintWriter ou = new PrintWriter(System.out);
                int h = Integer.parseInt(sc.next());
                int w = Integer.parseInt(sc.next());
                int[][] a = new int[h][w];
                for(int i = 0 ; i < h ; i++){
                        for(int j = 0 ; j < w ; j++){
                                a[i][j] = Integer.parseInt(sc.next());
                        }
                }
                sc.close();
                int[][] q = new int[4][w * h];
                int yono = 0;
                for(int i = 0 ; i < w ; i++){
                        for(int j = 0 ; j < h - 1 ; j++){
                                if(a[j][i] % 2 != 0){
                                        q[0][yono] = j + 1;
                                        q[1][yono] = i + 1;
                                        q[2][yono] = j + 2;
                                        q[3][yono] = i + 1;
                                        yono++;
                                        a[j + 1][i]++;
                                }
                        }
                }
                for(int i = 0 ; i < w - 1 ; i++){
                        if(a[h - 1][i] % 2 != 0){
                                q[0][yono] = h;
                                q[1][yono] = i + 1;
                                q[2][yono] = h;
                                q[3][yono] = i + 2;
                                yono++;
                                a[h - 1][i + 1]++;
                        }
                }
                System.out.println(yono);
                for(int i = 0 ; i < yono ; i++){
                        ou.println(q[0][i] + " " + q[1][i] + " " + q[2][i] + " " + q[3][i]);
                }
                ou.flush();
        }
}

Measured memory_bytes: 68412
//おまじないc++
#include <iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
 
int main() {


int k,x;
  cin>>k>>x;
  if(500*k>=x){
    cout<<"Yes";}
  else{
    cout<<"No";
  }
}
  

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, is_debug):
		self.debug = is_debug
	def print(self, *arg):
		if self.debug:
			print("logger:", *arg)
	def plane(self, lst, sep=" ", space=0):
		if self.debug:
			longest = space
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					longest = max(longest, len(str(lst[i][j])))
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					print("logger:", " "*(longest-len(str(lst[i][j])))+str(lst[i][j]), end=sep)
				print()

def main():
	h, w = map(int, sys.stdin.readline().split())
	s = [list(sys.stdin.readline().rstrip())[::-1] for i in [0]*h][::-1]
	cost = [[0]*w for i in [0]*h]
	for y in range(h):
		for x in range(w):
			if y == 0 and x == 0:
				if s[y][x] == "#":
					cost[y][x] = 1
			elif y == 0:
				if s[y][x] == "#" and s[y][x-1] != "#":
					cost[y][x] = cost[y][x-1] + 1
				else:
					cost[y][x] = cost[y][x-1]
			elif x == 0:
				if s[y][x] == "#" and s[y-1][x] != "#":
					cost[y][x] = cost[y-1][x] + 1
				else:
					cost[y][x] = cost[y-1][x]
			else:
				if s[y][x] == "#" and s[y-1][x] != "#":
					cost[y][x] = cost[y-1][x] + 1
				else:
					cost[y][x] = cost[y-1][x]
				if s[y][x] == "#" and s[y][x-1] != "#":
					cost[y][x] = min(cost[y][x], cost[y][x-1] + 1)
				else:
					cost[y][x] = min(cost[y][x], cost[y][x-1])
	logger = Logger(0)
	logger.print(h, w)
	print(cost[h-1][w-1])

main()

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

using namespace std;

int n;
const int MAX_N = 200000;
int R[MAX_N];

int main() {

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> R[i];
	}
	int maxv = -2000000000;
	int minv = R[0];
	for (int j = 1; j < n; j++) {

		maxv = max(maxv, R[j] - minv);
		minv = min(minv, R[j]);

	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 3884
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i, a, b) for(register int i = a; i <= b; ++i)
using namespace std;
const int maxn = 3e2 + 5;
const int mod = 998244353;
int f[maxn][maxn][maxn], K, N, n, num[maxn], ans;
	//x     k     owe 
char s[maxn];
void Add(int &x, const int &a) {
	x = (x + a) >= mod ? x + a - mod : x + a;
}

int main() {
	scanf("%s%d", s, &K);
	N = strlen(s), n = 1;
	f[0][0][0] = 1;
	For(i, 0, N - 1) {
		if(s[i] == '0') ++n;
		if(s[i] == '1') ++num[n];
	}
	K = min(K, N);
	For(i, 0, n - 1) 
		For(j, 0, K)
			For(k, 0, j) {
				Add(f[i + 1][j][k], f[i][j][k]);
				// in
				For(l, 1, K - j)
					Add(f[i + 1][j + l][k + l], f[i][j][k]);
				// out
				For(l, 1, min(k, num[i + 1]))
					Add(f[i + 1][j][k - l], f[i][j][k]);
			}
	For(i, 0, K) Add(ans, f[n][i][0]);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 56304
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n):
  ans=ans+b[a[i]-1]
  if a[i]-1==a[i-1] and i>=1:
    ans=ans+c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;
import java.util.OptionalInt;

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

    static class A {
        private static final int[] DX = {-1, 0, 1, 0};
        private static final int[] DY = {0, -1, 0, 1};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            while (n != 0) {
                int[] x = new int[n], y = new int[n];
                for (int i = 1; i < n; i++) {
                    int t = in.nextInt(), d = in.nextInt();
                    x[i] = x[t] + DX[d];
                    y[i] = y[t] + DY[d];
                }
                int w = IntStream.of(x).max().getAsInt() - IntStream.of(x).min().getAsInt() + 1;
                int h = IntStream.of(y).max().getAsInt() - IntStream.of(y).min().getAsInt() + 1;
                out.println(w + " " + h);
                n = in.nextInt();
            }
        }

    }
}




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


void solve(long long N, long long R){
    if (N>=10) cout <<R  <<  endl;
    else cout << R + (100 * (10-N)) << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long R;
    scanf("%lld",&R);
    solve(N, R);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
int main(){
	int a,b,c,n,i;
std::cin>>n;
for(i=0;i<n;i++){
	std::cin>>a>>b>>c;
	if(a*a==b*b+c*c)std::cout<<"YES"<<std::endl;
	else if(b*b==a*a+c*c)std::cout<<"YES"<<std::endl;
	else if(c*c==a*a+b*b)std::cout<<"YES"<<std::endl;
	else std::cout<<"NO"<<std::endl;
	}
return 0;}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
void tree(vector<set<pair<int,int>>> &g,vector<vector<pair<int,int>>> &t,int p){
  while(!g.at(p).empty()){
    auto cp=*begin(g.at(p));
    t.at(p).push_back(cp);
    g.at(p).erase(cp);
    g.at(cp.first).erase(make_pair(p,cp.second));
    tree(g,t,cp.first);
  }
  return;
}
void color(vector<vector<pair<int,int>>> &t,vector<int> &c,int p,int d){
  c.at(p)=d;
  for(auto x:t.at(p))
    color(t,c,x.first,(d+x.second)%2);
  return;
}
int main(){
  int n;
  cin>>n;
  vector<set<pair<int,int>>> g(n);
  for(int i=0;i<n-1;i++){
    int u,v,w;
    cin>>u>>v>>w;
    g.at(u-1).insert(make_pair(v-1,w%2));
    g.at(v-1).insert(make_pair(u-1,w%2));
  }
  vector<vector<pair<int,int>>> t(n);
  tree(g,t,0);
  vector<int> c(n);
  color(t,c,0,0);
  for(int i=0;i<n;i++)
    cout<<c.at(i)<<endl;
}

Measured memory_bytes: 21120
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
int n,k,cnt[1<<17],ans=1e9,now,a[1<<17],f;
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<=k)now+=!cnt[a[i]];
		cnt[a[i]]++;
		while(f<i&&(a[f]>k||cnt[a[f]]>1))cnt[a[f++]]--;
		if(now==k)ans=min(ans,i-f+1);
	}
	cout<<(ans==1e9?0:ans)<<endl;
}



Measured memory_bytes: 3872
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int count = 1;
        int h[] = new int[n];

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

        int max = h[0];

        for (int i = 1; i < n; i++) {
            if (max <= h[i]) {
                count++;
                max = h[i];
            }
        }

        System.out.println(count);
	}
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e6 + 5 ;
char s[15] , t[15] , u[15] ;
int a , b ;
bool same()
{
	int len = strlen(s) ;
	if(len != strlen(u))  return 0 ;
	for(int i = 0 ; i < len ; i ++)
	  if(s[i] != u[i])  return 0 ;
	return 1 ;
}
int main()
{
	scanf("%s%s%d%d%s" , s , t , &a , &b , u) ;
	if(same())  printf("%d %d\n" , a - 1 , b) ;
	else  printf("%d %d\n" , a , b - 1) ;
	return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    
    vpair ls;
    ls.emplace_back(s[0], 1);
    srep(i, n, 1) {
        if (s[i-1] == s[i]) ls.back().se++;
        else ls.emplace_back(s[i], 1);
    }

    int ans = ls.size();

    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
ll n,s,sq;

bool check(ll b)
{
	ll ret=0,t=n;
	for(;t;t/=b) ret+=t%b;
	return (ret==s);
}

ll solve()
{
	if(s==n) return n+1;
	if(s>n) return -1;
	
	for(int i=2;i<=sq;i++)
		if(check(i)) return i;
	for(int i=sq;i;i--)
		if((n-s)%i==0&&check((n-s)/i+1)) return ((n-s)/i+1);
	return -1;
}

int main()
{
	scanf("%lld%lld",&n,&s);sq=sqrt(n);
	printf("%lld",solve());
	return 0;
}

Measured memory_bytes: 256
L = input().split(" ")
A = int(L[0])
B = int(L[1])
C = int(L[2])
count = 0

while True:
    if (A % 2 == 1) or (B % 2 == 1) or (C % 2 == 1):
        break
    else:
        a = A
        b = B
        c = C
        A = (b/2) + (c/2)
        B = (a/2) + (c/2)
        C = (a/2) + (b/2)
        count += 1
        if (a == A) and (b == B) and (c == C):
            count = -1
            break
print(count)


Measured memory_bytes: 3316
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] h = new int[n];

        for (int i=0; i<n; i++) h[i] = sc.nextInt();

        int ans = 0;

        int[] dp = new int[n];

        dp[1] = Math.abs(h[1]-h[0]);

        for (int i=2; i<n; i++){
            int a = Math.abs(h[i]-h[i-2])+dp[i-2];
            int b = Math.abs(h[i]-h[i-1])+dp[i-1];
            dp[i] = Math.min(a, b);
        }

        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 48400
#include <stdio.h>

int main()
{
	int n,ans=1,a,count[50001],i,opr=0;
	scanf("%d",&n);
	for(i=0;i<(n+1)/2;i++)
		count[i]=2;
	if(n%2==1)
	opr=1;
	if(opr==1)
	count[0]--;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		if(opr==0)
		{
			if(a%2==0)
			{
				printf("0");
			    return 0;
			 }
			 else
			 	count[(a-1)/2]--;
		}
		else
		{
			if(a%2==1)
			{
				printf("0");
			    return 0;
			 }
			 else
			 count[a/2]--;
		}
	}
	for(i=0;i<(n+1)/2;i++)
	{
		if(count[i]<0)
		{
			printf("0");
			    return 0;
		}
	}
	for(i=0;i<(n+1)/2;i++)
	{
		ans=ans*2;
		if(i==0&&opr==1)
		ans=ans/2;
		if(ans>=1000000007)
		ans-=1000000007;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] price = new int[n];
        int[][] c = new int[n][m];
        for(int i=0; i<n; i++) {
            price[i] = sc.nextInt();
            for(int j=0; j<m; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        sc.close();

        int ans = Integer.MAX_VALUE;
        for(int i=0; i<(1<<n); i++) {
            int cost = 0;
            int[] skill = new int[m];
            for(int j=0; j<n; j++) {
                if((i >> j & 1) == 1) {
                    cost += price[j];
                    for(int k=0; k<m; k++) {
                        skill[k] += c[j][k];
                    }
                }
            }
            boolean isQualified = true;
            for(int l=0; l<m; l++) {
                if(skill[l] < x) isQualified = false;
            }
            if(isQualified) ans = Math.min(ans, cost);
        }
        if(ans == Integer.MAX_VALUE) System.out.println("-1");
        else System.out.println(ans);
    }
}


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

// DP+bit masking

// when N<=21 most of the time it is bitmasking

const int mod = 1e9+7;

void solve() {
	int n;
	cin >> n;
	
	int a[n][n]={};
	
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin >> a[i][j];
	
	vector<int> dp(1<<n); // O(2^n)
	dp[0]=1; // there is 1 way to match with no one.
	
	// Here mask is refer as set of womens
		
	// use mask for making set of women because 1 women belong to one man
	for(int mask=0; mask < (1<<n)-1; mask++){
		
		int man = __builtin_popcount(mask);
		
		// loop to all women
		for(int women=0; women<n; women++){
			
			// if there is compatibility man and women and women is not belong to other group man
			if(a[man][women] && !(mask & (1<<women))) {
				
				// set that women bit
				int mask2 = mask ^ (1<<women);
				
				// add new mask means set of women with old mask.
				dp[mask2]+=dp[mask];
				
				if(dp[mask2] >= mod)
					dp[mask2] -= mod;
				
			}
		}
	}
			
	cout << dp[(1<<n)-1] << "\n";
	
}

int main(){
	solve();
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  vector<int> a;
  vector<int> z;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'A') { a.push_back(i); };
    if(S[i] == 'Z') { z.push_back(i); };
  }
  sort(a.begin(), a.end());
  sort(z.rbegin(), z.rend());
  int ans = z[0] - a[0] + 1;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1428
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N;
ll a[20][20];

ll score[(1<<16)];
ll dp[(1<<16)];
const ll INF=1e18;

ll solve(int state){
    if(dp[state]!=-INF) return dp[state];

    ll res=score[state];
    
    for(int i=(state-1)&state;i>0;i=(i-1)&state){
        ll tmp=solve(i);
        tmp+=solve(state^i);
        res=max(res,tmp);
    }

    return dp[state]=res;
}

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

  for(int i=0;i<(1<<N);i++){
      vector<int> v;
      for(int j=0;j<N;j++){
          if((1<<j)&i) v.push_back(j);
      }

      ll res=0;
      for(int j=0;j<v.size();j++){
          for(int k=j+1;k<v.size();k++){
              res+=a[v[j]][v[k]];
          }
      }
      score[i]=max(res,0ll);
      dp[i]=-INF;
  }

  dp[0]=0;
  cout<<solve((1<<N)-1)<<endl;

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b)                                                           \
  for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i) // ROF(i,n,0)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで降順
#define SUM(a) accumulate(all(a), int(0))
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> T add(const T &a, const T &b) { return (a + b) % mod; }

signed main() {
  int n, k;
  cin >> n >> k;
  vi a(n + 1);
  rep(i, n) cin >> a[i];

  rep(_, k) {
    vi b(n + 1);
    rep(i, n) {
      b[max(0ll, i - a[i])]++;
      b[min(n, i + a[i] + 1)]--;
    }
    dump(b);
    FOR(i, 1, n) { b[i] += b[i - 1]; }
    a = move(b);
    dump(a);

    bool alln = true;
    rep(i, n) {
      if (a[i] != n)
        alln = false;
    }
    if (alln)
      break;
  }
  cout << a[0];
  FOR(i, 1, n) cout << " " << a[i];
  cout << endl;
}

Measured memory_bytes: 6628
n=int(input())
l=list(map(int,input().split()))

def yama(l):
    r=0
    zf=0
    a=[0]*(len(l)+2)
    for i in range(1,len(l)+1):
        a[i]=l[i-1]
    for i in range(0,len(l)+1):
        if a[i]>0 and zf==1:
            r+=1
            zf=0
        elif a[i]<=0:
            zf=1
    return r
ans=0
while yama(l)>0:
    ans+=yama(l)
    for i in range(n):
        l[i]-=1
   
print(ans)
    
            

Measured memory_bytes: 3064
N = int(input())
S = list(input())
Q = int(input())
query = [input().split() for _ in range(Q)]

bit = [[0 for _ in range(26)] for _ in range(N + 1)]

def bit_add(i, s, x):
    j = ord(s) - ord("a")
    while i <= N:
        bit[i][j] += x
        i += i & - i
        
def bit_sum(i):
    s = [0] * 26
    while i:
        for j in range(26):
            s[j] += bit[i][j]
        i -= i & -i
    return s
  
for i in range(1, N + 1):
    s = S[i - 1]
    bit_add(i, s, 1)

for x, y, z in query:
    if x == "1":
        y = int(y)
        bit_add(y, S[y - 1], -1)
        bit_add(y, z, 1)
        S[y - 1] = z
    if x == "2":
        answer = 0
        y, z = int(y) - 1, int(z)
        sum_y = bit_sum(y)
        sum_z = bit_sum(z)
        for i in range(26):
            if sum_z[i] - sum_y[i] > 0:
                answer += 1
        print(answer)

Measured memory_bytes: 245916
h,w=map(int,input().split())
a=[input() for _ in range(h)]
d=dict()
for i in range(h):
    for j in range(w):
        if a[i][j] not in d:
            d[a[i][j]]=1
        else:
            d[a[i][j]]+=1
num=[]
for c in d:
    num.append(d[c])
num.sort(reverse=True)
ans=[[0]*w for _ in range(h)]
lis=[]
for i in range(h):
    for j in range(w):
        if ans[i][j]==0:
            if h-1-i==i and w-j-1!=j:
                ans[i][j]=1
                ans[i][w-1-j]=1
                lis.append(2)
            elif h-i-1!=i and w-j-1==j:
                ans[i][j]=1
                ans[h-1-i][j]=1
                lis.append(2)
            elif h-1-i==i and w-j-1==j:
                ans[i][j]=1
                lis.append(1)
            else:
                ans[i][j]=1
                ans[i][w-1-j]=1
                ans[h-1-i][j]=1
                ans[h-1-i][w-1-j]=1
                lis.append(4)
lis.sort(reverse=True)
for i in range(len(num)):
    for j in range(len(lis)):
        if num[i]>=lis[j]:
            num[i]-=lis[j]
            lis[j]=0
if sum(num)!=0 or sum(lis)!=0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9240
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(void){
	int r,g,b,n,i,j,k,count,rr,g2,b2;
  	cin >> r >> g >> b >> n;
  	if(g>r){
    	swap(r,g);
    }
  	if(b>g){
    	swap(b,g);
    }
  	count = 0;
  	g2 = g;
  	b2 = b;
  	rr = g2 % b2;
  	while(rr!=0){
      g2 = b2;
      b2 = rr;
      rr = g2 % b2;
  	}
  	for(i=0;r*i<=n;i++){
           if(n< r*i){
                break; 
           }else if(n== r*i){
                count += 1;
                break;
           }
      		if((n-r*i)%b2!=0){
            	continue;
            }
            for(j=0;r*i+g*j<=n;j++){
                if(n== r*i+g*j){
                	count += 1;
                    break;
                }else if((n- (r*i+g*j))%b==0){
                	count += 1;
                }
          	}
    }
  	cout << count;
  	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
struct LS {
	ll num, cost;
	//値、遅延配列
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m;
string s, t;

signed main() {
	cin >> n >> m;
	cin >> s >> t;
	if (n > m) {
		swap(n, m);
		swap(s, t);
	}
	bool l = 1;
	int k = n * m / gcm(n, m);
	if (gcm(n, m) == 1) {
		if (s[0] == t[0]) {
			cout << k << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if ((double)i*m / n == (int)i*m / n) {
				if (s[i] != t[i*m / n]) {
					l = 0;
				}
			}
		}
		if (l) {
			cout << k << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 56;

//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

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


Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
using namespace std;
//科赫曲线
//根号三
#define SD3 1.732050808
#define max 4100

struct Node
{

	double x;
	double y;
	void set(double a, double  b)
	{
		x = a;
		y = b;
	}
	Node &operator=(Node rex)
	{
		rex;
		1 + 1;
		this->x = rex.x;
		this->y = rex.y;
		return  *this;
	}

};
inline Node P1(Node &A,Node &B)
{
	Node tmp;
	tmp.x = 1.0 / 3 * A.x + 2.0 / 3 * B.x;
	tmp.y = 1.0 / 3 * A.y + 2.0 / 3 * B.y;
	return tmp;
}
inline Node P3(Node &A, Node &B)
{
	Node tmp;
	tmp.x = 1.0 / 3 * B.x + 2.0 / 3 * A.x;
	tmp.y = 1.0 / 3 * B.y + 2.0 / 3 * A.y;
	return tmp;
}
inline Node P2(Node &tmpA,Node &tmpB) 
{
	Node tmp;
	Node A = P3(tmpA, tmpB);
	Node B = P1(tmpA, tmpB);
	tmp.x = (B.x - A.x)*0.5-(B.y-A.y)*SD3*0.5+A.x;
	tmp.y = (B.x - A.x)*SD3*0.5 + (B.y - A.y)*0.5 + A.y;
	return tmp;
}
Node mark1[max];
Node mark2[max];
int main() 
{
	//cout << fixed<<setprecision(9)<<sqrt(3);
	//cout << endl << pow(4, 6);
	Node work;
	work.set(0, 0);
	mark2[0] = work;
	mark1[0] = work;
	work.set(100, 0);
	mark2[1] = work;
	mark1[1] = work;
	double tmp;
	int len1 = 2;
	int len2 = 0;
	int h;
	cin >> h;
	if (!h) 
	{
		cout <<fixed << setprecision(9)<< 0.00000000 <<' '<< 0.00000000 << endl;
		cout << fixed << setprecision(9)<<100.00000000 << ' ' << 0.00000000 << endl;
		return 0;
	}
	for (int i = 0; i < h; ++i) 
	{
	if(i%2)
	{
		tmp = (mark1[1].x - mark1[0].x)*0.25;
		len1 = (len2 - 1) * 4 + 1;
		for (int k = 0; k < len2 - 1; ++k)
		{
			if (4 + k * 4 >= max) 
			{
				mark1[0]=work;
			}
			mark1[1 + k * 4] = P3(mark2[k], mark2[k + 1]);
			mark1[2 + k * 4] = P2(mark2[k], mark2[k + 1]);
			mark1[3 + k * 4] = P1(mark2[k], mark2[k + 1]);
			mark1[4 + k * 4] = mark2[k + 1];
		}
		if(i==h-1)
		for (int k = 0; k < len1; ++k)
			cout << fixed << setprecision(9)<< mark1[k].x << ' ' << mark1[k].y << endl;
		//cout << "*******************************" << endl << endl << endl;
	}
	else 
	{
		tmp = (mark1[1].x - mark1[0].x)*0.25;
		len2 = (len1 - 1) * 4 + 1;
		for (int k = 0; k < len1-1; ++k) 
		{
			if (4 + k * 4 >= max)
			{
				mark1[0] = work;
			}
			mark2[1 + k * 4] = P3(mark1[k],mark1[k+1]);
			mark2[2 + k * 4] = P2(mark1[k], mark1[k + 1]);
			mark2[3 + k * 4] = P1(mark1[k], mark1[k + 1]);
			mark2[4 + k * 4] = mark1[k + 1];
		}
		if (i == h-1)
		for (int k = 0; k < len2; ++k)
			cout << fixed << setprecision(9)<< mark2[k].x<<' '<<mark2[k].y << endl;
		//cout << "*******************************" << endl << endl << endl;

	}
	}

	return 0;
}


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

// ユークリッドの互除法参照
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0 ; i < n ; ++i) {
        cin >> a[i];
    }
    // 最大公約数を求める
    int dst = a[0];
    for(int i = 1 ; i < n ; ++i) {
        // cout << "gcd\tdst:" << dst << "\ta[" << i << "]:" << a[i] << endl;
        dst = gcd(dst, a[i]);
    }
    cout << dst << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;

int main(){
  string x; cin >> x;
  int N = x.length();
  
  int m = 0;
  int t=0;
  int s=0;
  for(int i=0;i<N;i++){
    if(x[i] == 'S'){
      s++;
    }
    else if(s > 0){
      s--;
    }
    else{
      t++;
      m = max(m, t);
    }
  }
  cout << m*2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(void){
    int a,b;
    int c[100][100];
    int d[100];
    int flg[101]={0};
    int e=0;
    scanf("%d %d",&a,&b);
    for(int i=0;i<b;i++){
        scanf("%d",&d[i]);
        for(int j=0;j<d[i];j++){
            scanf("%d",&c[i][j]);
            flg[c[i][j]]=1;
            
        }
    }
    for(int i=1;i<=a;i++){
        if(flg[i]==0){
            e++;
        }
    }
    printf("%d",e);
    return 0;
}

Measured memory_bytes: 1720
import java.util.*;

public class Main {
    private static final long INF = 1145143643641919810L;
    private static final long INIT = 1000000000000000L;

    private class City {
        long cost = INF;
        boolean fix = false;
        List<Road> roads = new ArrayList<>();
    }

    private class Road {
        int src, dst, cost;

        public Road(int src, int dst, int cost) {
            this.src = src;
            this.dst = dst;
            this.cost = cost;
        }
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int s = sc.nextInt();
        int t = sc.nextInt();

        City city[] = new City[n];
        City scity[] = new City[n];
        for (int i = 0; i < n; i++) {
            city[i] = new City();
            scity[i] = new City();
        }

        int u, v, a, b;
        for (int i = 0; i < m; i++) {
            u = sc.nextInt() - 1;
            v = sc.nextInt() - 1;
            a = sc.nextInt();
            b = sc.nextInt();
            city[u].roads.add(new Road(u, v, a));
            city[v].roads.add(new Road(v, u, a));
            scity[u].roads.add(new Road(u, v, b));
            scity[v].roads.add(new Road(v, u, b));
        }

        dij(s - 1, n, city);
        dij(t - 1, n, scity);

        long ans[] = new long[n];
        Arrays.fill(ans, INIT + 1);
        ans[n - 1] = city[n - 1].cost + scity[n - 1].cost;
        for (int i = n - 2; i >= 0; i--) {
            ans[i] = Math.min(ans[i + 1], city[i].cost + scity[i].cost);
        }

        for (int y = 0; y < n; y++) {
            System.out.println(INIT - ans[y]);
        }
    }

    private void dij(int start, int n, City city[]) {
        Queue<City> queue = new PriorityQueue<>((o1, o2) -> Long.compare(o1.cost, o2.cost));

        city[start].cost = 0;
        queue.add(city[start]);
        while (!queue.isEmpty()) {
            City c = queue.poll();
            if (c.fix) {
                continue;
            }

            c.fix = true;
            for (Iterator<Road> ite = c.roads.iterator(); ite.hasNext();) {
                Road r = ite.next();
                if (city[r.dst].fix) {
                    ite.remove();
                    continue;
                }

                city[r.dst].cost = Math.min(c.cost + r.cost, city[r.dst].cost);
                queue.add(city[r.dst]);
            }
        }
    }

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


Measured memory_bytes: 203280
from collections import deque

k = int(input())

todo = deque(list(map(str, range(1, 10))))
count = 0
while todo:
    num = todo.popleft()
    count += 1
    if count == k:
        print(num)
        exit()

    base = int(num[-1])
    n1 = base - 1
    if n1 != -1:
        todo.append(num + str(n1))
    n2 = base
    todo.append(num + str(n2))

    n3 = base + 1
    if n3 != 10:
        todo.append(num + str(n3))



Measured memory_bytes: 17012
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <string.h>

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

#define maxN 500000
#define INF 1e18

vector<edgeTo> g[maxN];
priority_queue<distTo, vector<distTo>, greater<distTo> > q;
int n, m, s;
ll d[maxN]; //d[u]: do dai dd ngan nhat tu s den u

void ReadGraph()
{
    int u, v, c;
    cin>>n>>m>>s;
    for (int i = 0; i < m; ++i)
    {
        cin>>u>>v>>c;
        g[u].push_back(edgeTo(v, c));
    }
}

void Init()
{
    for (int u = 0; u < n; ++u)
        d[u] = INF;
    d[s] = 0;
    q.push(distTo(s, d[s]));
}

void Solve()
{
    Init();
    while (!q.empty())
    {
        int u = (int)q.top().first; ll du = (ll)q.top().second;
        q.pop();

        if (du != d[u]) continue;

        for (int i = 0; i < g[u].size(); ++i)
        {
            int v = (int)g[u][i].first, c = (int)g[u][i].second;
            if (d[v] > d[u] + c)
            {
                d[v] = d[u] + c;
                q.push(distTo(v, d[v]));
            }
        }
    }
}

void WriteANS()
{
    for (int u = 0; u < n; ++u)
    {
        if (d[u] == INF)
            cout<<"INF\n";
        else cout<<d[u]<<"\n";
    }
}

int main()
{
    ReadGraph();
    Solve();
    WriteANS();
    return 0;
}

Measured memory_bytes: 38212
N,M=map(int, input().split())
ACList=[0]*(N+1)
ansAC=0
ansP=0
for i in range(M):
	p,S=map(str, input().split())
	p=int(p)
	if S=="AC" and ACList[p]!=-1:
		ansAC+=1
		ansP+=ACList[p]
		ACList[p]=-1
	elif S=="WA" and ACList[p]!=-1:
		ACList[p]+=1
	else:
		continue

print(ansAC,ansP)

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	LL n;
	cin >> n;

	vector<LL> a(n);

	LD sm = 0;
	for (auto &e : a) {
		cin >> e;
		if (e == 0) {
			cout << "0\n";
			return 0;
		}
		sm += log10(e);
	}

	if (sm > LD(19)) {
		cout << "-1\n";
	}
	else {
		LL p = 1;
		for (auto e : a) {
			p *= e;
		}
		if (p <= 1000000000000000000) {
			cout << p << "\n";
		}
		else {
			cout << "-1\n";
		}
	}

}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    string S;
    cin >> S;
    lint r = 0;
    lint g = 0;
    lint b = 0;
    REP(i, N) {
        if(S[i] == 'R') r++;
        if(S[i] == 'G') g++;
        if(S[i] == 'B') b++;
    }
    lint ans = r * g * b;
    REP(i, N) {
        for(int j=i+1; 2*j-i < N; j++) {
            if(S[i] != S[j] && S[i] != S[2*j-i] && S[j] != S[2*j-i]) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = 0, max = 0;
		int N = sc.nextInt();
		String s = sc.next();
		for(int i = 0;i < N;i ++) {
			char c = s.charAt(i);
			if(c == 'I') x ++;
			else x --;
			if(max < x)max = x;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 23764
#include <iostream>

int main(){

	char s[3];

	std::cin >> s;

	int count[3] = {};
	for(int i = 0; i < 3; ++i){
		++count[s[i] - 'a'];
	}

	for(int i = 0; i < 3; ++i){
		if(count[i] != 1){
			std::cout << "No" << std::endl;
			return 0;
		}
	}

	std::cout << "Yes" << std::endl;

	return 0;
}


Measured memory_bytes: 764
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int a, b, c, d, k;
	cin >> a >> b >> c >> d >> k;
	int ans = (c - a) * 60 + d - b - k;
	cout << ans << endl;
	return 0;
}


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

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


    if (n%2) {
        cout << (n*(n-1))/2 - n/2 << "\n";
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                if (i+j==n) continue;
                cout << i << " " << j << "\n";
            }
        }

    } else {
        cout << n*(n-2)/2 << "\n";
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                if (i+j==n+1) continue;
                cout << i << " " << j << "\n";
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

while True:
	gem_count = int(input())
	if gem_count <= 0:
		break
	gems = []
	for i in range(gem_count):
		x, y = input().split()
		gems.append([ int(x), int(y) ])

	pos = [10,10]
	com_count = int(input())
	for i in range(com_count):
		d, v = input().split()
		for j in range(0,int(v)):
			if d == 'E':
				pos[0] += 1
			elif d == 'W':
				pos[0] -= 1
			elif d == 'N':
				pos[1] += 1
			elif d == 'S':
				pos[1] -= 1
			
			for k in range(len(gems)):
				if pos == gems[k]:
					gems.pop(k)
					break
	
	if len(gems) == 0:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 7708
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const ll MOD = 100000;
const int MAXN = 100010;
ll pos[MAXN];

int main(void) {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n-1; i++) {
        ll diff;
        cin >> diff;
        pos[i+1] = pos[i] + diff;
    }
    int cur = 1;
    ll ans = 0;
    while (m--) {
        int a;
        cin >> a;
        ans = (ans + abs(pos[cur+a] - pos[cur])) % MOD;
        cur += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		long x=sc.nextLong();
		long y=sc.nextLong();
		long cnt=1;
		while(true) {
			x *= 2;
			if(x>y) break;
			cnt++;
		}
		System.out.println(cnt);
		sc.close();
	}

}


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

template <typename T> void rsort(T beg, T end)
{
    sort(beg, end);
    reverse(beg, end);
}

int main() {
    int x, y, a, b, c;
    scanf(" %d%d%d%d%d", &x, &y, &a, &b, &c);
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; i++)
        scanf(" %d", &p[i]);
    for (int i = 0; i < b; i++)
        scanf(" %d", &q[i]);
    for (int i = 0; i < c; i++)
        scanf(" %d", &r[i]);

    rsort(begin(p), end(p));
    rsort(begin(q), end(q));
    rsort(begin(r), end(r));

    int64_t tot = 0;

    for (int i = 0; i < c; i++)
        if (x > 0 && y > 0) {
            if (r[i] <= min(p[x - 1], q[y - 1])) break;
            tot += r[i];
            if (p[x - 1] < q[y - 1]) --x;
            else --y;
        } else if (x > 0) {
            if (r[i] <= p[x - 1]) break;
            tot += r[i];
            --x;
        } else {
            if (r[i] <= q[y - 1]) break;
            tot += r[i];
            --y;
        }

    for (int i = 0; i < x; i++) tot += p[i];
    for (int i = 0; i < y; i++) tot += q[i];
    printf("%lld\n", tot);
}


Measured memory_bytes: 1408
from collections import deque
def main():
    X, Y, A, B, C = map(int, input().split())
    
    apple = []
    red = sorted(map(int, input().split()), reverse=True)[:X]
    green = sorted(map(int, input().split()), reverse=True)[:Y]
    nocolor = list(map(int, input().split()))
    apple.extend(red)
    apple.extend(green)
    apple.extend(nocolor)
    
    print(sum(sorted(apple, reverse=True)[:X+Y]))      
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 106752
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vi s(n);
  int sum=0;
  rep(i, n) {
    cin >> s[i];
    sum += s[i];
  }
  if (sum % 10 != 0) {
    cout << sum << endl;
    return 0;
  }
  sort(all(s));
  rep(i, n) {
    if (s[i] % 10 != 0) {
      cout << sum - s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


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

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 long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) { // 重さの合計がsum_w以下に収まるかどうか判定
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl; // N+1番目のM+1番目に答えが格納される
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

bool is_prime(int n) {
    if (n <= 1) return false;

    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }

    return true;
}
 
int main() {
    int x;
    cin >> x;

    while (!is_prime(x)) {
        x++;
    }

    cout << x << endl;

    return 0;
}


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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n , x;
	cin>>n>>x ;
	for(int i = 0 ; i <= n ; ++i)
	{
		for(int j = 0 ; j <= n-i ; ++j)
		{
			int k = n-i-j ;
			if(i*10000+j*5000+k*1000 == x)
				return cout<<i<<" "<<j<<" "<<k<<"\n" , 0 ;
		}
	}
	return cout<<-1<<" "<<-1<<" "<<-1<<"\n" , 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL dp[100003][101];
LL weight[102],value[102];
int main()
{
    fastinput;
    LL n,i,j,k,t,temp,capacity;
    cin>>n>>capacity;
    for(i=1;i<=n;i++)
    {
        cin>>weight[i]>>value[i];
    }
    
    for(i=0;i<100003;i++)
    {
        for(j=0;j<=100;j++)
        {
            dp[i][j]=100000000000000000;
        }
    }
    //value , items 
    //state=min weight possible with value j and among i items
    dp[0][0]=0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<100003;j++)
        {            
            dp[j][i]=min(dp[j][i],dp[j][i-1]);
            if(j+value[i]<100003)
            {
                dp[j+value[i]][i]=min( dp[j+value[i]][i],dp[j][i-1]+weight[i]);
            }
        }
    }
    LL max_now=-1;

    for(i=0;i<100003;i++)
    {
        if(dp[i][n]<=capacity)
        {
            max_now=i;
        }
    }
    cout<<max_now<<endl;
    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <cstring>

class Queue {
public:
	int* data;
	int size;
	int memory;
	int top; //先頭要素の位置
	Queue() {
		size = 0;
		memory = 1;
		top = 0;
		data = new int[memory];
	}
	void enqueue(int x) {
		size++;
		if (size > memory) {
			// メモリ拡張
			memory *= 2;
			//std::cout << "upsizing: " << memory << std::endl;
			int* tmp = new int[memory];
			memcpy(tmp, data + top, (memory / 2) * sizeof(int));
			memcpy(tmp + size - top - 1, data, top * sizeof(int));
			top = 0;
			free(data);
			data = tmp;
		}
		data[(top + size - 1) % memory] = x;
	}
	void front() {
		if (size == 0) return;
		std::cout << data[top] << std::endl;
	}
	void dequeue() {
		if (size == 0) return;
		data[top] = 0;
		size--;
		if (size * 2 <= memory && memory > 1) {
			// メモリ縮小
			memory /= 2;
			//std::cout << "down sizing: " << memory << std::endl;
			int* tmp = new int[memory];
			if (top < memory){
			    memcpy(tmp, data + top + 1, size * sizeof(int));
			}
			else {
			    memcpy(tmp, data + top + 1, (memory * 2 - top - 1) * sizeof(int));
			    memcpy(tmp + memory * 2 - top - 1, data, (size - memory * 2 + top + 1) * sizeof(int));
			}
			top = 0;
			free(data);
			data = tmp;
		}
		else {
			top = (top + 1) % memory;
		}
	}
};

int main() {
	int n, q;
	std::cin >> n >> q;
	Queue* que = new Queue[n];
	while (q--) {
		int com, t;
		std::cin >> com >> t;
		if (com == 0) {
			int x;
			std::cin >> x;
			que[t].enqueue(x);
		}
		if (com == 1) {
			que[t].front();
		}
		if (com == 2) {
			que[t].dequeue();
		}
	}
}


Measured memory_bytes: 4112
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long n,d;
  cin>>n>>d;
  int cnt=0;
  while(n--){
    long long x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   cout << 3*r*r << endl;


   return 0;
}

Measured memory_bytes: 256
s=input()
a=[int(c) for c in s]
n=0
c=0
d=len(a)
while n<=d:
    b=n%2
    if a[n]==0 and b==1:
        c=c+1
    if a[n]==1 and b==0:
        c=c+1
    if n+1==d:
        break
    n=n+1
if c<= d/2:
    print(c)
else:
    print(d-c)

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

int main() {

	int  a, b, c;
	cin >> a >> b >> c;
	string ans = "No";

	if(a+b == c || a+c == b || b+c == a)
		ans = "Yes";

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256