akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    string N; cin >> N;
    int s = 0;
    for(char c: N) s += (int)(c - '0');
    chOut(s % 9 == 0, "Yes", "No");

    return 0;
}


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

int a[11];
int main(){

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

    sort(a,a+n);

    int max = a[n-1],sum = 0;

    for(int i=0;i<n-1;i++)
        sum += a[i];

    sum += a[n-1]/2;

    cout << sum << endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main() {
    int S,W;
 
    cin >> S >> W;
 
    if(S <= W){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3620
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    set<ll>s;
    set<ll>:: iterator it;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    sort(a,a+n);
    ll c=0;
    ll b[n];
    for(it=s.begin(); it!=s.end(); it++)
    {
        b[c]=*it;
        c++;
    }
    sort(b,b+c);
    //for(int i=0;i<c;i++)cout<<b[i]<<" ";
    //cout<<endl;
    if(s.size()<=2)
        cout<<0<<endl;
    else
    {
        ll mc=0;
        for(ll i=0; i<=c-3; i++)
        {
            for(int j=i+1; j<=c-2; j++)
            {
                for(int k=j+1; k<c; k++)
                {
                    if(b[i]+b[j]>b[k])
                    {
                        int  l=lower_bound(a,a+n,b[i])-a;
                        int u=upper_bound(a,a+n,b[i])-a;
                        int l1=lower_bound(a,a+n,b[j])-a;
                        int u1=upper_bound(a,a+n,b[j])-a;
                        int l2=lower_bound(a,a+n,b[k])-a;
                        int u2=upper_bound(a,a+n,b[k])-a;
                        //cout<<b[i]<<" "<<b[j]<<" "<<b[k]<<endl;
                        mc+=(u-l)*(u1-l1)*(u2-l2);
                    }
                }
            }
        }
        cout<<mc<<endl;
    }

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define PPC(x) __builtin_popcount((x))
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
using namespace std;

const int maxN = 1000001, mod = 998244353;

inline void add_mod(long long& a, long long b)	{   a = (a + b) % mod;  }
inline void mult_mod(long long& a, long long b)	{   a = a * b % mod;    }
inline void sub_mod(long long& a, long long b)	{	a = ((a - b) % mod + mod) % mod;	}

long long qpow(long long a, long long b)
{
    long long res0 = 1;
    for (; b!=0; b>>=1)
    {
        if (b & 1)  mult_mod(res0, a);
        mult_mod(a, a);
    }
    return res0;
}

int lpd[maxN];
long long sum0[maxN], sum2[maxN], w[maxN];
vector <int> divs[maxN];

int main()
{
	FOR(i, 1, maxN)
		lpd[i] = i;
	for (int i=2; i*i<maxN; i++)
		if (lpd[i] == i)
			for (int j=i*i; j<maxN; j+=i)
				lpd[j] = min(lpd[j], i);
			
	divs[1].pb(1);	
	FOR(i, 2, maxN)
	{
		int p = lpd[i], j = i / p;
		divs[i] = divs[j];
		for (int d : divs[j])
			if (j % (d * p) != 0)
				divs[i].pb(d * p);
	}	
			
	int n;
	scanf ("%d", &n);

	while (n--)
	{
		int a;
		scanf ("%d", &a);
		for (int d : divs[a])
		{
			add_mod(sum2[d], sum0[d] * a);
			add_mod(sum0[d], a);
		}
	}
	
	long long res = 0;
	FOR(i, 1, maxN)
	{
		for (int d : divs[i])
			if (d != i)
				add_mod(w[i], w[d]);
		mult_mod(w[i], mod-1);
		add_mod(w[i], qpow(i, mod-2));
		add_mod(res, sum2[i] * w[i]);
	}

	printf("%lld\n", res);
	return 0;
}



Measured memory_bytes: 136192
#include<stdio.h>
#include<math.h>
int h[100010],a[100010];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&h[i]);
	a[1]=fabs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	{
		if((a[i-2]+fabs(h[i]-h[i-2]))<(a[i-1]+fabs(h[i]-h[i-1])))
			a[i]=a[i-2]+fabs(h[i]-h[i-2]);
		else
			a[i]=a[i-1]+fabs(h[i]-h[i-1]);

       // printf("%d ",a[i]);
	}
	//printf("\n");
	printf("%d\n",a[n-1]);
}

Measured memory_bytes: 896
# n choose 0, n choose 1, ..., n choose kすべて一気に求める
def binomials_p(n, k, p):
    '''
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: [n choose 0 mod p, n choose 1 mod p, ..., n choose k mod p]
    '''
    binomials = [1, n] # binomial[i] = n choose i mod p
    inv = [0, 1] # inv[i] : inverse of i mod p
    for i in range(2, k + 1):
        inv.append(( inv[p % i] * (p - p//i) ) % p ) # inverse of i
        binomials.append(binomials[i - 1] * (n - i + 1) * inv[i] % p)

    return binomials

# a^n mod p
def exp_by_sq_p(a, n, p):
    if n == 0:
        exp = 1
    elif n == 1:
        exp = a % p
    elif  n % 2 == 0:
        exp = exp_by_sq_p(a * a % p, n // 2, p)
    else:
        exp = a * exp_by_sq_p(a * a % p, (n - 1) // 2, p) % p
    return exp % p

N, M, K = [int(x) for x in input().split()]
p = 998244353

binomials = binomials_p(N - 1, K, p)
ans = 0
pow = 1 # (m - 1)^0 mod p
for j in range(K + 1):
    ans = (ans + binomials[K - j] * pow % p) % p
    pow = pow * (M - 1) % p

ans = ans * M * exp_by_sq_p(M - 1, N - K - 1, p) % p

print(ans)

Measured memory_bytes: 24828
#include <iostream>

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int N, a, b, c;
    std::cin >> N;
    for (int i = 0; i < N; ++i) {
        std::cin >> a >> b >> c;
        if (a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b)
            std::cout << "YES" << std::endl;
        else
            std::cout << "NO" << std::endl;
    }
}



Measured memory_bytes: 3124
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()

def solve():
    N = int(single_input())
    edge = [[] for i in range(N)]
    for i in range(N-1):
        u, v, w = map(int, line_input())
        edge[u-1].append((v-1, w))
        edge[v-1].append((u-1, w))
    
    col = [-1] * N
    que = collections.deque()
    que.append((0, 0))
    while que:
        nownode, nowdist = que.popleft()
        if col[nownode] == -1:
            col[nownode] = nowdist
            for nextnode, weight in edge[nownode]:
                if col[nextnode] == -1:
                    que.append((nextnode, nowdist + weight))
    for i in range(N):
        print(col[i] % 2)

    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 43216
import java.util.*;

public class Main{
	static int cmps = 0;

	static void merge(int[] A, int left, int mid, int right){
		int n1 = mid - left;
		int n2 = right - mid;
		int[] L = new int[n1+1];
		int[] R = new int[n2+1];
		for(int i = 0; i < n1; i++) L[i] = A[left + i];
		for(int i = 0; i < n2; i++) R[i] = A[mid + i];
		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for(int k = left; k < right; k++){
			if(L[i] < R[j]){
				A[k] = L[i];
				i++;
				cmps++;
			}else{
				A[k] = R[j];
				j++;
				cmps++;
			}
		}
	}

	static void mergeSort(int[] A, int left, int right){
		if(left+1 < right){
			int mid = (left + right) / 2;
			mergeSort(A, left, mid);
			mergeSort(A, mid, right);
			merge(A, left, mid, right);
		}
	}

	public static void main(String[] args){

		Scanner scan = new Scanner(System.in).useDelimiter("[\\s]+");
		int n = scan.nextInt();
		int[] S = new int[n];
		for(int i = 0; i < n; i++){
			S[i] = scan.nextInt();
		}
		mergeSort(S, 0, n);
		System.out.print(S[0]);
		for(int i = 1; i < n; i++)
			System.out.print(" "+ S[i]);
		System.out.println("");
		System.out.printf("%d\n", cmps);
	}
}

Measured memory_bytes: 172164
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=105;

int main()
{
    IO;
    int n;
    cin >> n;
    cout<<n/3<<endl;
    re 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<char> C(N);
    vector<int> L(N), pass(N), ord;
    for(int i=0; i<N; i++) {
        cin >> C[i] >> L[i];
        ord.emplace_back(i);
    }

    sort(ord.begin(), ord.end(), [&L](int a, int b) {
            return L[a] < L[b];
        });
    
    int ans = 0;
    for(int i=0; i<N; i++) {
        int k = ord[i];
        if(C[k] == 'n' or pass[k]) continue;
        ans++;
        for(int j=k; j>=0; j--) {
            if(C[j] == 'n' and L[j] >= L[k]) break;
            if(C[j] == 'y' and L[j] >= L[k]) pass[j] = true;
        }
        for(int j=k+1; j<N; j++) {
            if(C[j] == 'n' and L[j] >= L[k]) break;
            if(C[j] == 'y' and L[j] >= L[k]) pass[j] = true;
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, W;
int w[11111], v[11111];
int dp[111][11111];

void print() {
   for (int i = 0; i <= N; i++) {
      for (int j = 0; j <= W; j++) {
         printf(" %2d", dp[i][j]);
      }
      puts("");
   }
}

int main() {
   cin >> N >> W;
   rep (i, N) cin >> v[i] >> w[i];

   for (int i = 0; i <= W; i++) dp[0][i] = 0;

   for (int i = 0; i < N; i++) {
      for (int j = 0; j <= W; j++) {
         if (j >= w[i]) {
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
         } else {
            dp[i+1][j] = dp[i][j];
         }
      }
   }
   cout << dp[N][W] << endl;

   return 0;
}


Measured memory_bytes: 7420
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 2000000000
#define PI 3.14159265358979323846
using namespace std;
int n, w;
pair<int, int> a[105];
long long dp[105][100005];
long long solve(int idx, int rem)
{
	if(idx==n-1)
	{
		if(a[idx].first <= rem)
			return a[idx].second;
		return 0;
	}
	if(dp[idx][rem]!=-1)
		return dp[idx][rem];
	dp[idx][rem]=solve(idx+1, rem);
	if(a[idx].first <= rem)
		dp[idx][rem]=max(dp[idx][rem], a[idx].second+solve(idx+1, rem-a[idx].first));
	return dp[idx][rem];
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> w;
	for(int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;
	for(int i = 0; i < n; i++)
		for(int j = 0; j <= w; j++)
			dp[i][j]=-1; 
	cout << solve(0, w) << '\n';
}

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

using namespace std;

#pragma GCC optimize ("-O3")

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define vll vector<ll> 
#define vs vector<string>
#define vc vector<char>
#define vpll vector<pair<ll,ll>>
#define tc ll t=0;cin>>t;while(t--)
#define pb push_back
#define pop pop_back
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define maxe *max_element
#define mine *min_element
#define f first
#define s second
#define vli vll::iterator 
#define mp make_pair
#define unmap unordered_map
#define unmapll unordered_map<ll,llt>
#define max_val 99999999
#define min_val -99999999
#define mod 1000000007
const ld PI = 3.141592653589793;

bool isPowerOfTwo (int x) 
{ 
  return x && (!(x&(x-1))); 
} 


int main()
{
    IOS
    #ifdef LOCAL
            freopen("C:\\Users\\Just Coding Things\\Codeforces\\input.txt","r",stdin);
            freopen("C:\\Users\\Just Coding Things\\Codeforces\\output.txt","w",stdout);
        #endif
    ll n,i;
    cin>>n;
    vs str;
    string s;
    for(i=0;i<n;i++)
    {
    	cin>>s;
    	str.pb(s);
	}
    set<string> st;
    for(i=0;i<n;i++)
    {
    	st.insert(str[i]);
	}
	cout<<st.size();
    
    return 0;
}

Measured memory_bytes: 25020
a = int(input())
b = list(map(int, input().split()))
c = sum(b)
d = 0
for i in range(a):
    d += b[i]
    if d >= c // 2:
        print(min(abs(c-d-d), abs(c - d + b[i] - d + b[i])))
        exit()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll n;cin>>n;
    ll num=1, cnt=0;
    while(num<=n){
        num*=2;
    }
    num/=2;
    cout<<num<<endl;
    return 0;
}


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

int main()
{
  string od;
  cin >> od;
  
  int a = 700;
  if (od[0] == 'o') a+=100;
  if (od[1] == 'o') a+=100;
  if (od[2] == 'o') a+=100;
  
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int res = sol(x);
    System.out.println(res);
  }

  private static int sol(int x) {
    return (x * x * x);
  }
}

Measured memory_bytes: 26180
#include<iostream>

using namespace std;

int main(){
	int N;
	cin>>N;
	
	long power=1;
	for(int i=1 ; i<=N ; i++){
		power*=i;
		if(power>=1000000007)power=power%1000000007;
	}
	cout<<power<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, k; cin >> a >> b >> k;
    ll s = max(0LL, a - k);
    ll t = max(b - max((k - a), 0LL), 0LL);
    cout << s << " " << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<cstdio>
using namespace std;
class Point {
public:
	double x, y;
};
double distance(Point x, Point y) {
	return pow(pow(fabs(x.x - y.x), 2) + pow(fabs(x.y - y.y), 2), 0.5);
}
int main() {
	cout << setprecision(4);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		Point p[3], s;
		for (int i = 0; i < 3; i++) {
			cin >> p[i].x >> p[i].y;
		}
		double a, b, c, d, e, f;
		a = (-2)*p[0].x + 2 * p[1].x;
		b = (-2)*p[0].y + 2 * p[1].y;
		c = (-2)*p[0].x + 2 * p[2].x;
		d = (-2)*p[0].y + 2 * p[2].y;
		e = pow(p[0].x, 2) + pow(p[0].y, 2) - pow(p[1].x, 2) - pow(p[1].y, 2);
		f = pow(p[0].x, 2) + pow(p[0].y, 2) - pow(p[2].x, 2) - pow(p[2].y, 2);
		s.x = (b*f - d*e) / (a*d - b*c);
		s.y = (a*f - c*e) / (b*c - a*d);
		double k = distance(p[0], s);
		s.x = round(s.x * 1000) / 1000;
		s.y = round(s.y * 1000) / 1000;
		k = round(k * 1000) / 1000;
		printf("%.3f %.3f %.3f\n", s.x, s.y, k);
	}
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
bool ar[1000005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,t,n,b,a,c,d,l,rr;
    cin>>n;
    string s;
    cin>>s;
    ll r=0,cnt=0;
    for(i=0; i<n; i++)
        if(s[i]=='R')
            r++;
    for(i=0; i<r; i++)
        if(s[i]=='W')
            cnt++;
    cout<<cnt<<'\n';
}











Measured memory_bytes: 3720
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		char s[] = sc.next().toCharArray();

		int esum[] = new int[n+1];
		int wsum[] = new int[n+1];
		for(int i=0; i<n; i++) {
			if(s[i] == 'E') {
				esum[i+1] += esum[i]+1;
				wsum[i+1] += wsum[i];
			} else {
				esum[i+1] += esum[i];
				wsum[i+1] += wsum[i]+1;
			}
		}
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<n; i++) {
			ans = Math.min(ans, wsum[i] + esum[n] - esum[i+1]);
		}
		System.out.println(ans);
		sc.close();
	}
}


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

using Pii = std::pair<int, int>;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    priority_queue<pair<int, int>, vector<Pii>, greater<Pii>> q;
    for (int i = 0, a, b; i < N; ++i) {
        cin >> a >> b;
        q.emplace(b, a);
    }

    int t = 0;
    while (!q.empty()) {
        auto p = q.top(); q.pop();
        int a = p.second, b = p.first;
        if (t + a <= b) {
            t += a;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 2420
/****************************
    > File Name: b.cpp
    > Author: caoyu01
  	> Mail: yalecyu@gmail.com 
    > Created Time: 2016年10月15日 星期六 20时01分28秒
*****************************/
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cle(x) memset(x,0,sizeof(x))
#define rep(i,x) for(int i=0;i<x;i++)
#define Rep(i,x) for(int i=1;i<=x;i++)
const int N = 1000+10;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
#endif
	int n,k;
	while(cin>>n>>k){
		int ans=1;
		rep(i,n){
			if(i)ans*=(k-1);
			else ans*=k;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{

	/*
	 * ???52???
	 *
	 * ???????????????????????????????????????????????? ??????????????? ???n <= 52???
	 *
	 */
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		// ?????±??\???
		String card = sc.next();
		int rank = Integer.parseInt(card);

		ArrayList<Integer> S_card = new ArrayList<Integer>(); // ????????????
		ArrayList<Integer> H_card = new ArrayList<Integer>(); // ?????????
		ArrayList<Integer> C_card = new ArrayList<Integer>(); // ?????????
		ArrayList<Integer> D_card = new ArrayList<Integer>(); // ?????????

		for (int i = 0; i < rank; i++) {
			// ??????
			String shape = sc.next();
			String no = sc.next();
			int choice = Integer.parseInt(no);
			if (shape.equals("S")) {
				S_card.add(choice);
			} else if (shape.equals("H")) {
				H_card.add(choice);
			} else if (shape.equals("C")) {
				C_card.add(choice);
			} else if (shape.equals("D")) {
				D_card.add(choice);
			}
		}

		// ??¢?´¢
		// ?¶???????????????????

		String[] cardShape = new String[] { "S", "H", "C", "D" };
		String swi = "";
		for (int i = 0; i < cardShape.length; i++) {
			swi = cardShape[i];
			if (swi == "S")
				swi_method(swi, S_card);
			else if(swi == "H")
				swi_method(swi, H_card);
			else if(swi == "C")
				swi_method(swi, C_card);
			else
				swi_method(swi, D_card);

		}

	}

	static void check(String cardShape, ArrayList<Integer> cArd_N) {
		Collections.sort(cArd_N);

		

		boolean[] chk_arr = new boolean[13];
		for (int i = 1; i <= 13; i++) {
			for (int j = 0; j < cArd_N.size(); j++) {
				if (i == cArd_N.get(j))
					chk_arr[i-1] = true;
			}
		}
		for (int j = 0; j < chk_arr.length; j++) {
			if (chk_arr[j] == false)
				System.out.println(cardShape + " " + (j + 1));
		}
	}

	static void swi_method(String swi, ArrayList<Integer> cArd_N) {
		switch (swi) {
		case "S":
			check(swi, cArd_N);
			break;
		case "H":
			check(swi, cArd_N);
			break;
		case "C":
			check(swi, cArd_N);
			break;
		case "D":
			check(swi, cArd_N);
			break;
		}
	}
}

Measured memory_bytes: 26316
#include <climits>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

int N;
bool dp[10100] = {0};

int main()
{
    cin >> N;
    dp[0] = true;
    FO (i, N)
    {
        int num;
        cin >> num;
        RFOR (j, num, 10100)
            dp[j] = dp[j] | dp[j - num];
    }
    int res = 0;
    RFOR (j, 0, 10100)
    {
        if (j % 10 && dp[j])
        {
            res = j;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdlib>
#include<time.h>
#include<string>
#include<stack>
#include<cmath>
#include<iostream>
#include<cstring>
#include<complex>
#include<tr1/unordered_set>
#include<tr1/unordered_map>
using namespace std;
using namespace tr1;
#define FOR(i,j,k) for(int i=j;i<k;i++)
#define FORD(i,j,k) for(int i=j;i>=k;i--)
#define ll long long
#define ull unsigned long long int
//Make sure no overflow problems
#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define VAR(i,n) __typeof(n) i = (n)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();i++)
#define FORDEACH(i,c) for( VAR(i,(c).rbegin()),i!=(c).rend();i++)
#define REP(i,n) FOR(i,0,n)
#define ld long double
const int INF = 1000000009;
const long long INFLL = (ll)INF * (ll)INF;
const ld EPS = 10e-9;

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

   /*	#ifndef ONLINE_JUDGE
   		freopen("input.txt", "r", stdin); 
   		freopen("output.txt", "w", stdin); 
    #endif */
   		int n, divisors[2], cnt = 0;
        cin >> n;
        cout << n*n;
   		return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010];
ll cnt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	ll all = 0;
	rep(i, 0, N) cnt[A[i]]++;
	rep(i, 1, N + 1) all += cnt[i] * (cnt[i] - 1) / 2;

	rep(i, 0, N) {
		ll ans = all;
		ans -= cnt[A[i]] * (cnt[A[i]] - 1) / 2;
		ans += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2;
		printf("%lld\n", ans);
	}
}







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

int main() {
  int n;
  cin >> n;
  vector<string> red(n);
  
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    red.at(i) = s;
  }

  int m;
  cin >> m;
  vector<string> blue(m);
  
  for (int i = 0; i < m; i++) {
    string t;
    cin >> t;
    blue.at(i) = t;
  }
  
  int max = 0;

  for (int i = 0; i < n; i++) {
    int yen = 0;
    for (int j = 0; j < n; j++) {
      if (red.at(i) == red.at(j)) yen++; 
    }
    for (int j = 0; j < m; j++) {
      if (red.at(i) == blue.at(j)) yen--;
    }
    if (yen > max) max = yen;
  }

  cout << max << endl;
}

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

using namespace std;

int main()
{
    long long int a, b, k;

    cin >> a >> b >> k;

    long long int x, y;

    x = min(a, k);

    a = a - x;
    k = k - x;

    if (k > 0)
    {
        y = min(b, k);
        b = b - y;
        k = k - y;
    }

    cout << a << " " << b << "\n";

    return 0;
}

Measured memory_bytes: 256
class Binexpgen
	@len # max length of log2 i
	def initialize(len)
		@len = len
		@i = -1
	end
	def gen()
		@i += 1
		return bin_exp(@i)
	end
	def bin_exp(i)
		arr = Array.new(@len) { |i| 0 }
		cnt = 0
		while(cnt < @len)
			arr[cnt] = i&1
			i /= 2
			cnt += 1
		end
		return arr
	end
end

N,M=gets.chomp.split(' ').map{|n| n.to_i}
K=Array.new(M)
S=Array.new(M)
for i in 0..(M-1)
	tmp = gets.chomp.split(' ').map{|n| n.to_i}
	K[i] = tmp[0]
	S[i] = tmp[1..(tmp.size-1)]
end
P = gets.chomp.split(' ').map{|n| n.to_i}

cnt = 0
binexpgen = Binexpgen.new(N)
for n in 0..(2**N-1)
	binarr = binexpgen.gen()
	# p binarr
	flg = true
	for m in 0..(M-1)
		thiscnt = 0
		for k in 0..(K[m]-1)
			thiscnt += binarr[S[m][k]-1]
		end
		flg &= (thiscnt % 2 == P[m])
	end
	cnt += 1 if flg
	# puts "hit!" if flg
end
puts cnt



Measured memory_bytes: 1916
#define y1 askjdkasldjlkasd
#include <bits/stdc++.h>
#undef y1

using namespace std;

#define pb push_back
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while (0)
#endif

double START_TIME;

void exit() {
#ifdef LOCAL	
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif	
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

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

const int MAX = 541;

int a[MAX][MAX];
int n;

int rec(int l, int r) {
	if (r - l <= 0) return 0;
	int tm = (l + r) / 2;
	int v1 = rec(l, tm);
	int v2 = rec(tm + 1, r);
	int res = max(v1, v2) + 1;
	fi(l, tm) {
		fj(tm + 1, r) {
			a[i][j] = a[j][i] = res;
		}
	}
	return res;	
}

void solve () {
	rec(0, n - 1);
	fi(0, n - 2) {
		fj(i + 1, n - 1) {
			printf("%d ", a[i][j]);
		}
		printf("\n");
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif
	
	scanf("%d", &n);
	solve();

	exit();
	return 0;
}





Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
#define lint int64_t

int main(){
    lint N,M;
    cin >> N >> M;
    
    vector<lint> Ai;
    rep(i,N){
        lint tmpAi;
        cin >> tmpAi;
        Ai.push_back(tmpAi);
    }
    
    sort(Ai.begin(),Ai.end());
    
    //累積和
    vector<lint> Si(N+1);
    rep(i,N){
        Si.at(i+1) = Si.at(i) + Ai.at(i);
    }

    //2分探索 A[i]+A[j]を最大から順番に並べたとき
    //M回以上になる値left,M回未満になるrightを求める 
    lint left = 0;
    lint right = 1e6 + 1e6; 
    while((right - left) > 1){
        lint mid = (left + right) / 2;  
        lint Mcnt = 0;
        
        rep(i,N){
            lint tmp = mid - Ai.at(i);
            //A[i]がtmp以上あるか
            vector<lint>::iterator pos;
            pos = lower_bound(Ai.begin(), Ai.end(), tmp);
            auto okAiCnt = distance(pos,Ai.end());
            Mcnt += okAiCnt;
        }
        if(Mcnt >= M){
            left = mid;
        }else{
            right = mid;
        }
    }

    //総和 right以上について考え＋余った回数分leftをかける。
    lint ans = 0; 
    lint already_cnt = 0;
    rep(i,N){
        lint tmp = right - Ai.at(i);
        //A[i]がtmp以上あるか
        vector<lint>::iterator pos;
        pos = lower_bound(Ai.begin(), Ai.end(), tmp);
        auto okAiCnt = distance(pos,Ai.end());

        lint okinitidx = N-okAiCnt;
        ans += Si.at(N) - Si.at(okinitidx) + Ai.at(i) * okAiCnt;
        already_cnt += (okAiCnt);
    }

    ans += left * (M - already_cnt);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int H,W; cin >> H >> W;
  vector<vector<char>> grids(H, vector<char>(W, 0));
  vector<vector<bool>> isRemained(H, vector<bool>(W, true));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> grids.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; i++) {
    bool isAllWhite = true;
    for (int j = 0; j < W; j++) {
      if (grids.at(i).at(j) == '#') {
        isAllWhite = false;
        break;
      }
    }
    if (isAllWhite) {
      for (int j = 0; j < W; j++) isRemained.at(i).at(j) = false;
    }
  }
  
  for (int i = 0; i < W; i++) {
    bool isAllWhite = true;
    for (int j = 0; j < H; j++) {
      if (grids.at(j).at(i) == '#') {
        isAllWhite = false;
        break;
      }
    }
    if (isAllWhite) {
      for (int j = 0; j < H; j++) isRemained.at(j).at(i) = false;
    }
  }
  
  for (int i = 0; i < H; i++) {
    bool isNoneRow = true;
    for (int j = 0; j < W; j++) {
      if (isRemained.at(i).at(j)) {
        cout << grids.at(i).at(j);
        isNoneRow = false;
      }
    }
    if (!isNoneRow) cout << endl;
  }
}

Measured memory_bytes: 256
x1, y1, x2, y2 = gets.split(" ")
x1, y1, x2, y2 = x1.to_i, y1.to_i, x2.to_i, y2.to_i

xsiz = y2-y1
ysiz = x2-x1

x3 = x2-xsiz
y3 = y2+ysiz
x4 = x1-xsiz
y4 = y1+ysiz

print x3 ," ", y3 ," ", x4 ," ", y4

Measured memory_bytes: 1788
n = int(input())

vac = []
firstDay = list(map(int, input().split()))

for _ in range(n-1):
    newTotal = [0,0,0]
    
    secondDay = list(map(int, input().split()))
    for j, second in enumerate(secondDay):
        temp = 0
        for i, first in enumerate(firstDay):
            if i != j:
                temp = max(temp, first + second)
                
        newTotal[j] = temp   
                    
    firstDay = newTotal
    
print(max(firstDay))

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

int main()
{
    int i,j,k,l,n,counter;
    while(cin>>n)
    {
        counter=0;
        if(n<37)
        {
            for(i=0;i<=9;i++)
                for(j=0;j<=9;j++)
                  for(k=0;k<=9;k++)
                    for(l=0;l<=9;l++)
            {
                if(i+j+k+l==n)
                    counter++;
            }
        }
        cout<<counter<<endl;
    }


    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    int field[9][9] = {0};
    bool flag[9][9] = {false};
    for(int i=0; i<9; i++){
      for(int j=0; j<9; j++){
	cin >>field[i][j];
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[i][j]] != 0){flag[i][j] = true;flag[i][log[field[i][j]]-1] = true;}
	log[field[i][j]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[j][i]] != 0){flag[j][i] = true;flag[log[field[j][i]]-1][i] = true;}
	log[field[j][i]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[j%3+(i%3)*3][j/3+(i/3)*3]] != 0){
	  int r = log[field[j%3+(i%3)*3][j/3+(i/3)*3]]-1;
	  flag[j%3+(i%3)*3][j/3+(i/3)*3] = true;
	  flag[r%3+(i%3)*3][r/3+(i/3)*3] = true;
	}
	log[field[j%3+(i%3)*3][j/3+(i/3)*3]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      for(int j=0; j<9; j++){
	if(flag[i][j]){cout <<"*";}
	else{cout <<" ";}
	cout <<field[i][j];
      }
      cout <<endl;
    }
    if(n>0){cout <<endl;}
  }
  return 0;
}

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

typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 100 + 5;
const int M = 63244 + 5;

ll dp[N][M];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 1; i <= n; ) {
    a.emplace_back(n / i);
    i = n / (n / i) + 1;
  }
  int m = a.size();
  sort(a.begin(), a.end());
  for (int i = 0; i < m; ++ i) {
    dp[1][i] = a[i];
  }
  ll ans = 0;
  for (int i = 2; i <= k; ++ i) {
    for (int j = 0; j < m; ++ j) {
      int oj = m - j - 1;
      int t = a[j] - (j == 0 ? 0 : a[j - 1]);
      dp[i][j] = 1ll * t * dp[i - 1][oj] % MOD;
      if (i == k) {
        ans = (ans + dp[i][j]) % MOD;
      }
    }
    for (int j = 1; j < m; ++ j) {
      dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
    }
  }
  if (n == 314159265) {
    puts("                ");
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 51324
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,m;
 int count=0;
 int sum=0;
  
 cin>>n>>m;
 int a[n];
  
 for(int i=0;i<n;i++){
   cin>>a[i];
   sum=sum+a[i];
 }
  
 for(int i=0;i<n;i++){
  if(a[i]*4*m>=sum){count++;}
 }
  
 if(count<m){
   cout<<"No"<<endl;
 }
 else if(count>=m){
   cout<<"Yes"<<endl;
 }
}


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

//約数列挙 計算量O(sqrt(n))
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main() {
  ll n;
  cin >> n;
  ll sum = 0;
  vector<ll> divs = divisor(n);
  rep(i,divs.size()){
    ll num = (n - divs[i]) / divs[i];
    if(divs[i] == n) continue;
    if ((((n - divs[i]) % divs[i]) == 0)){
      if(n % num == divs[i]){
        sum += num;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
n, k = map(int, input().split())

max_k = (n - 1) * (n - 2) // 2
cut = max_k - k

if cut < 0:
    print(-1)
    exit(0)

print(n - 1 + cut)
for i in range(n - 1):
    print(n, i + 1)

for i in range(n - 1):
    for j in range(i + 1, n - 1):
        if cut > 0:
            print(i + 1, j + 1)
            cut -= 1


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

using namespace std;
int main(){
	string S1,S2;
	int N,i=0,flag;
	long long P=3,x;
	
	cin >> N;
	cin >> S1;
	cin >> S2;
	
	if(S1[0]==S1[1]){		//横のドミノ
		P*=2;
		i+=2;
		flag=0;
	}else if(S1[0]==S2[0]){	//縦のドミノ
		i++;
		flag=1;
	}
	
	for(;i<N;i++){
		if(flag==0){//横のドミノ
			if(S1[i]==S1[i+1]){		//横のドミノ
				P*=3;
				i++;
				flag=0;
			}else if(S1[i]==S2[i]){	//縦のドミノ
				flag=1;
			}
		}else if(flag==1){//縦のドミノ
			if(S1[i]==S1[i+1]){		//横のドミノ
				P*=2;
				i++;
				flag=0;
			}else if(S1[i]==S2[i]){	//縦のドミノ
				P*=2;
				flag=1;
			}
		}
		P%=1000000007;
	}
	
	cout<<P<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.EmptyStackException;
import java.util.Stack;

/**
 * Problem C: Midnight Teatime
 */
public class Main {

	static int count;
	final static byte OPER_DUMMY = -10;
	final static byte OPER_AND = -1;
	final static byte OPER_OR_ = -2;
	final static byte OPER_XOR = -3;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("END")) {

			Stack<Byte> exp = new Stack<Byte>();
			Stack<Byte> oper = new Stack<Byte>();

			for (char c : line.trim().toCharArray()) {
				if (c == ' ') {
					oper.push(OPER_DUMMY);
				} else if (c >= '1' && c <= '9') {
					exp.push((byte) ((c - '0') * -1));
				} else if (c == ')') {
					exp.push(oper.pop());
				}
			}

			//
			int n = Integer.parseInt(br.readLine());
			for (int i = 1; i < n + 1; i++) {
				byte b = stob(line = br.readLine());
				for (int j = 0; j < exp.size(); j++) {
					if (exp.get(j).intValue() == i * -1) {
						exp.setElementAt(Byte.valueOf(b), j);
					}
				}
			}

			//
			count = 0;
			ArrayList<Byte> idx = new ArrayList<Byte>();
			for (byte i = 0; i < exp.size(); i++) {
				if (exp.get(i).intValue() == OPER_DUMMY) {
					idx.add(i);
				}
			}
			try {
				solve(0, idx, exp, OPER_AND);
				solve(0, idx, exp, OPER_OR_);
				solve(0, idx, exp, OPER_XOR);
				System.out.println(count);
			} catch (EmptyStackException e) {
				System.err.println(exp.toString());
			}

		}
	}

	static byte answer(Stack<Byte> exp) {
		Stack<Byte> ans = new Stack<Byte>();
		byte b1, b2, op;
		for (int i = 0; i < exp.size(); i++) {
			if (exp.get(i) < 0) {
				b2 = ans.pop();
				b1 = ans.pop();
				op = exp.get(i);
				switch ((int) op) {
				case OPER_AND:
					ans.push((byte) (b1 & b2));
					break;
				case OPER_OR_:
					ans.push((byte) (b1 | b2));
					break;
				case OPER_XOR:
					ans.push((byte) (b1 ^ b2));
					break;
				}
			} else {
				ans.push(exp.get(i));
			}
		}
		return (byte) ans.pop();
	}

	static byte stob(String str) {
		byte b = 0;
		for (int j = 0; j < 7; j += 2) {
			if (str.charAt(j) == '1') {
				b += 1 << j / 2;
			}
		}
		return b;
	}

	static void solve(int p, ArrayList<Byte> idx, Stack<Byte> exp, byte op) {
		if (p < idx.size()) {
			exp.setElementAt(Byte.valueOf(op), idx.get(p));
			if (p == idx.size() - 1) {
				if (answer(exp) == 15) {
					count++;
				}
			}
			solve(p + 1, idx, exp, OPER_AND);
			solve(p + 1, idx, exp, OPER_OR_);
			solve(p + 1, idx, exp, OPER_XOR);
		} else {
			return;
		}
	}
}

Measured memory_bytes: 40220
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
int main()
{
    int a,b,c;
    int k;
    cin >> a >> b >> c >> k;
    vector<int> v{a,b,c};
    sort(v.begin(),v.end());
    cout << v[2] * pow(2,k) + v[1] + v[0] << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,a,b;cin>>n>>a>>b;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll res=0;
    rep(i,n-1){
        if((x[i+1]-x[i])*a>b)res+=b;
        else res+=(x[i+1]-x[i])*a;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3924
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int D, N;
    cin >> D >> N;
    if (N == 100) {
        N++;
    }
    if (D == 0) {
        cout << N << endl;
    }
    else if (D == 1) {
        cout << N * 100 << endl;
    }

    else {
        cout << N * 10000 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

ll dp[123][4][4][4],ans;

int main(void){
	int n,i,j,k,l,p;
	dp[0][3][3][3] = 1ll;
	cin >> n;
	for(p=0; p<n; ++p){
		for(i=0; i<4; ++i){
			for(j=0; j<4; ++j){
				for(k=0; k<4; ++k){
					for(l=0; l<4; ++l){
						if(j==0&&k==1&&l==2){
							continue;
						}else if(j==1&&k==0&&l==2){
							continue;
						}else if(j==0&&k==2&&l==1){
							continue;
						}else if(i==0&&k==1&&l==2){
							continue;
						}else if(i==0&&j==1&&l==2){
							continue;
						}
						add_mod(dp[p+1][j][k][l],dp[p][i][j][k]);
					}
				}
			}
		}
	}
	for(i=0; i<4; ++i){
		for(j=0; j<4; ++j){
			for(k=0; k<4; ++k){
				add_mod(ans,dp[n][i][j][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int a[300000];
LL Max[300000];
LL Min[300000];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < 3 * N; i++) {
		cin >> a[i];
	}
	priority_queue<int, vector<int>, greater<int> > Q1;
	priority_queue<int> Q2;
	for (int i = 0; i < N; i++) {
		Q1.push(a[i]);
		Max[N-1] += a[i];
	}
	for (int i = N; i < 2 * N; i++) {
		Q1.push(a[i]);
		Max[i] = Max[i - 1] + a[i] - Q1.top();
		Q1.pop();
	}
	for (int i = 3 * N - 1; i >= 2 * N; i--) {
		Q2.push(a[i]);
		Min[2 * N] += a[i];
	}
	for (int i = 2 * N - 1; i >= N; i--) {
		Q2.push(a[i]);
		Min[i] = Min[i + 1] + a[i] - Q2.top();
		Q2.pop();
	}
	LL ans = -(1LL << 60);
	for (int i = N-1; i < 2 * N; i++) {
		ans = max(ans, Max[i] - Min[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define int long long
#define fi first
#define se second


const int maxn=105,maxk=1e5+5,mod=1e9+7;
int n,k,a[maxn],s[maxk];
int f[maxn][maxk];
main()
{
    cin>>n>>k;
    forinc(i,1,n) cin>>a[i];
    forinc(i,1,k+1) s[i]=1;
    forinc(i,1,n)
    {
        forinc(j,0,k) f[i][j]=(s[j+1]-s[max(0ll,j-a[i])]+mod)%mod;
        forinc(j,0,k) s[j+1]=(f[i][j]+s[j])%mod;
    }
    cout<<f[n][k]%mod;
}


Measured memory_bytes: 80128