akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	    int x=gi();
	    int y=Math.floorDiv(x, 100);
	    int a=x%100;

	    


	    if (a>5*y) {
	    	System.out.println('0');
	    } else {
	    	System.out.println('1');
	    }
	    //System.out.println(n);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35548
#include <bits/stdc++.h>
#define pii pair<int,int>
#define eb emplace_back
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int L[n];
    for(auto& x:L)  cin>>x;
    int ans = 0;
    for( int i=0;i<n;i++ )
    for( int j=i+1;j<n;j++ )
    for( int k=j+1;k<n;k++ )
    if( L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k] )
    {
        int a[] = { L[i], L[j], L[k] };
        sort(a,a+3);
        if( a[0] + a[1] > a[2] )
            ans++;
    }
    cout << ans;
}

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

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


Measured memory_bytes: 3624
n, m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: x[1])

remove = ab[0][1]
res = 1
for i in range(m):
    if remove <= ab[i][0]:
        res += 1
        remove = ab[i][1]

print(res)

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

int main(){
  int N,Y,a,b,c;cin>>N>>Y;
  int res=0;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        res++;
        a=i;b=j,c=N-i-j;
      }
    }
  }
  if(res){
    cout<<a<<" "<<b<<" "<<c<<endl;
  }
  else cout<<-1<<" "<<-1<<" "<<-1<<endl;
}


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

int main() {
  int x;
  
  cin >> x;
  
  int s1 = x % 10;
  int s2 = (x / 10) % 10;
  int s3 = x / 100;
  
  cout << s1 + s2 + s3 << endl;
}

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

using namespace std;

