akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());
    
    System.out.print(X - K + 1);
    for (int i = X - K + 2; i < X + K; i++) {
      System.out.print(" " + i);
    }
  }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

int main()
{
	string s;
	cin >> s;
	
	int n=s.length();
	int ans=n;
	for(int i=0;i<n-1;i++)
	{
		if(s[i]!=s[i+1])
			ans=min(ans,max(i+1,n-i-1));
	}
	cout << ans;

}


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[][] cnt = new int[n][26];

        for (int i = 0; i < n; i++) {
            cnt[i][s[i] - 'a']++;

            if (i > 0) {
                for (int j = 0; j < 26; j++)
                    cnt[i][j] += cnt[i - 1][j];
            }
        }

        int max = 0;
        for (int i = 0; i < n-1; i++) {
            int tmp = 0;
            for (int j = 0; j < 26; j++) {
                if (cnt[i][j] > 0 && cnt[i][j] < cnt[n-1][j])
                    tmp++;
            }

            max = Math.max(tmp, max);
        }

        System.out.println(max);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int f[maxn],vis[maxn],fa[maxn],d[maxn],u,v,x,y,a[maxn],cnt,n,m;
vector<int> G[maxn];ll ans;
void dfs(int u){
	f[u]=(d[u]&1)?1:-1;vis[u]=1;
	for(int v:G[u]) if(v^fa[u]){
		if(vis[v]){x=u,y=v;continue;}
		fa[v]=u;d[v]=d[u]+1;dfs(v);
		f[u]+=f[v];
	}
}
int lca(int u,int v){
	if(d[u]<d[v]) swap(u,v);
	while(d[u]^d[v]) u=fa[u];
	while(u^v) u=fa[u],v=fa[v];
	return u;
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,m) scanf("%d%d",&u,&v),G[u].pb(v),G[v].pb(u);
	dfs(1);
	if(m==n-1){
		if(f[1]) return puts("-1"),0;
		rep(i,1,n) ans+=abs(f[i]);
	}
	else if(!((d[x]^d[y])&1)){
		if(f[1]&1) return puts("-1"),0;
		int fxk=-(f[1]>>1);ans+=abs(fxk);
		for(int u=x;u;u=fa[u]) f[u]+=fxk;
		for(int u=y;u;u=fa[u]) f[u]+=fxk;
		rep(i,1,n) ans+=abs(f[i]);
	}
	else{
		if(f[1]) return puts("-1"),0;
		int t=lca(x,y);
		for(int u=x;u^t;u=fa[u]) a[++cnt]=f[u],vis[u]=0;
		for(int u=y;u^t;u=fa[u]) a[++cnt]=-f[u],vis[u]=0;a[++cnt]=0;
		sort(a+1,a+cnt+1);int fxk=a[cnt+1>>1];
		rep(i,1,n) if(vis[i]) ans+=abs(f[i]);
		rep(i,1,cnt) ans+=abs(a[i]-fxk);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

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

    int n, k;
    char s[100];
    cin >> n >> k >> s;

    s[k - 1] = tolower(s[k - 1]);

    cout << s << "\n";

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; string s;
    cin >> n >> s;
    
    const int mod = 1e9+7;
    int dp[n+1][n+2];

    memset(dp[1], 0, sizeof dp[1]);
    dp[1][1] = 1;

    FOR(x,2,n) {
        int i = n-x;
        memset(dp[x], 0, sizeof dp[x]); // important to set base case

        if (s[i] == '<') {
            RFOR(y,x,1) {
                dp[x][y] = 0;
                //FOR(z,y+1,x)
                //    dp[x][y] = (dp[x][y] + dp[x-1][z-1]) % mod;
                dp[x][y] = (dp[x-1][y] + dp[x][y+1]) % mod;
            }
        } else {
            FOR(y,1,x) {
                dp[x][y] = 0;
                //FOR(z,1,y-1)
                //    dp[x][y] = (dp[x][y] + dp[x-1][z]) % mod;
                dp[x][y] = (dp[x-1][y-1] + dp[x][y-1]) % mod;
                //assert(dp[x][y] == ((dp[x-1][y-1] + dp[x][y-1])%mod));
                //cout << dp[x][y] << " vs " << (dp[x-1][y-1]+dp[x][y-1])%mod << endl;
            }
        }
    }

    int ans = 0;
    FOR(y,1,n) ans = (ans + dp[n][y]) % mod;
    cout << ans << '\n';
}



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

