akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    int m = 25 * a / 2;
    int m2 = 25 * (a + 1) / 2;

    int m3 = b * 10;
    int m4 = 10 * (b + 1);

    int mmin = max(m, m3);
    int mmax = min(m2, m4);
    if (mmin > mmax) {
        cout << -1 << endl;
        return 0;
    } else {
        while (mmin < mmax) {
            int tax1 = ((int)((double)(mmin)*0.08));
            int tax2 = ((int)((double)(mmin)*0.10));
            if (tax1 == a && tax2 == b) {
                cout << mmin << endl;
                return 0;
            }
            mmin++;
        }
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
 while t[x]>=0:x=t[x]
 return x
def u(L):
 x,y=map(r,L)
 if x!=y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
d=defaultdict(list)
for l in q:u(l)
i=c=0;b=[];k=(n+~m)*2
for v in a:d[r(i)]+=v,;i+=1
print(k<1and'0'or k>n and'Impossible'or exec("for r,p in d.items():p.sort();c+=p.pop(0);b+=p;k-=1")or c+sum(sorted(b)[:k]))

Measured memory_bytes: 35500
#include <iostream>
using namespace std;
int main(){
    int N,result=0;
    string S;
    cin>>N>>S;
    for(int i=0;i<N-2;i++){
        if(S[i]=='A'){
          if(S[i+1]=='B'){
              if(S[i+2]=='C'){
                  result++;
              }
          }
        }
    }
    cout<<result;
}


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

int main(void) {
	int n;
	long long int count;
	cin >> n;
	count = 0;
	int a[100100];
	int b[100100];
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

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

}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	Scanner sc;
	final static int MAX = 300001;
	int counter;
	int[] msprime;
	Main(){
		counter = 0;
		msprime = new int[ MAX ];
		for( int i = 6; i <= MAX; i += ( i % 7 == 1 ? 5 : 2) ){
			boolean isMSPrime = true;
			for( int j = 6; j * j <= i; j += ( j % 7 == 1 ? 5 : 2) ){
				if( i % j == 0 ){
					isMSPrime = false;
					break;
				}
			}
			if( isMSPrime ){ msprime[ counter++ ] = i; }
		}
	}
	void run(){
		sc = new Scanner( System.in );
		while( true ){
			int n = sc.nextInt();
			if( n == 1 ){ return; }
			System.out.print( n + ":" );
			for( int i = 0; i < counter; i++ ){
				if( n % msprime[ i ] == 0 ){
					System.out.print( " " + msprime[ i ] );
				}
			}
			System.out.println();
		}
	}
	
	public static void main( String[] args ){
		new Main().run();
	}
}

Measured memory_bytes: 14000
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto o(C *x)->decltype(os << *x, 0);
template<class C> static char o(...);
template<class C> typename enable_if<sizeof o<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof o<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;

int n, m, K, a[mxn], b[mxn];
ll cs[mxn];
signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> n >> m >> K;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cs[i] = cs[i-1]+a[i];
    }
    ll sum = 0;
    int mx = upper_bound(cs+1, cs+n+1, K)-(cs+1);
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        sum += b[i];
        if (sum > K) break;
        mx = max(mx, i+int(upper_bound(cs+1, cs+n+1, K-sum)-(cs+1)));
    }
    // ll tot = 0;
    // for (int i = 1, j = 1; i<=n or j<=m; ) {
    //     if (i <= n and (j > m or a[i] <= b[j])) tot += a[i++];
    //     else tot += b[j++];
    //     if (tot > K) return cout << i-1+j-1-1 << '\n', 0;
    // }
    // cout << n+m << '\n';
    cout << mx << '\n';
}

Measured memory_bytes: 6756
#include<bits/stdc++.h>
#define ll long long
#define P pair<string,int>
using namespace std;
 
string d(string e){
    string f;
    for(char g:e){
	if(g!='*')f+=g;
	}
	return f;
    } 
int main(){
    int a,b;
    while(cin>>a>>b,a|b){
	P c[100];
	for(int e=0;e<a;e++){
	    string f;int g;
	    cin>>f>>g;
	    c[e]=P(d(f),g);
	    }
	    unordered_multiset<string>h;
	    for(int i=0;i<b;i++){
		string j;
		cin>>j;
		string k;
		for(int l=7;l!=-1;l--){
		    k=j[l]+k;
		    h.insert(k);
		    }
		}
	    ll s=0;
	    for(P o:c){
		s+=o.second*h.count(o.first);
		}
		cout<<s<<endl;
	}
    }

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