int main(){
  typedef long long int ll;
  int K,sum = 0;
  cin >> K;
  for(int i = 0; i < K; i++){
    for(int j = 0; j < K; j++){
      for(int l = 0; l < K; l++){
        sum += gcd(i+1,gcd(j+1,l+1));
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+100;
ll bit[maxn],len;
string s;
ll k[maxn];
int main()
{
    int n,p;
    scanf("%d%d",&n,&p);
    cin>>s;

    //cout<<s<<endl;
    k[0]=1;
    for(int i=1; i<=n; i++)
    {
        k[i]=(k[i-1]*10)%p;
    }
    ll ans=0,pre=0;
    reverse(s.begin(),s.end());
    if(p==2||p==5)
    {
        for(int i=0; i<n; i++)
        {
            //cout<<(2%p)<<endl;
            if(!((s[i]-'0')%p)){
                ans+=n-i;
                //cout<<ans<<endl;
            }
        }
    }
    else
    for(int i=0; i<n; i++)
    {
        pre=(pre+((s[i]-'0')*k[i])%p)%p;
        //if(!(pre%p))
        //  ans++;
        //cout<<pre<<"  $1 "<<ans<<endl;
        ans+=bit[pre];
        //cout<<"  $ "<<ans<<endl;
        bit[pre]++;

    }
    printf("%lld\n",ans+bit[0]);
    //cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2180
#include<stdio.h>

void solve(int, int);
int A[20], n, f;

int main(){
  int q, M[200], i;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }  
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &M[i]);
  }  
  for(i = 0; i < q; i++){
    f = 0;
    solve(0, M[i]);
    if(f == 1)printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

void solve(int p, int t){
  if(t == 0) f = 1;
  else if(p < n){
    solve(p+1, t-A[p]);
    solve(p+1, t); 
  }
}

Measured memory_bytes: 580
import java.util.*;

public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int o=0;
      	String s;
      	int n2=(int)(n/1.08);
      	if((int)(n2*1.08)==n)o=n2;
      	if((int)((n2+1)*1.08)==n)o=n2+1;
      	if(o==0)s=":(";
      	else s=Integer.toString(o);
      	System.out.println(s);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())
 
int main() {
    int n, res;
    cin>>n;
    res = n % 10;
    //cout << res << endl;
    if (res == 2 || res == 4 || res == 5 || res == 7 || res == 9) {
        cout << "hon" << endl;
    } else if (res == 3) {
        cout << "bon" << endl;
    } else {
        cout << "pon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
N,K=map(int,input().split())
L=[[]for i in range(N+1)]
l=[]
for i in range(N-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)
    l.append([a,b])
ans=N
if K%2==0:
    for i in range(1,N+1):
        C=[10000 for i in range(N+1)]
        Q=[[i,0]]
        cnt=0
        for q in range(10000):
            if q==len(Q):
                break
            if C[Q[q][0]]==10000:
                C[Q[q][0]]=Q[q][1]
                cnt+=1
                if Q[q][1]<K//2:
                    for k in L[Q[q][0]]:
                        if C[k]==10000:
                            Q.append([k,Q[q][1]+1])
        if N-cnt<ans:
            ans=N-cnt
        #print(i,C)
    print(max(0,ans))
else:
    if K==1:
        print(N-2)
        exit()
    for a,b in l:
        C1=[10000 for i in range(N+1)]
        C2=[10000 for i in range(N+1)]
        X=[[a,0]]
        for q in range(10000):
            if q==len(X):
                break
            if C1[X[q][0]]==10000:
                C1[X[q][0]]=X[q][1]
                if X[q][1]<(K-1)//2:
                    for k in L[X[q][0]]:
                        if C1[k]==10000:
                            X.append([k,X[q][1]+1])
        Y=[[b,0]]
        for q in range(10000):
            if q==len(Y):
                break
            if C2[Y[q][0]]==10000:
                C2[Y[q][0]]=Y[q][1]
                if Y[q][1]<(K-1)//2:
                    for k in L[Y[q][0]]:
                        if C2[k]==10000:
                            Y.append([k,Y[q][1]+1])
        cnt=0
        for x in range(1,N+1):
            if C1[x]<=(K-1)//2 or C2[x]<=(K-1)//2:
                cnt+=1
        #print(a,b,cnt,C1,C2)
        if N-cnt<ans:
            ans=N-cnt
    print(max(0,ans))

Measured memory_bytes: 108376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a%2 != b%2) {
		ll ans = min(b-1, n-a);
		ans = min(ans, (a+b-1)/2);
		ans = min(ans, (n-((a+b-1)/2)));
		cout << ans << endl;
	} else {
		ll ans = min(b-1, min(n-a, (a+b)/2-a));
		cout << ans << endl;
	}
	return 0;
}

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

struct Node {
  int parent;  // 節点の親
  int left;    // 節点の一番左の子
  int right;   // 節点の右隣の兄弟
};

void preParse(Node T[], int u) {
  if(u == NIL) return;
  cout << " " << u;
  preParse(T, T[u].left);
  preParse(T, T[u].right);
}

void inParse(Node T[], int u) {
  if(u == NIL) return;
  inParse(T, T[u].left);
  cout << " " << u;
  inParse(T, T[u].right);
}

void postParse(Node T[], int u) {
  if(u == NIL) return;
  postParse(T, T[u].left);
  postParse(T, T[u].right);
  cout << " " << u;
}

int main() {
  int n; cin>>n;
  Node T[n];
  // 初期化
  rep(i, n) T[i].parent = T[i].left = T[i].right = NIL;

  rep(i, n) {
    int u;cin>>u;
    cin >> T[u].left >> T[u].right;
    if(T[u].left != NIL) T[T[u].left].parent = u;
    if(T[u].right != NIL) T[T[u].right].parent = u;
  }

  int root;
  rep(i, n) if(T[i].parent == NIL) root = i;

  cout << "Preorder" << endl;
  preParse(T, root);
  cout << endl;
  cout << "Inorder" << endl;
  inParse(T, root);
  cout << endl;
  cout << "Postorder" << endl;
  postParse(T, root);
  cout << endl;

  return 0;
}


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

int main(){
	int a,L;
	while(cin>>a>>L && (a|L)!=0){
		int data[100];
		int count=1;
		bool f=true;
		data[0]=a;
		while(f){
			vector<int> num;
			for(int i=0;i<L;i++){
				num.push_back(a%10);
				a/=10;
			}
			sort(num.begin(),num.end());
			int b=0,c=0;
			for(int i=0;i<num.size();i++){
				b*=10;
				b+=num[i];
				c*=10;
				c+=num[num.size()-i-1];
			}
			data[count]=a=c-b;
			for(int i=0;i<count;i++){
				if(data[i]==a){
					f=false;
					cout<<i<<" "<<a<<" "<<count-i<<endl;
					break;
				}
			}
			count++;
		}
	}
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   map<string,int>m;
   for(int i=0;i<n;i++)
   {
       string x;
       cin>>x;
       m[x]++;
   }
   cout<<m.size()<<endl;
}


Measured memory_bytes: 19216
#include<cstdio>

int main(){
    int N;
    scanf("%d", &N);
    
    char S[N];
    for(int i=0;i<N;i++){
        scanf("%c",&S[i]);
    }


    int j=0;
    while(S[j] != 'Y'){
        if(j >= N){
            printf("Three\n");
            return 0;
        }
        j++;
    }

    printf("Four\n");
    return 0;
}

Measured memory_bytes: 128
//“ In order to be irreplaceable, one must always be different”
#include<bits/stdc++.h>
using namespace std;
#define ll long long
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
//assign() assignes new value
//emplace(position,x) inserting
//erase(position) to remove an element
//swap() for swapping
//reverse(position,position) for reversing
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
ll lcm(ll a, ll b)  
{  
    return (a*b)/gcd(a, b);  
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin>>x;
    str s;
    cin>>s;
    ll c=0;
    for(ll i=0;i<s.length()-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            c++;
        }
    }
    cout<<c;
    return 0;
}
   

		
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 256
def main():
    L,R = map(int,input().split())

    if R-L>=2019:
        print(0)
    else:
        ans = 2018
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                ans = min(ans,(i*j)%2019)
        print(ans)

if __name__=="__main__":
    main()

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

class C
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var x = read().OrderBy(t => t).ToArray();
		Console.WriteLine(Enumerable.Range(0, h[1] - 1).Select(i => x[i + 1] - x[i]).OrderByDescending(t => t).Skip(h[0] - 1).Sum());
	}
}