int euclid( int a, int b )
{
    int temp;

    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return euclid( b, a % b );
}

int main(){
  int k, num_1st, num_2nd, num_3rd;
  int gcd_temp=0, gcd=0, sum=0;

  cin >> k;

  for(num_1st=1; num_1st<k+1; num_1st++){
	for(num_2nd=1; num_2nd<k+1; num_2nd++){
        for(num_3rd=1; num_3rd<k+1; num_3rd++){
            gcd_temp = euclid(num_1st, num_2nd);
            sum += euclid(gcd_temp, num_3rd);
        }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3164
I=lambda:map(int,input().split())
N,M=I()
sw=[]
for _ in [0]*M:
    _,*s=I()
    sw+=[s]
*p,=I()
r=0
for i in range(2**N):
    k=str(bin(i))[2:].rjust(N,"0")
    f=True
    for j in range(M):
        t=0
        for s in sw[j]:
            if k[s-1]=="1":t+=1
        if t%2!=p[j]:f=False;break
    if f:r+=1
print(r)

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
bool myf(pair<int,string> &x, pair<int,string> &y){
    if(x.first==y.first) return x.second<y.second;
    return x.first>y.first;
}
int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    map<string,int> memo;
    for(int i=0;i<n;i++){
        string x; cin>>x;
        memo[x]++;
    }
    int mx=0;
    for(auto xx:memo){
        mx=max(mx,xx.second);
    }
    //int mn=0; string ans="";
    vector<pair<int,string>> ans;
    for(auto xx:memo){
        if(xx.second==mx) ans.push_back({xx.second,xx.first});
    }
    //cout<<ans;
    sort(ans.begin(),ans.end(),myf);
    for(auto xx:ans){
        cout<<xx.second<<'\n';
    }
    return 0;
}

Measured memory_bytes: 28272
#include <iostream>
#define rep(i,q) for(int i = 0; q > i; i++)
using namespace std; 
int N;
int A1[101];
int A2[101];
int mx,mx2,alle;

void input() { 
  cin >> N;
  rep(i,N) cin >> A1[i];
  rep(i,N) cin >> A2[i];
} 
void compute() { 
  alle = A1[0];
  for(int i = 1; N > i; i++){
    alle += A2[i];
  }
   mx = A2[0];
   mx2 = A2[0];
  rep(i,N){
    mx += A1[i+1] - A2[i];
    if(mx2 < mx){
      mx2 = mx;
    }
  }
} 
void output() { 
  cout << mx2 + alle << endl;
} 
int main() { 
    input(); 
    compute(); 
    output(); 
    return 0; 
} 

Measured memory_bytes: 256
n=int(input())
a=[0]*n
for i in range(n):
  a[i]=int(input())
a=sorted(a)
S=sum(a)
if S%10!=0:
  print(S)
  exit()
else:
  for i in range(n):
    if (S-a[i])%10:
      print(S-a[i])
      exit()
print(0)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class A {
	int n, a;
public:
	A()
	{
		cin >> n >> a;
	}
	void solve()
	{
		if (n % 500 <= a)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
		
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left as lower_bound
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N, W = MI()
    v = [0] * N
    w = [0] * N
    dp = [0] * (W + 1)

    for i in range(N):
        v[i], w[i] = MI()

    for i in range(N):
        dp_next = [0] * (W + 1)
        for j in range(W):
            dp_next[j] = max(dp[j], dp_next[j])
            if j+w[i] <= W:
                dp_next[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i])
        dp = dp_next
        # print(dp)

    print(dp[W])


if __name__ == '__main__':
    main()



Measured memory_bytes: 7468
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(40, -1, -1):
    j = 2 ** i
    count = len([1 for temp in a if temp&j > 0])
    if count < n - count and j <= k:
        k -= j
        count = n - count
    ans += j * count
print(ans)




Measured memory_bytes: 14620
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  a=pI(readline())
  b=pI(readline())
  c=pI(readline())
  x=pI(readline())
  ans=0
  for i=0:a
    for j=0:b
      for k=0:c
        if 500*i+100*j+50*k==x
          ans+=1
        end
      end
    end
  end
  println(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 163532
#include<bits/stdc++.h>
using namespace std;
int d[1000], mmax, used[1000][1000];
int main(){
  int n; scanf("%d", &n);
  string s;
  cin >> s;
  for(int i = 0; i < n-1; i++){
    //split
    int tmp=0;
    for(int j = i; j>=0; j--){
      
      char find_s= s[j];
      if(used[i][find_s]==1) continue;
      else used[i][find_s] = 1;
      for(int k = i+1; k < n; k++){
        if(s[k] == find_s){
          tmp++;
          break;
        }
      }
    }
    mmax= max(mmax, tmp);
  }
  printf("%d\n", mmax);
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(){

  int a[40],i,j,n,ans,h[5]={5,7,5,7,7};
  char str[10];

  while(scanf("%d",&n),n){

    for(i=0;i<n;i++)a[i]=0;

    for(i=0;i<n;i++){
      scanf("%s",str);
      a[i] = strlen(str);
      // printf("%d\n",a[i]);
    }

    
    int sum,count;
    ans=-1;
    
    for(i=0;i<n;i++){
      sum=0;
      count=0;
      for(j=i;j<n;j++){
	sum+=a[j];
	//printf("%d\n",sum);
	if(sum==h[count]){
	  count++;
	  sum=0;
	}else if(sum>h[count]){
	  break;
	}
	if(count==5){
	  ans=i;
	  break;
	}
      }
      if(ans != -1)break;
    }
    
     printf("%d\n",ans+1);
    
  }
  
  return 0;
  
}

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

  int n,ans=0;
  cin>>n;
  int a[100001];
  a[0]=0;

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


  for(int i=1;i<=n;i++){
  
    if((abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))>=abs(a[i+1]-a[i-1])){
      cout<<ans-((abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))-(abs(a[i+1]-a[i-1])))<<endl;
    }else{
      cout<<ans+(abs(a[i+1]-a[i-1])-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i])))<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main()
{
  int n1,n2,n3;
  int ans=0;
  cin >> n1 >> n2 >> n3;

  if(n1+n2+n3 >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    rep(i, s.length() - 2)
    {
        if (s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if (s[i] == s[i + 2])
        {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    if (s[s.length() - 2] == s[s.length() - 1])
    {
        cout << s.length() - 1 << " " << s.length() << endl;
        return 0;
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long 
#define max(a,b) a>b?a:b
inline void read(int &x)
{
    x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
}
ll ans;
int n,m,y[100005],mx;
int main()
{
    read(n);read(m);
    for(int i=1;i<=n;i++){int x;read(x);mx=max(mx,x);read(y[i]);}
    sort(y+1,y+n+1);
    int i=n;
    for(;i;i--){if(y[i]<=mx) break;m-=y[i];if(m<=0){cout<<n-i+1<<"\n";return 0;}}
    ans=n-i+(m-1)/mx+1;
    cout<<ans<<"\n";
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n , m;
  cin >> n >> m;
  ll a[n+1];
  rep(i,n+1){
    a[i]=0;
  }
  ll ans = 0;
  ll wa = 0;
  rep(i,m){
    ll p;
    string s;
    cin >> p >> s; 
    if(a[p]!=INF){
      if(s=="AC"){
        wa+=a[p];
        ans++;
        a[p]=INF;
      }else{
        a[p]++;
      }
    }
  }
  pri2(ans,wa);






  //ll n=10;

  //ll f = 1;
  //rep1(i,n){
  //  f*=i;
  //  f%=mod;
  //}
  //ll fn = f;
  //ll inv = mod_pow(f, mod - 2, mod);
  //ll invs[n+1];
  //invs[n] = inv;
  //for(ll i = n;i>1;i--){
  //  inv *= i;
  //  inv %= mod;
  //  invs[i - 1] = inv;
  //}
  //rep(i,n){
  //  pri(invs[i]);
  //}

  return 0;
}


Measured memory_bytes: 1024
N,X = map(int,input().split())
L = list(map(int,input().split()))

ans = 1 #位置0も1にカウントするから
p = 0 #今のポジション
for i in range(N):
    p += L[i]
    if p <= X:
         ans += 1
    else:
        break

print(ans)


Measured memory_bytes: 2940
/**
 * @jakestrj
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define rep(i, j, k) for(int i=(j);i<(k);++i)
#define repi(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>(k);--i)
#define peri(i, j, k) for(int i=(j);i>=(k);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(), greater<int>()
#define mem(a, b) memset(a, (b), sizeof(a))
#define mem2(a, b) memset(a, (b), sizeof(a[0][0])*len(a)*len(a[0]))
#define sz(x) ((int)(x).size())
#define len(x) (int)(sizeof(x)/sizeof(x[0]))
#define endl "\n"
#define INF 1e18
#define EPS 1e-9
#define PI 2*acos(0)
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
typedef tuple<int, int, int> trio;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef map<int,int> mpii;
typedef set<int> si;

#define pli pair<ll, int>
struct C {
	void solve(std::istream& cin, std::ostream& cout) {
		int n; cin >> n;
		vector<pli > uns, X;
		repi(i, 1, n){
			 ll x; cin >> x;
			 X.eb(x, i); uns.eb(x, i);
		}
		sort(all(X), [&](pli a, pli b){
			return a.f < b.first;
		});
		int res[n+1];
		rep(i, 0, n){
			ll val = X[i].f; int idx = X[i].s;
			int l = ((n)>>1);
			res[idx] = X[l - (i>=l?1:0)].first;
		}
		repi(i, 1, n) cout << res[i] << endl;
	}
};


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9948
#include<stdio.h>

int main(){

	int H,W,i,j;	

	while(1){
		scanf("%d %d\n",&H,&W);
		if(H==0 && W==0) break;

	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
	}
	return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    if(N%2)     cout << setprecision(12) << (double)((N/2)+1)/(double)N << "\n";
    else  cout << "0.5000000000\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int day;
	cin >> day;
	day = day % 7;
	switch (day)
	{
	case 0:
		cout<<"thu"<<endl;
		break;
	case 1:
		cout<<"fri"<<endl;
		break;
	case 2:
		cout<<"sat"<<endl;
		break;
	case 3:
		cout<<"sun"<<endl;
		break;
	case 4:
		cout<<"mon"<<endl;
		break;
	case 5:
		cout<<"tue"<<endl;
		break;
	default:
		cout<<"wed"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
  int n,k;
  cin >> n >> k;
  map<int,bool>a;
  rep(i,k){
    int cnt;
    cin >> cnt;
    rep(j,cnt){
      int jdg;
      cin >> jdg;
      if(a.count(jdg))continue;
      else a[jdg] = 1;
    }
  }
  int ans = a.size();
  ans = n - ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3540
#include <stdio.h>

int main(void)
{
    int S;
    int h,m,s;
    scanf("%d",&S);

    h = S/3600;
    m = (S-h*3600)/60;
    s = S-h*3600-m*60;

	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n;
	cin>>n;
	vl a(n);
	cin>>a;
	vvl dp(n,vl(n,inf));
	for(int i=0;i<n;i++){
		dp[i][i]=0;
		if(i<n-1) dp[i][i+1]=a[i]+a[i+1];
	}
	vvl sum(n,vl(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=i;k<=j;k++){
				sum[i][j]+=a[k];
			}
		}
	}
	for(int l=3;l<=n;l++){
		for(int i=0;i<=n-l;i++){
			for(int j=i;j<i+l-1;j++){
				dp[i][i+l-1]=min(dp[i][i+l-1],dp[i][j]+dp[j+1][i+l-1]+sum[i][i+l-1]);
			}
		}
	}
	cout<<dp[0][n-1];
 
 
}
int32_t main(){
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

Measured memory_bytes: 2816
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 2e5+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
char s[MAXN];
char t[MAXN];

void work(){
    scanf("%s%s",s,t);
    int lens=strlen(s);
    int lent=strlen(t);
    if(lens+1!=lent){
        printf("No\n");
    }
    else{
        int ok=1;
        for(int i=0;i<lens;i++){
            if(s[i]!=t[i]) ok=0;
        }
        if(ok) printf("Yes\n");
        else printf("No\n");
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}








Measured memory_bytes: 3692
#include<iostream>
#include<vector>
using namespace std;
int main(){
 int n,a;
  cin>>n;
  vector <int> l(n);
  for(int i=0;i<n;i++){
    cin>>a;
    l[a-1]=i+1;
  }
  for(int i=0;i<n-1;i++)cout<<l[i]<<" ";
  cout<<l[n-1]<<endl;
}

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

int main(){
  string str, cmnd, p;
  int q, a, b;

  cin >> str >> q;

  for(int i = 0; i < q; i++){
    cin >> cmnd >> a >> b;
    
    if(cmnd == "print"){
      cout << str.substr(a, b-a+1) << endl;
    } else if(cmnd == "reverse"){
      string keep = str.substr(a, b-a+1);         //??\???????????????????????????
      int n = keep.size();                        //??\??????????????????????????????
      for(int j = 0; j < n; j++) str[a+j] = keep[n-j-1]; //??\?????????
    } else if(cmnd == "replace"){
      cin >> p;
      str = str.replace(a, b-a+1, p);
    }
  }

  return 0;
}

Measured memory_bytes: 1224
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]

C=[]
for i in range(n):
    line=[]
    for j in range(l):
        c=0
        for k in range(m):
            c+=A[i][k]*B[k][j]
        line.append(c)
    C.append(line)

for line in C:
    print(*line)


Measured memory_bytes: 7056
#include <map>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (short i = a; i <= b; ++ i) 
const short N = 1005, base = 9971 ; 

const short turn[4][4] = {
	{4, 5, 1, 0}, {3, 2, 6, 7},
	{0, 3, 7, 4}, {1, 5, 6, 2}
} ;
using namespace std ;

unsigned long long id[N] ;
map <unsigned long long, short> Count ;
short col[N][5], n ;

inline void getmin(vector <short> &p) {
	vector <short> ret = p, tmp = p ;
	rep(i, 1, 3) {
		rep(j, 0, 3) tmp[j] = p[(i + j) % 4] ;
		if (tmp < ret) ret = tmp ;
	}
	p = ret ;
}

inline unsigned long long Hash(vector <short> &p) {
	unsigned long long ret = 0 ;
	rep(i, 0, 3) ret = ret * base + p[i] ;
	return ret ;
}

map <unsigned long long, short>  mul, used ;

int main() {
	cin >> n ;
	rep(i, 1, n) rep(j, 0, 3) cin >> col[i][j] ;
	rep(i, 1, n) {
		vector <short> ret ;
		rep(j, 0, 3) ret.push_back(col[i][j]) ;
		getmin(ret) ;
		++ Count[Hash(ret)] ;
		id[i] = Hash(ret) ;
		short tot = 0 ; 
		vector <short> tmp = ret ;
		rep(j, 0, 3) {
			rep(k, 0, 3) tmp[k] = ret[(j + k) % 4] ;
			if (tmp == ret) ++ tot ;
		}
		mul[Hash(ret)] = tot ;
	}	
	ll ans = 0, sum ;
	rep(i, 1, n) rep(j, i + 1, n) {
		-- Count[id[i]], -- Count[id[j]] ;
		rep(k, 0, 3) {
			vector <short> ret ;
			rep(p, 0, 3) ret.push_back(col[i][p]) ;
			rep(p, 0, 3) ret.push_back(col[j][3 - (p + k) % 4]) ;
			sum = 1 ;
			unsigned long long U[4] = {0} ;
			rep(p, 0, 3) {
				vector <short> x ;
				rep(q, 0, 3) x.push_back(ret[turn[p][q]]) ;
				getmin(x) ;
				rep(q, 0, 3) U[p] = U[p] * base + x[q] ;
				sum *= (ll) mul[U[p]] * (Count[U[p]] - used[U[p]]) ;
				++ used[U[p]] ;
			}
			rep(p, 0, 3) -- used[U[p]] ;
			ans += sum ;
		}
		++ Count[id[i]], ++ Count[id[j]] ;
	}
	printf("%lld\n", ans / 3) ;
	return 0 ;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }


int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n+100);
  for (int i=2; i<=n;i++){
    cin >> a[i];
  }
  vector<int> ans(n+100);
  for (int i=2; i<=n;i++){
    ans[a[i]]++;
  }
  for (int i=1; i<=n; i++){
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 4792
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,K;
char buf[55];

int main(){

	scanf("%d %d",&N,&K);
	scanf("%s",buf);

	buf[K-1] = buf[K-1]+32;

	printf("%s\n",buf);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=2e5+5;
const int mod=1e9+7;
ll fac[maxn]={1},ifac[maxn];
inline ll fastpow(ll a,ll b) {
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
	return ans;
}
inline void  init() {
	for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
	ifac[maxn-1]=fastpow(fac[maxn-1],mod-2);
	for(int i=maxn-2;~i;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}
inline ll C(ll n,ll m) {
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main() {
    init();
    ll h,w,a,b;cin>>h>>w>>a>>b;
    ll ans=0;
    for(int i=b+1;i<=w;i++) {
    	ans=(ans+C(h-1-a+i-1,i-1)*C(w-i+a-1,a-1)%mod)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6752
#include<stdio.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	int n, d, i, y[1000] = {};
	char x[1001];
	scanf("%d%*c", &n);
	S(s, x);
	S(d, d);
	for (i = 0; i < n; i++)if(x[i] == '0'&&d)y[i]=1,x[i]='1',d--;
	while (d)if (!y[--i]) x[i] = '0', d--;
	puts(x);
	return 0;
}

Measured memory_bytes: 592
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, M, K;

signed main(){
	cin >> N >> M >> K;
	for(int i=0; i<=N; i++){
		for(int j=0; j<=M; j++){
			if(i*j+(N-i)*(M-j) == K){
				cout << "Yes" << endl;
				return 0;
			}
			if(i*j+(N-i)*(M-j) == N*M-K){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main() {
        string s;
        cin >> s;
        bool ok = true;
        if(s.size()%2 == 1) ok = false;
        rep(i,s.size()){
                        if(i%2 == 0){
                                     if(s.at(i) != 'h') ok = false;
                }else{
                                if(s.at(i) != 'i') ok = false;
                        }
        }
        if(ok) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}




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

map<int, int> dp;
char s[200005];
bool vis[26];

int main(){
	scanf("%s", s);
	int l = strlen(s);
	dp[0] = 0;
	for(int i=0;i<l;i++){
		int c = s[i]-'a';
		vis[c] = 1-vis[c];

		int val = 0;
		for(int j=0;j<26;j++) if(vis[j]) val+=(1<<j);

		int ans = i+1;

		for(int j=0;j<26;j++){
			if(dp.count(val^(1<<j))){
				ans = min(ans, dp[val^(1<<j)]+1);
			}
		}
		if(dp.count(val)) ans = min(ans, dp[val]+1), dp[val] = min(dp[val], ans);
		else dp[val] = ans;

		if(i == l-1) printf("%d\n", ans);
	}
}

Measured memory_bytes: 9856
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


A,B,C = MI()
print('Yes' if A+B >= C else 'No')


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

using namespace std;

int main(){

	while(true){
		string  s;
		cin >> s;
		int len = s.length();

		if((s[0] == '0')&&(len == 1))
			break;

		int  sum = 0;
		for(int i = 0;i<len;i++){

			sum += (int)s[i] - 48;
		}
		cout << sum << endl;
		sum = 0;
	}
	return 0;
}



Measured memory_bytes: 3172
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 500010
ll n, d;
ll a[N], dp[N], r[N];

int main(){
	cin>>n>>d;
	rep(i, n) cin>>a[i];
	dp[n] = 1;
	for(int i = n-1; i >= 0; i--){
		dp[i] = dp[i+1];
		if(abs(dp[i]-a[i])<dp[i]) dp[i] += a[i];
	}
	rep(i, n){
		if(dp[i+1]<=d) r[i] = 1;
		d = min(d, abs(d-a[i]));
	}
	int q;
	cin>>q;
	rep(i, q){
		int x;
		cin>>x;
		cout<<(r[x-1]?"YES":"NO")<<endl;
	}
	return 0;
}


Measured memory_bytes: 13696
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

s=arr_data[0][0]


arr=[]


for v in s:
    
    arr.append(v)
    
    
arr02=sorted(arr)

#print(arr02)


chkflg=True


for i in range(0,len(arr02)-1):
    
#    print(arr02[i])
    
    if arr02[i]==arr02[i+1]:
        
        chkflg=False
        
        break
        
if chkflg:
    
    print("yes")
    
else:
    
    print("no")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count =0;
		for (int i=1;i<s.length();i++) {
			if (s.charAt(i)!=s.charAt(i-1)) {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define INF 1844674407370955161
using namespace std;

int n,m,r,a,b,c; unsigned long long ans = INF;
unsigned long long g[205][205];

int main(){
    
    cin>>n>>m>>r;
    int rs[r];
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++)
          g[i][j] = INF;
        g[i][i] = 0;
    }
    
    for(int i=0; i<r; i++) cin>>rs[i];
    
    sort(rs, rs+r);
    
    for(int i=0; i<m; i++){
        cin>>a>>b>>c;
        g[a-1][b-1] = c;
        g[b-1][a-1] = c;
    }
    
    for (int k = 0; k < n; k++) // common error: remember that loop order is k->i->j
        for (int i = 0; i < n; i++)
          for (int j = 0; j < n; j++)
            g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            
    /*for(int i=0; i<n; i++){
        for(int j=0; j<n; j++) if(g[i][j]!= INF)cout<<g[i][j]<<" "; else cout<<"# ";
        cout<<endl;
    }cout<<ans<<endl;
    */
    //cout<<ans<<endl;
    do{
        unsigned long long dist = 0;
        for(int i=0; i<r-1; i++){
            //cout<<g[rs[i]-1][rs[i+1]-1]<<" "<<rs[i]<<" "<<rs[i+1]<<endl;
            dist += g[rs[i]-1][rs[i+1]-1];
        }
        ans = min(ans, dist);
    }while(next_permutation(rs, rs+r));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
// 2020-09-19 21:41:40
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
const int MX = 100010;
bool visited[MX + 10];
void answer() {
  ll n, x, m;
  cin >> n >> x >> m;
  if (n < 1000000) {
    ll ans = 0, cur = x;
    rep(i, n) {
      ans += cur;
      cur = (cur * cur) % m;
    }
    cout << ans << '\n';
    return;
  }
  ll cur = x;
  ll loop = -1;
  for (int i = 0;; i++) {
    if (visited[cur]) {
      loop = cur;
      break;
    }
    visited[cur] = true;
    cur = (cur * cur) % m;
  }
  cur = x;
  ll ans = 0, rem = n;
  {
    ll now = 0, i = 0;
    while (cur != loop) {
      now += cur;
      cur = (cur * cur) % m;
      i++;
    }
    ans += now;
    rem -= i;
  }
  {
    ll tot = cur, i = 1;
    cur = (cur * cur) % m;
    while (cur != loop) {
      tot += cur;
      cur = (cur * cur) % m;
      i++;
    }
    ans += tot * (rem / i);
    rem %= i;
  }
  rep(i, rem) {
    ans += cur;
    cur = (cur * cur) % m;
  }
  cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3676
# 隣り合う頂点が、同じグループにいなければ良い
# 点を順番に0,1で塗っていき、既に0で塗られている場所に1を塗ろうとしたら（あるいはその逆）NG。

N = int(input())
E = [[] for i in range(N)]
G = [None] * N
INF = 10 ** 9
for i in range(N):
  edges = input()
  G[i] = list(map(int,list(edges)))
  G[i] = list(map(lambda x:INF if x == 0 else x,G[i]))
  for j in range(len(edges)):
    if edges[j] == "1":
      E[i].append(j)

color = [-1 for i in range(N)]
from collections import deque
q = deque([])
# 頂点、次に塗る色
q.append([0,0])

while q:
  v,bit = q.popleft()
  if color[v] != -1:
    # 既に色が塗られている
    if color[v] == bit: # 塗ろうとしている色と同じなら探索済み
      continue
    else: # 違う色ならNG
      print(-1)
      exit(0)
  # 塗る
  color[v] = bit
  children = E[v]
  for child in children:
    q.append([child,bit^1])

# ここまで来たら、最も長い頂点間の距離を求め+1が答え
# ワーシャルフロイドして最大値

import numpy as np
from scipy.sparse.csgraph import shortest_path
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import csgraph_from_dense

G = csgraph_from_dense(G, null_value=10**9)
d = floyd_warshall(G)

ans = 0
for i in range(N):
  for j in range(N):
    if ans < d[i][j]:
      ans = d[i][j]
      
print(int(ans) + 1)

Measured memory_bytes: 18400
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e9+7;

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

int main(){
   int k; cin >> k;
   ll sum = 0;
   for(int a = 1; a <= k; a++){
      for(int b = 1; b <= k; b++){
         // int g = gcd(a,b);
         for(int c = 1; c <= k; c++){
            sum += gcd(gcd(a,b),c);
         }
      }
   }
   cout << sum << endl;
   return 0;
}


Measured memory_bytes: 3612
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto S = new string[](N);
    auto P = new long[](N);
    foreach (i; 0 .. N)
        scan(S[i], P[i]);
    auto I = iota(N).map!"a+1"().array();

    zip(S, P, I).sort!less();
    foreach (i; 0 .. N)
    {
        // writeln(S[i]);
        writeln(I[i]);
    }
}

bool less(T)(T t0, T t1)
{
    if (t0[0] < t1[0])
        return true;
    if (t1[0] < t0[0])
        return false;
    if (t0[1] < t1[1])
        return false;
    if (t1[1] < t0[1])
        return true;
    return t0[2] < t1[2];
}


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    
    if(A < C && C < B){
        cout << "Yes" << endl;
    }else if(B < C && C < A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

using namespace std;

int main(void)
{
	//input
	int numData1;
	cin >> numData1;
	
	vector<int> vector1;
	for(int i = 0; i < numData1; i++ )
	{
		int input1;
		cin >> input1;
	  	vector1.push_back( input1 );
	}
	
	int numData2;
	cin >> numData2;
	
	vector<int> vector2;
	for(int j = 0; j < numData2; j++ )
	{
		int input2;
		cin >> input2;
	  	vector2.push_back( input2 );
	}
	
	//Serch
	int serchCnt = 0;
	for(int k = 0; k < numData2; k++ )
	{
		vector<int>::iterator serchNum = find( vector1.begin(), vector1.end(), vector2.at(k) );
		if( serchNum != vector1.end() )
		{
			serchCnt++;
		}
	}
	
	//Output
	cout << serchCnt << endl;
	
	return 0;
}

Measured memory_bytes: 3236
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll x, a, b;
    cin >> x >> a >> b;

    cout << (abs(a - x) < abs(b - x) ? "A" : "B") << endl;
    
    return 0;
}

Measured memory_bytes: 3584