int main()
{
	int i,count = 0;
	char W[11],T[1001];
	
	scanf("%s",W);
	while(1){
		scanf("%s",T);
		if(strcmp(T,"END_OF_TEXT") == 0)  break;
		for(i = 0;i < strlen(W);i++) W[i] = tolower(W[i]);
		for(i = 0;i < strlen(T);i++) T[i] = tolower(T[i]);
		if(strcmp(W,T) == 0) count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[12] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};
int dp[100005];
signed main() {
    int N;
    cin >> N;
    for(int i = 0; i <= 100000; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j < 12; j++) {
            if(i-cnt[j] >= 0) {
                dp[i] = min(dp[i],dp[i-cnt[j]]+1);
            }
        }
    }
    cout << dp[N] << endl;
}



Measured memory_bytes: 4376
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] s = new int[n + 1];
        for(int i = 0 ; i < n; i++) {
            s[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] t = new int[q];
        for(int i = 0; i < q; i++) {
            t[i] = sc.nextInt();
        }

        int ans = 0;
        for(int i = 0; i < q; i++) {
            if(binarySerch(s, n, t[i])) ans++;
        }

        System.out.println(ans);

        sc.close();
    }

    private static boolean binarySerch(int[] a, int n, int key) {
        int left = 0;
        int right = n;
        while(left < right) {
            int mid = (left + right) / 2;
            if(a[mid] == key) {
                return true;
            }else if(key < a[mid]) {
                right = mid;
            }else {
                left = mid + 1;
            }
        }

        return false;
    }
}


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


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

  rep(i,n-1){
      if(w[i][w[i].length()-1]!=w[i+1][0]){
          cout << "No" <<endl;
          return 0;
      }
  }
  rep(i,n-1){
      for(int j= i+1; j<n; ++j){
          if(w[i]==w[j]) {cout << "No" << endl;
          return 0;}
      }
  }
cout << "Yes" << endl;
return 0;
   }

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string  s ; 
    cin >> s ; 
    for (int i=1;i<sz(s);i++){
    	if (s[i] == s[i-1]){
    		co(i<<" "<<i+1);
    		return;
    	}
    	if (i>1){
    		if (s[i] == s[i-2]){
    			co(i-1<<" "<<i+1);
    			return;
    		}
    	}
    }
    co(-1<<" "<<-1);
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> ans;
    for(int i = 1; i <= 100; i++){
        if(a % i == 0 && b % i == 0){
            ans.push_back(i);
        }
    }
    sort(rbegin(ans), rend(ans));
    cout << ans[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

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

bool IsACGT(string s){
    bool flag = true;
    for(int i=0;i<s.size();i++){
        if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
            flag = false;
            break;
        }
    }
    return flag;
}

int main(){
    string s;
    cin >> s;

    int maxs = 0;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size();j++){
            if(IsACGT(s.substr(i,j-i+1))){
                maxs = max(maxs,j-i+1);
            }
        }
    }

    cout << maxs << endl;    
}

Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  console.log(' ' + buildMaxHeap(lines.shift().split(' ')).join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && Number(arr[left]) > Number(arr[largest])) largest = left;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
  return arr;
}



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

const int MAX = 100000;

int n, m;
int sum[MAX + 3];
int travel[MAX + 3];