Measured memory_bytes: 24032
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int l;vector<int> L;
    cin >> N;
    int Ans=0;
    REP(i,N){
        cin >> l;
        L.push_back(l);
    }
    sort(L.begin(),L.end());
    REP(i,N){
        REP(j,N){
            if(i>=j)continue;
            //i<j
            decltype(L)::iterator it = std::lower_bound(L.begin(), L.end(), L[j]+L[i]);
            int d=(it-L.begin());
            d=d-j-1;
            //cout <<L[i] MM L[j] MM L[i]+L[j] MM d << endl;
            Ans+=d;
            
        }
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

const int mod = 1e9+7;

int nCr [2010][2010];
void makePascal(){
  nCr[0][0] = 1;
  for(int i=0; i<2000; i++){
    for(int j=0; j<=i; j++){
      nCr[i+1][j] += nCr[i][j];
      nCr[i+1][j] %= mod;
      nCr[i+1][j+1] += nCr[i][j];
      nCr[i+1][j+1] %= mod;
    }
  }
}

int main() {
  makePascal();
  int n, k;
  cin >> n >> k;
  for(int i=1; i<=k; i++){
    ll res = (ll)nCr[n-k+1][i]*nCr[k-1][i-1]%mod;
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 15104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
signed main() {
	double a, b, r, p, q;
	cin >> a >> b >> p >> q >> r;
	double d = b * p - (b - a) * q;
	cout << d / (q + r) + b << endl;
	ggr
}



Measured memory_bytes: 3296
import collections

d,g =  map(int, raw_input().split())
cc = {0:0}
picis = [map(int,raw_input().split()) for _ in range(d)]

pisum = sum([pi for pi,ci in picis] or [0])
for i in range(len(picis)):
	pi,ci = picis[i]
	for p in range(1, pisum + 1)[::-1]:
		for q in range(1, pi + 1):
			if p - q >= 0 and (p - q) in cc:
				cc[p] = max(cc[p] if p in cc else -float('inf'),  cc[p - q] + (100 * q * (i + 1)) + (ci if pi == q else 0))

for k in range(pisum+1):
	if cc[k] >= g:
		print k
		break

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n , m ; cin >> n >> m ;
	ll ans = max((ll)0, (n-2)*(m-2));
	if(n==1||m==1){
		if(n*m == 1){
			ans = 1;
		}else if( n * m == 2){
			ans = 0;
		}else ans = n*m -2 ;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
void main()
{
    int c5=0,c7=0,i,arr[3];

    scanf("%d %d %d",&arr[0],&arr[1],&arr[2]);
    for(i=1;i<=3;i=i+1){
        if(arr[i-1]==5){
            c5=c5+1;
        }
        if(arr[i-1]==7){
            c7=c7+1;
        }
    }
    if(c5==2&&c7==1){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}


Measured memory_bytes: 1556
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200005
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int size[MAX] = {0};
int parent[MAX];
int a[MAX], b[MAX];

int root(int x) {
  if (x == parent[x]) return x;
  return parent[x] = root(parent[x]);
}

int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);

  rep(i, 0, m) scanf("%d %d", &a[i], &b[i]);

  rep(i ,1, n+1) parent[i] = i;

  rep(i ,0, m) parent[root(a[i])] = root(b[i]);
  rep(i, 1, n+1) size[root(i)]++;

  int max = 0;
  rep(i, 1, n+1) max = max(max, size[i]);
  printf("%d\n", max); 
  return 0;
}


Measured memory_bytes: 10264
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$current = 0;
$max = 0;
for($i = 0; $i < $n; $i++){
    if($str[$i] == "I"){
        $current++;
    }else{
        $current--;
    }
    $max = max($max, $current);
}
echo $max;


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

int main() {
    int n;cin>>n;
    int f[n][10];
    for (int i=0;i<n;i++)
        for (int j=0;j<10;j++)
            cin>>f[i][j];
    int p[n][11];
    for (int i=0;i<n;i++)
        for (int j=0;j<11;j++)
            cin>>p[i][j];
    int mx=-1e9;
    for (int i=1;i<1<<10;i++) {
        int sm=0;
        for (int j=0;j<n;j++) {
            int cnt=0;
            for (int k=0;k<10;k++)
                cnt+=i>>k&f[j][k];
            sm+=p[j][cnt];
        }
        mx=max(mx,sm);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 256
# 入力 : A B C
a, b, c = map(int, input().split())
# 文節の並びを五七五にすることができるなら YES 、そうでないなら NO を出力せよ。
list = [a, b, c]
list_seikai = [5, 5, 7]
list.sort()

if list == list_seikai :
    print("YES")
else :
    print("NO")

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

signed main() {
  int N;
  cin >> N;
  switch(N%10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      puts("hon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      puts("pon");
      break;
    default:
      puts("bon");
      break;
  }
}


Measured memory_bytes: 3600
string = input()
flag = False
 
num = len(string)
if num % 2 == 0:
  for i in range(num // 2):
    if string[2*i:2*(i+1)] == "hi":
      if i == num // 2 - 1:
        flag = True
    else:
      break

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int W = sc.nextInt();
        
        long[] w = new long[N];
        long[] v = new long[N];
        
        for(int i = 0; i < N; i++){
            w[i]=sc.nextInt();
            v[i]=sc.nextInt();
        }
        
        //dp[商品数][商品の重さ] = 商品数と商品の重さがわかっている時の、価値の総和の最大値
        
        long[][] dp = new long[110][100100]; 
        
        for(int i = 0; i < N; i++){ //商品
            for(int k = 0; k <= W; k++){ //重さ
                if(k - w[i] >= 0){ //重さ - i番目商品の重さ が０以上だったら 選ぶ場合
                //dp[i+1][商品の重さ] = max(dp[i+1][k],dp[i][重量-商品の重さ=残りの重量]=残りの重量の価値の総和の最大値+価値=価値の総和)
                    dp[i+1][k] = Math.max(dp[i+1][k],dp[i][(int) (k-w[i])]+v[i]);
                }
                //選ばない場合
                dp[i+1][k] = Math.max(dp[i+1][k],dp[i][k]);
            }
        }
        
        System.out.println(dp[N][W]);
        
    }
}


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

long N;
long A[100005];
long L[100005];
long R[100005];

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

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

	L[0] = A[0];
	for(long i = 1; i < N; i++){
		L[i] = gcd(A[i], L[i-1]);
	}

	R[N-1] = A[N-1];
	for(long i = N-2; i >= 0; i--){
		R[i] = gcd(A[i], R[i+1]);
	}

	long maxi = max(R[1], L[N-2]);
	for(long i = 1; i < N-1; i++){
		maxi = max(maxi, gcd(L[i-1], R[i+1]));
	}
	cout << maxi << endl;
}

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

int n;
int W;
long long w[128],v[128];
long long dp[128][101000];

int main(){
	cin>>n>>W;
	for(int i=1;i<=n;++i){
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=w[i];++j) dp[i][j]=dp[i-1][j];
		for(int j=w[i];j<=W;++j){
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
		}
	}
	long long ans=0;
	for(int i=1;i<=W;++i) ans=max(ans,dp[n][i]);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 79360
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int N;
	while(cin>>N) printf("3C%02d\n",(N-1)%39+1);
	return 0;
}

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

int main(void){
  int N, M;
  int a[60], b[60];
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> a[i] >> b[i];
  }

  int count[60];
  for(int i = 0;i < N; i++){
    count[i] = 0;
  }
  for(int i = 0; i < M; i++){
    count[a[i] - 1] ++;
    count[b[i] - 1] ++;
  }

  for(int i = 0; i < N;i++){
    cout << count[i] << endl;
  }
}

Measured memory_bytes: 256
import sys
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    a1 = input()
    A.append(a1)
for _ in range(M):
    b1 = input()
    B.append(b1)
    
for i in range(N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            if A[i+k][j:j+M] == B[k]:
                pass
            else:
                break
            if k == M-1:
                print("Yes")
                sys.exit()
print("No")                

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b);
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define size_of(a) (int)a.size()

const int iINF = 1L << 30;

inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }

int M, N, P[10010], S[10010], C[555], E[555];
int dp[10010];

int main() {
	scanf("%d %d", &M, &N);
	for_(i,0,M) scanf("%d", &P[i]);
	for_(i,0,N) scanf("%d %d", &C[i], &E[i]);
	
	sort(P, P+M, greater< int >());
	
	memset(S, 0, sizeof(S));
	for_(i,0,M) S[i + 1] = S[i] + P[i];
	
	fill(dp, dp + M + 1, iINF);
	dp[0] = 0;
	
	for_(i,0,N) for_rev(j,M+C[i],C[i]) {
		int nx = min(j, M);
		minUpdate(dp[nx], dp[j - C[i]] + E[i]);
	}
	
	int ans = 0;
	for_(i,0,M+1) maxUpdate(ans, S[i] - dp[i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1352
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,ll>>v;
ll n,k,a,b,c,ans;
int main(void){
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>a>>b;
        v.push_back({b,a});
    }
    sort(v.begin(),v.end());
    for(auto x:v){
        a=x.second;
        b=x.first;
        if(c<=a){
            ans++;
            c=b;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	vl r(n+1,0),g(n+1,0),b(n+1,0); //後ろからの累積和
	for(ll i = n-1;i >= 0;i--){
		if(s[i] == 'R')r[i] = r[i+1] + 1;
		else r[i] = r[i+1];
	}
	for(ll i = n-1;i >= 0;i--){
		if(s[i] == 'G')g[i] = g[i+1] + 1;
		else g[i] = g[i+1];
	}
	for(ll i = n-1;i >= 0;i--){
		if(s[i] == 'B')b[i] = b[i+1] + 1;
		else b[i] = b[i+1];
	}
	vl r0(0),g0(0),b0(0);
	rep(i,n){
		if(s[i] == 'R')r0.push_back(i);
		else if(s[i] == 'G')g0.push_back(i);
		else b0.push_back(i);
	}
	ll ans = 0;
	rep(i,r0.size()){
		rep(j,g0.size()){
			if(r0[i] > g0[j])continue;
			if(2*g0[j] - r0[i] < n && s[2*g0[j] - r0[i]] == 'B')ans += b[g0[j]] - 1;
			else ans += b[g0[j]];
		}
	}
	rep(i,g0.size()){
		rep(j,r0.size()){
			if(g0[i] > r0[j])continue;
			if(2*r0[j] - g0[i] < n && s[2*r0[j] - g0[i]] == 'B')ans += b[r0[j]] - 1;
			else ans += b[r0[j]];
		}
	}
	rep(i,r0.size()){
		rep(j,b0.size()){
			if(r0[i] > b0[j])continue;
			if(2*b0[j] - r0[i] < n && s[2*b0[j] - r0[i]] == 'G')ans += g[b0[j]] - 1;
			else ans += g[b0[j]];
		}
	}
	rep(i,b0.size()){
		rep(j,r0.size()){
			if(b0[i] > r0[j])continue;
			if(2*r0[j] - b0[i] < n && s[2*r0[j] - b0[i]] == 'G')ans += g[r0[j]] - 1;
			else ans += g[r0[j]];
		}
	}
	rep(i,g0.size()){
		rep(j,b0.size()){
			if(g0[i] > b0[j])continue;
			if(2*b0[j] - g0[i] < n && s[2*b0[j] - g0[i]] == 'R')ans += r[b0[j]] - 1;
			else ans += r[b0[j]];
		}
	}
	rep(i,b0.size()){
		rep(j,g0.size()){
			if(b0[i] > g0[j])continue;
			if(2*g0[j] - b0[i] < n && s[2*g0[j] - b0[i]] == 'R')ans += r[g0[j]] - 1;
			else ans += r[g0[j]];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3696
#include <stdio.h>

int main()
{
  int i, j, n, a[100], min, swap, ans = 0;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);
    
  for(i = 0; i < n-1; i++){
  	min = i;
    for(j = i; j < n; j++){
      if(a[j] < a[min])
        min = j;
    }
    for(j = min; j > i; j--){
      swap = a[j];
      a[j] = a[j-1];
      a[j-1] = swap;
      
      ans++;
    }
  }
  
  for(i = 0; i < n-1; i++)
    printf("%d ", a[i]);
    
  printf("%d\n", a[n-1]);
  
  printf("%d\n", ans);

    return 0;
}

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

using namespace std;
int a[1234567];
int Eve(int n)
{
    sort(a,a+n);
    long long ans=0;
    for (int i=0;i<n-1;i++)
    {
        ans+=a[i];
    }
    ans+=a[n-1]/2;
    return ans;
}
int main()
{
    int n;
    cin >>n;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    cout <<Eve(n)<<endl;
    return 0;
}

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

int main(){
  int N,M; cin >> N >> M;
  vector<int>a(M);
  for(int i=0;i<M;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  a.push_back(-1);
  int now = 0;
  vector<long long>dp(N+1);
  dp.at(0) = 1;
  for(int i=1;i<=N;i++){
    if(i == a.at(now)){
      now++;
      continue;
    }
    dp.at(i) += dp.at(i-1);
    if(i>1) dp.at(i) += dp.at(i-2);
    dp.at(i) = dp.at(i)%1000000007;
  }
  cout << dp.at(N)%1000000007 << endl;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n,m,i,j;
	int tarou[101];
	int hanako[101];
	int tarou_sum = 0,hanako_sum = 0;
	int sa;
	int min_tarou = 999,min_hanako = 999;
	int min = 999;
	int hen = 0;
	while(1){
		scanf("%d %d",&m,&n);
		if(m == 0)break;
		
		min_tarou = 999;
		min_hanako = 999;
		tarou_sum = 0;
		hanako_sum = 0;
		min = 999;
		
		for(i = 0;i < m;i++){
			scanf("%d",&tarou[i]);
			tarou_sum += tarou[i];
		}
		for(i = 0;i < n;i++){
			scanf("%d",&hanako[i]);
			hanako_sum += hanako[i];
		}
		if(!(abs(tarou_sum - hanako_sum) % 2)){
			sa = (tarou_sum - hanako_sum) / 2;
			
			for(i = 0;i < m;i++){
				for(j = 0;j < n;j++){
					if((tarou[i] - hanako[j]) == sa && (tarou[i] + hanako[j]) < min){
						min_tarou = tarou[i];
						min_hanako = hanako[j];
						min = tarou[i] + hanako[j];
					}
				}
				
			}
		}
		
		if(min_tarou == 999){
			printf("-1\n");
		}else{
			printf("%d %d\n",min_tarou,min_hanako);
		}
		
	}
	return 0;
}

Measured memory_bytes: 612
let () =
  let n = Scanf.sscanf (read_line()) "%d" (fun n -> n) in
  let string_numbers = Str.split (Str.regexp " ") (read_line()) in
  let numbers = List.map int_of_string string_numbers in
  let rec read numbers min max sum n =
    match numbers with
    | [] -> if n != 0 then
              raise (Sys_error ": number of the numbers is wrong");
            min,max,sum
    | h::t -> let new_min = if h < min then h else min in
              let new_max = if h > max then h else max in
              read t new_min new_max (sum + h) (n - 1)
  in
  let min, max, sum = read numbers max_int min_int 0 n in
  Printf.printf "%d %d %d\n" min max sum
;;


Measured memory_bytes: 4316
N,A,B=map(int,input().split())
cnta, cntb, cntc = 0,0,0
passed = 0
for i, s in enumerate(input()):
  if s == 'a':
    if passed<A+B:
      print('Yes')
      passed += 1
    else:
      print('No')
    cnta += 1
    
  elif s == 'b':
    if passed<A+B and cntb<B:
      print('Yes')
      passed += 1
    else:
      print('No')
    cntb += 1
    
  else:
    print('No')
    cntc += 1

Measured memory_bytes: 53592
import numpy as np


def main():
    n = int(input())
    p = list(map(int,input().split()))
    a = np.array(list(range(1,n+1)))
    p = np.array(p)
    ans = len(np.where((a-p)!=0)[0])

    if ans <= 2:
        print('YES')
    else:
        print('NO')






main()

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

typedef long long ll;
#define inf 1e9+7

int dp[1001][1001];
char x[1001],y[1001];

void init(){
    for(int i=0;i<1001;i++){
        dp[0][i]=0;
        dp[i][0]=0;
    }
}

void solve(int sn, int tn){
    for(int i=1;i<=sn;i++){
        for(int j=1;j<=tn;j++){
            if(x[i-1]==y[j-1])dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    }
}

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

    int n;
    cin >> n;
    string s,t;
    for(int i=0;i<n;i++){
        init();
        cin >> s >> t;
        int sn=s.size();
        int tn=t.size();
        for(int j=0;j<sn;j++){
            x[j]=s[j];
        }
        for(int j=0;j<tn;j++){
            y[j]=t[j];
        }

        solve(sn, tn);
        cout << dp[sn][tn] << endl;
    }

}



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

int main() {
  int N, M, total = 0;
  int A[1000];

  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A[i] = x;
    total += x;
  }

  int ans = 0;
  for (int j = 0; j < N; j++) {
    if (A[j] >= total * 1/(4.0*M)) {
      ans++;
    }
  }

  if (ans >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void) {
    int A, B, C, D;

    scanf("%d%d%d%d", &A, &B, &C, &D);

    while (A > 0) {
        C = C - B;
        if (C <= 0) {
            break;
        }
        A = A - D;
    }

    if (C <= 0) {
        printf ("Yes\n");
    } else {
        printf ("No\n");
    }

    return 0;
}

Measured memory_bytes: 1660
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var K = int.Parse(Console.ReadLine());
        var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans += Min(x[i], Abs(x[i] - K));
        }

        Console.WriteLine(ans*2);
    }
}

Measured memory_bytes: 28156
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define MAX 2000001
#define VMAX 10000


int main()
{
	unsigned short *A,*B;

	int C[VMAX+1];
	for (int i = 0; i < VMAX+1; ++i)
	{
		C[i] = 0;
	}
	int n;
	scanf("%d",&n);

	A = (unsigned short *)malloc(sizeof(short)*n+1);
	B = (unsigned short *)malloc(sizeof(short)*n+1);

	for (int i = 0; i < n; ++i)
	{
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}

	for (int i = 1; i <= VMAX;++i)
	{
		C[i] = C[i] + C[i-1];
	}

	for (int i = n; i > 0 ; --i)
	{
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	for (int i = 1; i <= n; ++i)
	{
		if (i > 1)
		{
			printf(" ");
		}
		printf("%hu",B[i]);
	}
	printf("\n");


	return 0;
}


Measured memory_bytes: 11004
#include <iostream>

using namespace std;

int main(void){
  long long N;
  cin >> N;
  // 入力終了
  
  // f(N) = N(N-2)(N-4)(N-6) ...  
  // となり，偶数のときのみ0が末尾につく

  // 奇数のときは，
  // f(N) = N(N-2)(N-4)(N-6) ... 3 1
  // なので10を素因数に持たない
  if(N%2){
    cout << 0 << endl;
    return 0;
  }

  // Nの桁数を見る
  long long tmp = N;
  long long dig = 0;
  while(tmp != 0){
    dig++;
    tmp /= 10;
  }

  // 素因数5より素因数2の方が明らかに多く現れるので
  // 素因数5が何回現れるかだけに着目すれば十分
  long long ans = 0;
  tmp = 5;
  while(1){
    // 5^nで何回割れるか
    // ただし，奇数のときは除く
    ans += (N/tmp)/2;
    tmp *= 5;

    if(tmp > N)
      break;
  }
  
  // 解答
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3636
K = gets.to_i

arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]

puts arr[K-1]

Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		
		String str=s.next();
		
		long[] r=new long[3*n];
		long[] g=new long[3*n];
		long[] b=new long[3*n];
		
		if(str.charAt(n-1)=='R')
		{
			r[n-1]=1;
		}
		else if(str.charAt(n-1)=='G')
		{
			g[n-1]=1;
		}
		else
		{
			b[n-1]=1;
		}
		
		for(int i=n-2;i>=0;i--)
		{
			if(str.charAt(i)=='R')
			{
				r[i]=r[i+1]+1;
				g[i]=g[i+1];
				b[i]=b[i+1];
			}
			else if(str.charAt(i)=='B')
			{
				r[i]=r[i+1];
				g[i]=g[i+1];
				b[i]=b[i+1]+1;
			}
			else
			{
				r[i]=r[i+1];
				g[i]=g[i+1]+1;
				b[i]=b[i+1];
			}
		}
		
		long ans=0;
		
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				if(str.charAt(i)=='R')
				{
					if(str.charAt(j)=='B')
					{
						ans=ans+g[j+1];
						
						int check=j+j-i;
						
						if(check<n)
						{
							if(str.charAt(check)=='G')
							{
								ans--;
							}
						}
					}
					else if(str.charAt(j)=='G')
					{
						ans=ans+b[j+1];
						
						int check=j+j-i;
						
						if(check<n)
						{
							if(str.charAt(check)=='B')
							{
								ans--;
							}
						}
					}
				}
				else if(str.charAt(i)=='B')
				{
					if(str.charAt(j)=='R')
					{
						ans=ans+g[j+1];
						
						int check=j+j-i;
						
						if(check<n)
						{
							if(str.charAt(check)=='G')
							{
								ans--;
							}
						}
					}
					else if(str.charAt(j)=='G')
					{
						ans=ans+r[j+1];
						
						int check=j+j-i;
						
						if(check<n)
						{
							if(str.charAt(check)=='R')
							{
								ans--;
							}
						}
					}
				}
				else
				{
					if(str.charAt(j)=='R')
					{
						ans=ans+b[j+1];
						
						int check=j+j-i;
						
						if(check<n)
						{
							if(str.charAt(check)=='B')
							{
								ans--;
							}
						}
					}
					else if(str.charAt(j)=='B')
					{
						ans=ans+r[j+1];
						
						int check=j+j-i;
						
						if(check<n)
						{
							if(str.charAt(check)=='R')
							{
								ans--;
							}
						}
					}
				}
			}
		}
		
		System.out.println(ans);
		
	}
	
}

Measured memory_bytes: 39748
#include <bits/stdc++.h>
using namespace std;
static const int INFH = (1<<30)-1;
static const int INFL = -INFH;

vector<pair<char, int>> runLength(string x)
{
	char now = x[0];
	int count = 1;
	vector<pair<char, int>> ret;
	for (int i = 1; i < x.size(); ++i)
	{
		if(x[i] != now)
		{
			ret.push_back(make_pair(now, count));
			now = x[i];
			count = 1;
		}
		else
		{
			++count;
		}
	}
	ret.push_back(make_pair(now, count));
	return ret;
}

long long int wa(int x)
{
	long long int ret = 0;
	for (int i = 1; i <= x; ++i)
	{
		ret += i;
	}
	return ret;
}

int main()
{
	string in;
	cin >> in;
	vector<pair<char, int>> r = runLength(in);
	long long int ans = 0;
	if(r.size() == 1)
	{
		cout << wa(r[0].second) << endl;
		return 0;
	}
	for (int i = 0; i < r.size(); ++i)
	{
		if(i == 0 && r[i].first == '>')
		{
			ans += wa(r[i].second);
		}
		else if (i == r.size() - 1 && r[i].first == '<')
		{
			ans += wa(r[i].second);
		}
		else
		{
			ans += wa(max(r[i].second, r[i + 1].second)) + wa(min(r[i].second, r[i + 1].second)-1);
			++i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x(n), y(n), a(n);
    rep(i, n) cin >> x.at(i) >> y.at(i) >> a.at(i);

    int x_min = 0, x_max = w, y_min = 0, y_max = h;

    for (int i = 0; i < n; i++)
    {
        if (a.at(i) == 1)
        {
            x_min = max(x_min, x.at(i));
        }
        if (a.at(i) == 2)
        {
            x_max = min(x_max, x.at(i));
        }
        if (a.at(i) == 3)
        {
            y_min = max(y_min, y.at(i));
        }
        if (a.at(i) == 4)
        {
            y_max = min(y_max, y.at(i));
        }
    }

    int answer = max(0, x_max - x_min) * max(0, y_max - y_min);
    cout << answer << endl;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/*************************************************************************************/
void file(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/*************************************************************************************/

const ll maxn=2e5+1,mod=1e9+7;



int main(){

    sync
  //  file();
    
    int n;
    cin>>n;
    
    int ar[n];
    forn(i,n){
    	cin>>ar[i];
    }
    int ans = 0;
    multiset<int> ms;

    forn(i,n){
    	if(i==0) ms.insert(ar[i]);
    	else{
    		auto it = ms.lower_bound(ar[i]);
    		if(it==ms.begin()){
    			ms.insert(ar[i]);
    		}
    		else{
    			it--;
    			ms.erase(it);
    			ms.insert(ar[i]);
    		}
    	}
    }
    cout<<ms.size()<<endl;



  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int gcd(int b,int d){
  int r;
  if(b<d) swap(b, d);
  
  while(d>0){
    r=b%d;
    b=d;
    d=r;
  }
  return b;
}

signed main(){
  int T;
  cin>>T;
  for(int q=0; q<T; q++){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    
    if(A<B || B>D){
      cout<<"No"<<en;
      continue;
    }else if(C>=B){
      cout<<"Yes"<<en;
      continue;
    }
    
    int g=gcd(B,D);
    if(B-g+(A%g)>C){
      cout<<"No"<<en;
    }else cout<<"Yes"<<en;
    
    continue;
  }
}





















































































































































































Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<int> P(N+1);
    vector<int> M(N+1,N+1);
    REPi(i,1,N+1){
        cin>>P[i];
    }
    //input end;
    M[1]=P[1];
    int count=0;
    REPi(i,2,N+1){
        M[i]=min(P[i],M[i-1]);
    }
    REPi(i,1,N+1){
        if(P[i]<=M[i-1]){
            count+=1;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<functional>
#include<stack>
#include<list>
#include<set>
#include<deque>
#include<climits>
using namespace std;
 
typedef long long ll;
 
const int dx[9] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int dy[9] = {0, -1, 0, 1, 1, 1, 0, -1, -1};
 
bool dp[40][1 << 5][20][20];
 
int main(){
    int W, H, N, sx, sy, L[5];
    int px[5][40], py[5][40];
    cin >> W >> H >> N >> sx >> sy;
    sx--;
    sy--;
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
        for (int j = 0; j < L[i]; j++)
        {
            cin >> px[i][j] >> py[i][j];
            px[i][j]--;
            py[i][j]--;
        }
    }
 
    int ss = 0;
    for (int n = 0; n < N; n++)
    {
        if (px[n][0] == sx && py[n][0] == sy)
            ss = ss | (1 << n);
    }
    if (ss == (1 << N) - 1)
    {
        puts("0");
        return 0;
    }
    dp[0][ss][sy][sx] = true;
     
    for (int i = 0; i <= H + W; i++)
    {
        for (int j = 0; j < (1 << N) - 1; j++)
        {
            bool ng = false;
            for (int k = 0; k < N; k++)
            {
                if (((j >> k)&1) == 1) continue;
                if (L[k] - 2 - i <= 0) ng = true;
            }
            if (ng) continue;
            for (int k = 0; k < H; k++)
            {
                for (int l = 0; l < W; l++)
                {
                    if (!dp[i][j][k][l]) continue;
                    for (int m = 0; m < 9; m++)
                    {
                        int nx = l + dx[m];
                        int ny = k + dy[m];
                        int nj = j;
                        if(nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
                        bool onBomb = false;
                        for (int n = 0; n < N; n++)
                        {
                            if (nx == px[n][L[n] - 1] && ny == py[n][L[n] - 1]) onBomb = true;
                            if (i+1 != L[n] - 1 && px[n][i+1] == nx && py[n][i+1] == ny)
                                nj = nj | (1 << n);
                        }
                        if (onBomb) continue;
                        if (nj == (1 << N) - 1)
                        {
                            printf("%d\n", i+1);
                            return 0;
                        }
                        dp[i+1][nj][ny][nx] = true;
                    }
                }
            }
        }
    }
 
    puts("-1");
    return 0;
}

Measured memory_bytes: 1608
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	int i,j,n,minj,temp,count=0;
	int array[] = new int[101];

	Scanner scan = new Scanner(System.in);
	n = scan.nextInt();

	for(i=0;i<n;i++){
	    array[i] = scan.nextInt();
	}

	for(i=0;i<n;i++){
	    minj=i;
	    for(j=i;j<n;j++){
		if(array[j] < array[minj]){
		    minj = j;
		}
	    }
	    if(i!=minj){
	    temp = array[i];
	    array[i] = array[minj];
	    array[minj] = temp;
	    count++;
	    }
	}
	for(i=0;i<n;i++){
	    if(i==n-1){System.out.println(array[i]+"\n"+count);}
	    else System.out.print(array[i]+" ");
	    }
    }
}



Measured memory_bytes: 26364
#include <iostream>
#include<string>
using namespace std;
int main(){
   int N,K;
   cin>>N>>K;
   string S;
   cin>>S;
   K=K-1;
   if(S[K]=='A'){
   S[K]='a';
   }
   else if(S[K]=='B'){
       S[K]='b';
   }
   else if(S[K]=='C'){
       S[K]='c';
   }
   cout<<S<<endl;
   

    


}


Measured memory_bytes: 256