int main() {
	ios_base::sync_with_stdio(0);
	
	cin >> n >> m;

	int i, road;

	for (i = 1; i < n; i++) {
		cin >> road;
		sum[i + 1] = sum[i] + road;
	}

	for (i = 0; i < m; i++) {
		cin >> travel[i];
	}

	int ans = 0;
	int station = 1;
	for (i = 0; i < m; i++) {
		ans += abs(sum[station + travel[i]] - sum[station]);
		station += travel[i];
		ans %= 100000;
	}

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

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

int main() {
    int a, b;
    cin >> a >> a >> a >> b;
    cout << (b == 1) << endl;
}

Measured memory_bytes: 256
s = str(input())
K = int(input())
S = set()
anslength = K
while 0 < anslength:
    for i in range(0,len(s)-anslength+1):
        S.add(s[i:i+anslength])
    anslength-=1
LS = list(S)
LS.sort()
print(LS[K-1])

Measured memory_bytes: 4464
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%I64d",&x)
using namespace std;
const int N = 2e6+5;
const int mod = 1e9+7;
const ll INF = 1e18;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

int main()
{
	int n;
	cin >> n;
	if(n == 1) cout<<"Hello World"<<endl;
	else
	{
		int a,b;
		cin >> a >> b;
		cout << a+b << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 個数を取得
		Integer n = sc.nextInt();
		for(int i = 0; i < n ; i++){
			String color = sc.next();
			if("Y".equals(color)){
				System.out.println("Four");
				break;
			}else if(i == n-1){
				System.out.println("Three");
			}
		}
	}
}

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

int main(int argc, char const *argv[]){
	int a, b;
	bool c = false;
	cin >> a >> b;
	for(int i = 1; i < 4; i++){
		if((a*b*i) % 2 != 0){
			c = true;
		}
	}
	if(c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

int sum(string s) {
    reverse(s.begin(), s.end());
    int res = 0, ten = 1;
    REP(i, s.size()) {
        int tmp = (int)s[s.size()-1-i]-48;
        if ( tmp > 0 ) {
            res += tmp * ten;
        }
        ten *= 10;
    }
    return res;
}
int dup(int ns[], int i) {
    REP(j, i) {
        if ( ns[i] == ns[j] ) return j;
    }
    return -1;
}

int main() {
    int a, l;
    stringstream ss;

    while (cin >> a >> l, a || l) {
        int ns[21];

        ns[0] = a;

        REP(i, 20) {
            ss.str("");
            ss << a;
            string tmp = ss.str();

            while(tmp.size() < l) {
                tmp = "0" + tmp;
            }

            sort(tmp.begin(), tmp.end());
            int big = sum(tmp);

            reverse(tmp.begin(), tmp.end());
            int sml = sum(tmp);

            ns[i+1] = a = big - sml;
            int res = dup(ns, i+1);
            if ( res >= 0 ) {
                cout << res << " " << ns[i+1] << " " << i+1-res << endl;
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3148
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=1000+10;
const char ch[4]={'L','R','D','U'};
const char dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};

int n,x[N],y[N];
vector<int> c;

signed main() {
    n=read();
    for (int i=1;i<=n;++i) x[i]=read(),y[i]=read();
    for (int i=2;i<=n;++i)
        if ((abs(x[i]+y[i])&1)!=(abs(x[1]+y[1])&1)) {
            puts("-1"); return 0;
        }
    for (int i=30;~i;--i) c.push_back(1<<i);
    if (!(abs(x[1]+y[1])&1)) c.push_back(1);
    printf("%lu\n",c.size());
    for (int i:c) printf("%d ",i); puts("");
    for (int i=1;i<=n;++i) {
        ll nx=0,ny=0;
        for (int j:c) {
            vector<pair<ll,int> > o;
            for (int d=0;d<4;++d) {
                ll tx=nx+dx[d]*j,ty=ny+dy[d]*j;
                o.push_back(make_pair(abs(x[i]-tx)+abs(y[i]-ty),d));
            }
            sort(o.begin(),o.end());
            int d=o.begin()->second;
            putchar(ch[d]),nx+=dx[d]*j,ny+=dy[d]*j;
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
ll a[10005];
int main()
{
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        ll n,k;
        cin >> n >> k;
        for(ll i=0;i<n;i++)
        {
            cin >> a[i];
        }
        sort(a,a+n);
        ll sum = 0;
        for(ll i=0;i<k;i++)
        {
            sum = sum + a[i];
        }
        printf("%lld\n",sum);
    }
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	ll n;
	double b;
	cin>>n>>b;
	ll  c = (b*100 + .5);
	ll res = n*c;
	res = res/100;
	cout<<res;
	//cout<<(ll)floor((n * (b * 100))/100);
	

}

Measured memory_bytes: 3716
N , M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(input().split())
count = 0
for i in range(N):
    r = C
    for j in range(M):
        r += int(A[i][j]) * B[j]
    if r > 0:
        count += 1
print(count)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    s+='S';
    ll maxi=0;
    ll cnt=0;
    for(ll i=0;i<s.length();i++)
    {
        if(s[i]=='R')
            cnt++;
        else
        {
            maxi=max(cnt,maxi);
            cnt=0;
        }
    }
    cout<<maxi<<"\n";
}

Measured memory_bytes: 3592
# abc110_c.py
# https://atcoder.jp/contests/abc110/tasks/abc110_c

# C - String Transformation /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# 英小文字のみからなる文字列 S, Tが与えられます。
# 文字列 Sに対して、次の操作を何度でも行うことができます。
# 操作: 2つの異なる英小文字 c1, c2 を選び、S に含まれる全ての c1 を c2 に、c2 を c1に置き換える
# 0回以上操作を行って、S を Tに一致させられるか判定してください。

# 制約
#     1≤|S|≤2×10^5
#     |S|=|T|
#     S, Tは英小文字のみからなる

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S
# T

# 出力
# Sを Tに一致させられる場合は Yes、そうでない場合は No を出力せよ。

# 入力例 1
# azzel
# apple

# 出力例 1
# Yes

# 次のように操作を行えば、azzel を apple にできます。
#     c1として e を、c2として l を選ぶと、azzel が azzle になる
#     c1として z を、c2として p を選ぶと、azzle が apple になる

# 入力例 2
# chokudai
# redcoder

# 出力例 2
# No

# どのように操作を行っても chokudai を redcoder にできません。

# 入力例 3
# abcdefghijklmnopqrstuvwxyz
# ibyhqfrekavclxjstdwgpzmonu

# 出力例 3
# Yes


def calculation(lines):
    # N = int(lines[0])
    # X, Y = list(map(int, lines[0].split()))
    S = lines[0]
    T = lines[1]
    ns = list()
    nt = list()
    for c in 'abcdefghijklmnopqrstuvwxyz':
        s = len(S) - len(S.replace(c, ''))
        ns.append(s)
        t = len(T) - len(T.replace(c, ''))
        nt.append(t)
    ns.sort()
    nt.sort()
    if ns == nt:
        return ['Yes']
    else:
        return ['No']


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['azzel', 'apple']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['chokudai', 'redcoder']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['abcdefghijklmnopqrstuvwxyz', 'ibyhqfrekavclxjstdwgpzmonu']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

int main(){
  int r, D, x0;
  cin >> r >> D >> x0;
  
  vector<int> x(11, 0);
  x[0] = x0;
  
  for(int i=0; i<10+1; ++i) {
    x[i+1] = r*x[i] - D;
  }
  
  for(int i=1; i<10+1; ++i) {
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 256
n, m = map(int, input().split())

l = set()
for i in range(n):
    l.add(i+1)

h = list(map(int, input().split()))

s = set()

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] == h[b-1]:
        s.add(a)
        s.add(b)
    if h[a-1] < h[b-1]:
        s.add(a)
    if h[a-1] > h[b-1]:
        s.add(b)

#    print(s)

ans = list(l - s)
#print(ans)
print(len(ans))









Measured memory_bytes: 27484
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	StringBuilder sb = new StringBuilder();
	int n = Integer.parseInt(scan.nextLine());
	int[] a = new int[n];
	for (int i = 0; i < n; i++) {
	    a[i] = scan.nextInt();
	}
	int q = partition(a, 0, n-1);
	for (int i = 0; i < q; i++) {
	    sb.append(a[i] + " ");
	}
	sb.append("[");
	sb.append(a[q]);
	sb.append("] ");
	for (int i = q+1; i < n - 1; i++) {
	    sb.append(a[i] + " ");
	}
	sb.append(a[n-1]);
	System.out.println(sb);
    }
    static int partition (int[] a, int p, int r) {
	int x = a[r];
	int i = p - 1;
	int tmp;
	for (int j = p; j < r; j++) {
	    if (a[j] <= x) {
		i = i + 1;
		tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	    }
	}
	tmp = a[i+1];
	a[i+1] = a[r];
	a[r] = tmp;
	return i+1;
    }
}

Measured memory_bytes: 67588
x, y = map(int, raw_input().split())

if x % 3 == 0 or y % 3 == 0:
	print 0
else:
	m = 10000000
	for i in range(1, x):
		j = y / 2
		s1 = y * i
		s2 = (x - i) * j
		s3 = (x - i) * (y - j)
		l = [s1, s2, s3]
		l.sort()
		if l[-1] - l[0] < m:
			m = l[-1] - l[0]
			# ix = i
			# ij = j
	# print m
	x, y = y, x
	for i in range(1, x):
		j = y / 2
		s1 = y * i
		s2 = (x - i) * j
		s3 = (x - i) * (y - j)
		l = [s1, s2, s3]
		l.sort()
		if l[-1] - l[0] < m:
			m = l[-1] - l[0]
	if m > x:
		m = x
	if m > y:
		m = y
	print m

Measured memory_bytes: 5764
A, B = map(int, input().split())
C = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if C.index(A) > C.index(B):
    print('Alice')
elif C.index(A) < C.index(B):
    print('Bob')
else:
    print('Draw')

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

int N,M,X;
int mins=100100100;
vector<int> money;
vector<int> skillUpBpook;

int sum(vector<bool> bl,vector<vector<int>> skillUp){
    vector<int> readed(M+1,0);
    for(int a=0;a<N;a++){
        if(bl[a]==true){
            readed[0]+=money[a];
            for(int k=0;k<M;k++){
                readed[k+1]+=skillUp[a][k];
            }
        }
    }
    //for(int k=0;k<=M;k++)cout << readed[k]<<" ";
    //cout <<endl;
    for(int k=1;k<=M;k++){
        //cout << readed[k]<<" ";
        if(readed[k]<X){
            return 1001001000;
        }
        //cout <<endl;
    }
    //cout << "return";
    return readed[0];
}

void Dfs(vector<bool> df,vector<vector<int>> skillUp){
    if(df.size()==N){
        //cout <<df[0]<<df[1]<<df[2]<<endl;
        int cc=sum(df,skillUp);
        if(cc<mins){
            mins=cc;
        }
        return;
    }else if(df.size()<N){
        df.push_back(false);
        Dfs(df,skillUp);
        df.pop_back();
        df.push_back(true);
        Dfs(df,skillUp);
    }
}

int main(void)
{
    cin >> N>>M>>X;
    money.resize(N);
    skillUpBpook.resize(M);
    vector<vector<int>> skillUp(N,skillUpBpook);
    for(int a=0;a<N;a++){
        cin >> money[a];
        for(int b=0;b<M;b++){
            cin >> skillUp[a][b];
        }
    }
    vector<bool> df;
    Dfs(df,skillUp);
    if(mins==100100100){
        cout <<"-1"<<endl;
        return 0;
    }
    cout <<mins<<endl;
}

Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable PossibleNullReferenceException
// ReSharper disable AssignNullToNotNullAttribute

namespace ProCon
{
    internal class Program
    {
        private static List<int>[] _link;
        private static int[] _group;
        private static int[] _groupMemberNum;

        private static void Main(string[] args)
        {
            var nmk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = nmk[0];
            var m = nmk[1];
            var k = nmk[2];
            _link = new List<int>[n];
            var hate = new List<int>[n];
            _group = new int[n];
            for (int i = 0; i < n; ++i)
            {
                _link[i] = new List<int>();
                hate[i] = new List<int>();
                _group[i] = -1;
            }
            for (int i = 0; i < m; ++i)
            {
                var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                _link[ab[0]-1].Add(ab[1] - 1);
                _link[ab[1]-1].Add(ab[0] - 1);
            }
            for (int i = 0; i < k; ++i)
            {
                int[] hTmp =  Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(tmp => tmp).ToArray();
                hTmp[0]--;
                hTmp[1]--;
                hate[hTmp[0]].Add(hTmp[1]);
                hate[hTmp[1]].Add(hTmp[0]);
            }
            int groupId = 0;
            _groupMemberNum = new int[n];
            for (int i = 0; i < n; ++i)
            {
                if (_group[i] != -1) continue;
                _groupMemberNum[groupId] = Visit(i, groupId);
                groupId++;
            }
            var suggest = new int[n];
            for (int i = 0; i < n; ++i)
            {
                var g = _group[i];
                suggest[i] = _groupMemberNum[g]-1-_link[i].Count- hate[i].Count(tmp => _group[tmp] == g);
            }
            Console.WriteLine(string.Join(" ", suggest.Select(tmp=>tmp.ToString())));
        }

        private static int Visit(int idx, int group)
        {
            if (_group[idx] != -1) return 0;
            int num = 1;
            _group[idx] = group;
            foreach (var l in _link[idx])
            {
                num+=Visit(l, group);
            }
            return num;
        }
    }
}


Measured memory_bytes: 66276
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    long long int N, ans = 0;
    cin >> N;
    vector<int> a(3 * N);

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

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

    for (int i = 0; i < N; i++) {
        ans += a[3 * N - 2 * (i + 1)];
    }

    cout << ans;

    return 0;

}



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

#define MAX 100002

int n;
int m;

int t;

map<long long int,long long int> mp;

int q;

#define MAX_T 1002

long long int dp[MAX_T];
long long int f[MAX_T];

long long int tmp[MAX_T];

int main(){
	cin>>n>>m>>t;
	mp[0]=0;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		if(mp.count(a%t)==0){
			mp[a%t]=0;
		}
		mp[a%t]=max(mp[a%t],(long long int)a);
	}
	for(int i=0;i<t;i++)dp[i]=LLONG_MIN;
	dp[0]=0;
	for(int i=0;i<t;i++){
		f[i]=LLONG_MIN;
		if(mp.count(i)){
			f[i]=mp[i];
		}
	}
	while(m){
		if(m&1){
			for(int j=0;j<t;j++)tmp[j]=dp[j];
			for(int j=0;j<t;j++){
			if(dp[j]==LLONG_MIN)continue;
				for(int k=0;k<t;k++){
				if(f[k]==LLONG_MIN)continue;
					tmp[(j+k)%t]=max(tmp[(j+k)%t],dp[j]+f[k]);
				}
			}
			for(int j=0;j<t;j++)dp[j]=tmp[j];
		}
		for(int j=0;j<t;j++)tmp[j]=f[j];
			for(int j=0;j<t;j++){
			if(f[j]==LLONG_MIN)continue;
				for(int k=0;k<t;k++){
				if(f[k]==LLONG_MIN)continue;
					tmp[(j+k)%t]=max(tmp[(j+k)%t],f[j]+f[k]);
				}
			}
			for(int j=0;j<t;j++)f[j]=tmp[j];
		m>>=1;
	}
	for(int j=t-2;j>=0;j--){
		dp[j]=max(dp[j],dp[j+1]);
	}
	cin>>q;
	while(q--){
		int a,b;
		scanf("%d%d",&a,&b);
		if(dp[a]>=(long long int)(b)*(long long int)(t)){
			puts("yes");
		}
		else{
			puts("no");
		}
	}
	return 0;
}


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

int main(){
    auto f = [](long a){
        long t = a & ~3;
        long ret(0);
        for(; t <= a; ++t){
            ret ^= t;
        }
        return ret;
    };
    long A, B;
    cin >> A >> B;
    cout << (f(B) ^ (A ? f(A - 1) : 0)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N,A,B;cin >> N >> A >> B;
  ll n = N/(A+B);
  cout << n*A + min(A,(N-n*(A+B))) << endl;
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int64 grundy(int64 x, int64 y){
    int64 s = x+y;
    if(s % 2 == 0){
        return abs(x-y)/2;
    }else{
        return (abs(x-y)-1)/2 * (s/2);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 x,y;
    cin >> x >> y;
    if(grundy(x,y)){
        ANS("Alice");
    }else{
        ANS("Brown");
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int a, b;

    cin >> a >> b;

    cout << max(a+b, max(a-b, a*b)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define POS(j,k) ((j)*(1+n)+(k))

void run(void){
  int n;
  scanf("%d",&n);
  int cnt[4]={0,0,0,0};
  int i,j,k;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    cnt[a]++;
  }
  double *dp=(double *)calloc((1+cnt[2]+cnt[3])*(1+n),sizeof(double));
  for(i=0;i<=cnt[3];i++){
    for(j=0;j<=cnt[2]+cnt[3]-i;j++){
      for(k=(i==0 && j==0?1:0);k<=n-i-j;k++){
	double local=n;
	if(i>0) local+=i*dp[POS(j+1,k)];
	if(j>0) local+=j*dp[POS(j-1,k+1)];
	if(k>0) local+=k*dp[POS(j,k-1)];
	dp[POS(j,k)]=local/(i+j+k);
      }
    }
  }
  printf("%.9f\n",dp[POS(cnt[2],cnt[1])]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v(n);
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        v[i].first = x + l, v[i].second = x - l;
    }
    sort(all(v));
    int ma = -INF;
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (ma <= v[i].second) {
            res++;
            ma = v[i].first;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 1792
N,Y=map(int,input().split())
count=0
cost=0
for i in range(N+1):
    cost=10000*i
    cost2=cost
    for j in range(N-i+1):
        cost=cost+5000*j
        k=N-(i+j)
        cost=cost+1000*k
        if(cost==Y):
            print(str(i)+" "+str(j)+" "+str(k))
            count += 1
            break
        cost=cost2
    if(count==1):
        break
    cost=0
    cost2=0

if(count==0):
    print(str(-1)+" "+str(-1)+" "+str(-1))
    

Measured memory_bytes: 3064
from itertools import groupby
n,k=map(int,input().split())
l=sorted([len(list(g)) for k,g in groupby(input())])[::-1]
ans=sum(l[:min(2*k,len(l))])+sum(x-1 for x in l[min(2*k,len(l)):])
print(ans-(ans==n))

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstdlib> 
#include <string.h>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <algorithm>
#include <cmath>
#define PI 3.1415926535897932384626433832795l
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define deci(n) cout<<fixed<<setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i,a,b) for(int i = a; i < b; i++)
#define ForA1(i,a,b) for(int i = b - 1; i >= a; i--)
#define ForB1(i,a,b) for(int i = b; i > a; i--)
#define ForB(i,a,b) for(int i = a; i <= b; i++)
#define INT_SIZE 18 
#define maxn 100010

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

int h[maxn], dp[maxn];

int main()
{
    IOS;      
    int n,k,l; cin >> n >> k;
    ForB(i,1,n) cin >> h[i];
    ForB(i,0,maxn - 1) dp[i] = MOD;
    dp[1] = 0;
    ForB(i,1,n){
        l = k;
        for(int j = i - 1; j > 0 && l > 0; j--, l--){
            dp[i] = min(dp[j] + abs(h[i] - h[j]), dp[i]);
        }
    }
    cout << dp[n] << '\n';
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0 ;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void MAIN() {
  int n, m;
  cin >> n >> m;
  vector<string> s(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    s[i] = "-" + s[i];
  }
  struct tup {
    int fi, sc, th;
    tup() {}
    tup(int fi, int sc, int th):
      fi(fi), sc(sc), th(th) {}
  };
  vector<int> r = {-1, 0, 1, 0};
  vector<int> c = {0, -1, 0, 1};
  vector<vector<int>> v(n + 1, vector<int>(m + 1));
  queue<tup> q;
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    if (s[i][j] == '#') q.push(tup(i, j, 1));
  }
  while (q.size()) {
    int x = q.front().fi;
    int y = q.front().sc;
    int z = q.front().th;
    q.pop();
    if (x < 1 || x > n || y < 1 || y > m) continue;
    if (v[x][y]) continue;
    v[x][y] = z;
    for (int i = 0; i < 4; i++) {
      q.push(tup(x + r[i], y + c[i], z + 1));
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    ans = max(ans, v[i][j] - 1);
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 108884
def calc(n, w, v)
  r = [0] * 100
  v.each do |e|
    r[e / w] += 1
  end
  r.map.with_index do |e, i|
    e.to_f / r.max * (v.max / w - i) / (v.max / w)
  end.inject(:+) + 0.01
end
loop do
  n, w = gets.split.map(&:to_i)
  break if n == 0
  v = []
  n.times do |i|
    v[i] = gets.to_i
  end
  puts calc(n, w, v)
end

Measured memory_bytes: 8800
N = int(input())
# X * 1.08 // 1.0  = Nとなる. X = N/1.08
# Xは1.08をかけたあとでNになる可能性のあるもので最も小さいもの,Nを1.08で割ったものを切り上げる
X = N/1.08
if int(X)*1.08==N:
    X=int(N/1.08)
else: 
    X=int(N/1.08) + 1
# Xでも大きすぎた場合(1.08を掛けるとNを超える場合)
if X * 1.08 >= N+1:
    print(":(")
else:
    print(X)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   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;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
 
  int main(){
      lint n;
      cin>>n;
      lint t=n-1;
      set<lint> st;
      lint ans=1;
      lint count=0;
     rep(i,sqrt(t)){
            if(t%(i+1)==0){
            st.insert(t/(i+1));
            if(i==0)continue;
            st.insert(i+1);
            }
     }

     count=st.size();
    rep(i,sqrt(n)){
        lint k=n;
        if(n%(i+1)==0){
               lint j=n/(i+1);
               if(j==1)continue;
             while(k%j==0){
                k/=j;
            }
            if(k==1||k%j==1)st.insert(j);
            k=n;
            if(i==0)continue;
            while(k%(i+1)==0){
                k/=(i+1);
            }
            if(k==1||k%(i+1)==1)st.insert(i+1);
         
         

        }
    }
    st.insert(1);
    st.erase(1);
    cout<<st.size();
  }
  
     


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
typedef long long ll; typedef long double db;

struct cir
{
	double x, y, r;
	cir(double &a, double &b, double c)
	{
		x = a;
		y = b;
		r = c;
	}
	cir() {}
};
double cul_dist(double a, double b, double x, double y, double r1, double r2)
{
	double ans = sqrt((a - x)*(a - x) + (b - y)*(b - y)) - r1 - r2;
	if (ans < 0) return 0;
	else return ans;
}

int main()
{
	vector<cir> c;
	double t1, t2, t3, t4;
	cin >> t1 >> t2 >> t3 >> t4;
	c.push_back(cir(t1, t2, 0.0));
	c.push_back(cir(t3, t4, 0.0));

	int n;
	cin >> n;
	while (n--)
	{
		double x, y, r;
		cin >> x >> y >> r;
		c.push_back(cir(x, y, r));
	}

	vector<vector<double>> dist((int)c.size(), vector<double>((int)c.size()));

	for (int i = 0; i < (int)c.size(); ++i)
		for (int j = i + 1; j < (int)c.size(); ++j)
		{
			dist[i][j] = dist[j][i] = cul_dist(c[i].x, c[i].y, c[j].x, c[j].y, c[i].r, c[j].r);
		}

	for (int k = 0; k < (int)dist.size(); ++k)
		for (int i = 0; i < (int)dist.size(); ++i)
			for (int j = 0; j < (int)dist.size(); ++j)
			{
				if (dist[i][k] + dist[k][j] < dist[i][j])
					dist[i][j] = dist[i][k] + dist[k][j];
			}

	cout << fixed << setprecision(10) << dist[0][1] << endl;

	return 0;
}

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

using namespace std;

#define PRB ""
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define EP emplace_back
#define SZ(A) (int) A.size()
#define FOR(i, l, r) for (int i = l; i <= r; i++)
#define FORD(i, r, l) for (int i = r; i >= l; i--)
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

int main(){
    string s, t;
    cin >> s >> t;
    int res = 0;
    FOR(i, 0, 2)
        if (s[i] == t[i])
            res++;
    cout << res;

    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np


def inputs(func=lambda x: x, sep=None, maxsplit=-1):
	return map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))

def input_row(n : int, type=np.int, **kwargs):
	return np.fromiter(inputs(type, **kwargs), dtype=type)

def input_2d(nrows : int, ncols : int, type=np.int, **kwargs):
	data = np.zeros((nrows, ncols), dtype=type)
	for i in range(nrows):
		data[i, :] = input_row(ncols, type, **kwargs)
	return data

from collections import deque
import numpy as np

N, M = inputs(int)
rooms_from = [[] for _ in range(N)]
for i in range(M):
	A, B = inputs(int)
	A -= 1
	B -= 1
	rooms_from[A].append(B)
	rooms_from[B].append(A)

INF = N

nexts = deque()
distance = np.full(N, INF, dtype=int)
direction = np.full(N, -1, dtype=int)

nexts.append((0, 0, -1))

while nexts:
	here, d, to = nexts.popleft()
	if distance[here] == INF:
		distance[here] = d
		direction[here] = to
		for room in rooms_from[here]:
			nexts.append((room, d + 1, here))

print('Yes')
for i in range(1, N):
	print(direction[i] + 1)


Measured memory_bytes: 70688
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
using namespace std;
void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll r = 0;
    for(ll i = 0;i < n;i++)
    if(s[i] == 'R')
    r++;
    ll cnt = 0;
    for(ll i = 0;i < r;i++)
    {
        if(s[i] == 'W')
        cnt++;
    }
    cout<<cnt<<endl;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = input[0];
            var K = input[1];

            var H = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Array.Sort(H);
            Array.Reverse(H);

            for (var i = 0; i < K; i++)
            {
                if (i >= H.Length)
                {
                    break;
                }
                H[i] = 0L;
            }

            Console.WriteLine(H.Sum());
        }
    }
}

Measured memory_bytes: 37120
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
#define minn(x,y) x=min(x,y)
#define maxx(x,y) x=max(x,y)
using namespace std;
string s;
int main()
{
	int i,j,k,n,m,x=0,y=0,z=0,t;
	scanf("%d",&n);
	cin>>s;
	for(i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			x++;
		}
		else if(s[i]=='G')
		{
			y++;
		}
		else
		{
			z++;
		}
	}
	ll ans=1ll*x*y*z;
	for(i=0;i<n;i++)
	{
		for(j=1;i+2*j<n;j++)
		{
			if(s[i]!=s[i+j]&&s[i]!=s[i+2*j]&&s[i+j]!=s[i+2*j])
			{
				ans--;
			}
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3832
a,b,h,m = map(int, input().split())


phi = m * 6

theta = h * 30 + 0.5 * m

import math

apoint = (a*math.cos(math.radians(theta)), a*math.sin(math.radians(theta)))
bpoint = (b*math.cos(math.radians(phi)),   b*math.sin(math.radians(phi)))

#print(theta,phi, apoint, bpoint)

xd = abs(apoint[0] - bpoint[0])
yd = abs(apoint[1] - bpoint[1])

#print(xd, yd)

ans = math.sqrt(math.pow(xd,2) + math.pow(yd,2))

print(ans)


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n;
	cin >> n;
	cout << (1+n)*n/2 << endl;
}

Measured memory_bytes: 256