akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();	
		var n=sc.I;
		var a=sc.Ia;
		var b=sc.Ia;
		var c=new int[n][];
		var d=new int[n][];
		for(int i = 0;i<n;i++) {
			c[i]=new int[]{a[i],0};
			d[i]=new int[]{b[i],i};
		}
		Array.Sort(a);
		Array.Sort(b);
		Array.Sort(d,(u,v)=>u[0]-v[0]);
		for(int i = 0;i<n;i++) {
			c[d[i][1]][1]=i;
		}
		Array.Sort(c,(u,v)=>u[0]-v[0]);
		for(int i = 0;i<n;i++) {
			if(a[i]>b[i]){Console.WriteLine("No");return;}
		}
		for(int i = 1;i<n;i++) {
			if(a[i]<=b[i-1]){Console.WriteLine("Yes");return;}
		}
		int p=0,q=0;
		while(c[p][1]!=0){
			p=c[p][1];
			q++;
		}
		Console.WriteLine("{0}",q==n-1?"No":"Yes");
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 36188
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int K,S,cnt=0;
  cin>>K>>S;
  
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(S-i-j>=0&&S-i-j<=K) cnt++;
    }
  }
  cout<<cnt<<endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>

#define MAX_N 50

using namespace std;

int n;
double v[MAX_N];

void solve()
{
    double res = 0;
    sort(v, v + n, greater<int>());
    for (int i = 1; i <= n; i++)
    {
        if (i != n)
            res += v[i - 1] / pow(2, i);
        else
            // 最初は生の具材２つを混ぜる
            res += v[n - 1] / pow(2, n - 1);
    }
    cout << setprecision(16) << res << endl;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    solve();
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

vector<int> G[100020];
int h[100020];

int main()
{
	ios::sync_with_stdio(false);
	int n,m,k=0,a,b;
	bool t;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>h[i];
	while(m--)
	{
		cin>>a>>b;
		G[a].pb(b);
		G[b].pb(a);
	}
	for(int i=1;i<=n;i++)
	{
		t=false;
		for(int j=0;j<G[i].size();j++)
		{
			if(h[G[i][j]]>=h[i])
			{
				t=true;
				break;
			}
		}
		if(!t) k++;
	}
	cout<<k;
	return 0;
}




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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int counter[4];
int main()
{
    int n;cin >> n;
    rep(i,n)
    {
        string s;
        cin >> s;
        if(s=="AC")
        {
            counter[0]++;
            continue;
        }
        if (s == "WA")
        {
            counter[1]++;
            continue;
        }
        if (s == "TLE")
        {
            counter[2]++;
            continue;
        }
        if (s == "RE")
        {
            counter[3]++;
            continue;
        }
    }
    cout << "AC x " << counter[0] << endl;
    cout << "WA x " << counter[1] << endl;
    cout << "TLE x " << counter[2] << endl;
    cout << "RE x " << counter[3] << endl;
}

Measured memory_bytes: 3628
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

cc :: String -> String -> Int -> Int
cc [] _ n = n
cc _ [] n = n
cc (s : ss) (c : cs) n
  | s == c = cc ss cs (n + 1)
  | otherwise = n

calc ss cs
  | ((cc ss cs 0) + (cc (reverse ss) (reverse cs) 0)) >= length cs = "YES"
  | otherwise = "NO"

main = do
  [s] <- getString
  putStrLn $ calc s "keyence"


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

int main() {
  int X, Y;
  cin >> X >> Y;
  string ans;
  
  if((2*X<=Y) && (4*X>=Y) && (Y%2 == 0)) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
}

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

int a[26];

int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    vector<int> p(n, k - q);
    rep(i, q) {
        int a;
        cin >> a;
        a--;
        p[a]++;
    }
    rep(i, n) {
        if(p[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

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

typedef vector<int> vi;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii > vii;
typedef vector<vi > vvi;

int i, j, afs;
string a, b;
int main(){
    cin >> a;
    b = a;
    reverse(b.begin(), b.end());
    if(b == a) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

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


int main() {
  int N;
  cin>>N;
  
  vector<int64_t> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int sai=0;
  int sum=0;
  for(int i=1;i<N;i++){ 
    if(vec.at(i-1)>=vec.at(i)) sum++;
    else{
    sai=max(sai,sum);
    sum=0;
    }
  }
  cout<<max(sai,sum)<<endl; 
  
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int col(int n){
	if(n==1)return 0;
	return col(n%2?n*3+1:n/2)+1;
}

int main() {
	int n;
	while(n=in()){
		cout<<col(n)<<endl;
	}
	return 0;
}

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

int main() {
    int64_t n, d, a;
    cin >> n >> d >> a;
    vector<pair<int64_t, int64_t>> xh(n);
    for (auto& e : xh) cin >> e.first >> e.second;
    sort(begin(xh), end(xh));

    vector<int64_t> damage(n+1);
    int64_t ans = 0;
    for (int64_t l = 0, r = 0; l < n; l++) {
        while (r < n && xh[r].first - xh[l].first <= 2 * d) r++;
        int64_t tb = max(0l, xh[l].second - damage[l] + a - 1l) / a, ta = tb * a;
        ans += tb, damage[l] += ta, damage[r] -= ta, damage[l+1] += damage[l];
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
N = int(input())
X = input()
tmp = bin(int(X, 2)).count("1")
big = int(X, 2) % (tmp + 1)
small = int(X, 2) % (tmp - 1) if tmp - 1 else 0

for i in range(N):
    ans = 0
    if X[i] == '1':
        if not tmp - 1:
            print(ans)
            continue

        c = small - pow(2, (N - i - 1), tmp - 1)
        c = c % (tmp - 1)
    else:
        c = big + pow(2, (N - i - 1), tmp + 1)
        c = c % (tmp + 1)
    ans += 1
    while c:
        MOD = bin(int(c)).count("1")
        c %= MOD
        ans += 1
    print(ans)


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

const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;

ll modpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b&1)
      res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}

ll f[MAXN];
ll invf[MAXN];

ll ncr(ll n, ll r) {
  if (r == 0 || n == r) return 1;
  return (((f[n] * invf[n-r]) % MOD) * invf[r]) % MOD;
}

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  f[0] = 1;
  for (int i = 1; i < MAXN; i++) {
    f[i] = (f[i-1] * i) % MOD;
    invf[i] = modpow(f[i], MOD-2);
  }
  ll res = 0;
  for (int i = b; i < w; i++) {
    int y1 = h - a - 1, x1 = i;
    int y2 = a - 1, x2 = w - i - 1;
    ll p = (ncr(x1 + y1, x1) * ncr(x2 + y2, x2)) % MOD;
    res = (res + p) % MOD;
  }
  cout << res << '\n';
}

Measured memory_bytes: 15872
from collections import deque
H, W = map(int, input().split())
sy, sx = 0, 0
gy, gx = H-1, W-1
field = [list(input()) for _ in range(H)]
step = [[-1]*W for _ in range(H)]
step[sy][sx] = 0
tovisit = deque()
tovisit.append([sy, sx])

while tovisit:
  y, x = tovisit.popleft()
  for next_y, next_x in [[y+1, x], [y-1, x], [y, x+1], [y, x-1]]:
    if 0 <= next_y < H and 0 <= next_x < W and field[next_y][next_x] != '#':
      if step[next_y][next_x] == -1:
        tovisit.append([next_y, next_x])
        step[next_y][next_x] = step[y][x] + 1

sum_block = sum([l.count('#') for l in field])
steps = step[gy][gx]
print(-1 if steps == -1 else H*W - sum_block - steps - 1)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

const int MAX_N = 1e5 + 10;
int K, N;
int64_t x[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> K;
    
    for (int i = 1; i <= N; i++) {
        std::cin >> x[i];
    }

    int64_t ret = abs(x[N]) + abs(x[1]);
    ret *= 2;
    for (int i = 1; i - 1 + K <= N; i++) {
        int64_t left = x[i];
        int64_t right = x[i-1+K];
        int64_t tmp = (right - left) + std::min(abs(left), abs(right));
        ret = std::min(ret, tmp);
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	string str;
	cin >> str;
	int a = -1,z = -1;
	for(int i = 0;i < str.size();i++){
		if(a == -1 && str[i] == 'A') a = i;
		if(str[i] == 'Z') z = i;
	}

	cout << z - a + 1 << endl;
	return 0;
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,d;cin>>n>>d;
    cout<< n/(2*d+1) + ((n%(2*d+1)== 0)?0:1)<<endl; return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

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

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, a);
    IN(int, b);
    IN(int, c);
    IN(int, d);
    int aoki = (a+d-1)/d;
    int taka = (c+b-1)/b;
    Yes(taka<=aoki);
}


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

int p[35][35];
int memo[33][33][33][33];
int M = 1000000007;

//[l, r), [u, d)
// max bunkatu
int dfs(int l, int r, int u, int d, int mi) {
    if (memo[l][r][u][d] != -1) return memo[l][r][u][d];
    int sum = 0;
    for (int i = l; i < r; ++i) {
        for (int j = u; j < d; ++j) {
            sum += p[i][j];
        }
    }
    if (sum < mi) {
        return memo[l][r][u][d] = -M;
    }
    int ret = 1;
    for (int i = l + 1; i < r; ++i) {
        ret = max(ret, dfs(l, i, u, d, mi) + dfs(i, r, u, d, mi));
    }
    for (int i = u + 1; i < d; ++i) {
        ret = max(ret, dfs(l, r, u, i, mi) + dfs(l, r, i, d, mi));
    }
    return memo[l][r][u][d] = ret;
}
int main() {
    while (1) {
        int h, w, s;
        cin >> h >> w >> s;
        if (!h) return 0;
        int sum = 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> p[i][j];
                sum += p[i][j];
            }
        }
        for (int i = 0; i < 33; ++i) {
            for (int j = i + 1; j < 33; ++j) {
                for (int k = 0; k < 33; ++k) {
                    for (int l = k + 1; l < 33; ++l) {
                        memo[i][j][k][l] = -1;
                    }
                }
            }
        }
        int ma = dfs(0, h, 0, w, sum - s);
        int ok = sum - s, ng = sum + 1;
        while (ok + 1 < ng) {
            int m = (ok + ng) / 2;
            for (int i = 0; i < 33; ++i) {
                for (int j = i + 1; j < 33; ++j) {
                    for (int k = 0; k < 33; ++k) {
                        for (int l = k + 1; l < 33; ++l) {
                            memo[i][j][k][l] = -1;
                        }
                    }
                }
            }
            if (dfs(0, h, 0, w, m) == ma) {
                ok = m;
            }
            else {
                ng = m;
            }
        }
        cout << ma << " " << (s- sum + ok) << "\n";
    }
}

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    int n;

    std::cin >> n;

    std::vector<P> vec(n), vec1;

    rep(i, n)
            std::cin >>
        vec[i].first >> vec[i].second;

    vec1 = vec;

    std::sort(rag(vec1));

    std::vector<int> idx(n + 1); //val->元のidx
    std::vector<int> pos(n + 1); //valのそーと後のpos

    rep(i, n)
    {
        idx[vec[i].second] = i;
        pos[vec1[i].second] = i;
    }

    std::vector<std::vector<int>> ans;
    std::vector<bool> used(n + 1);

    int prep = n;

    for (int i = 1; i <= n; ++i)
    {
        if (used[i])
            continue;

        if (n - pos[i] > i)
        {
            if (n - prep < i)
            {
                ans.push_back(std::vector<int>());
            }
            auto &v = ans.back();
            for (int j = pos[i]; j < prep; ++j)
            {
                used[vec1[j].second] = 1;
                v.push_back(vec1[j].second);
            }
        }
        else
        {
            ans.push_back(std::vector<int>());
            ans.back().push_back(i);
            used[i] = 1;
        }
        prep = pos[i];
    }

    std::vector<int> res(n);

    for (const auto &v : ans)
    {
        for (auto x : v)
            res[idx[x]] = v.size();
    }

    for (auto x : res)
        std::cout << x << std::endl;

    /*for (const auto &v : ans)
    {
        for (auto x : v)
            std::cerr << x << ' ';
        std::cerr << std::endl;
    }*/

    return 0;
}

Measured memory_bytes: 10072
n = int(input())
l = [int(x.strip()) for x in input().split()]
ans = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      if i < j and j < k:
        if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i] and l[j]!=l[k] and l[i]!=l[j] and l[i]!=l[k]:
          ans += 1
print(ans)

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

int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;

  if ((A+B)>(C+D)) {
    cout <<"Left"<< endl;
  }
  
  if ((A+B)<(C+D)){
    cout<<"Right"<<endl;
  }
  
  if((A+B)==(C+D)){
    cout<<"Balanced"<<endl;
  }
}

  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=2000005,INF=1<<28;

ll inv[MAX],fac[MAX],finv[MAX];

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    make();
    int r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;
    
    ll ans=comb(r1+c1,r1);
    
    for(int j=r1+1;j<=r2;j++){
        ll base=comb(j+c1,j);
        base*=comb(c2-c1+r2-j+1,r2-j+1);
        base%=mod;
        
        ans+=base;
        ans%=mod;
    }
    
    for(int i=c1+1;i<=c2;i++){
        ll base=comb(i+r1,i);
        base*=comb(r2-r1+c2-i+1,c2-i+1);
        base%=mod;
        
        ans+=base;
        ans%=mod;
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 47104
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }

    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        char[] s = in.next().toCharArray();
        s[k - 1] = Character.toLowerCase(s[k - 1]);
        System.out.println(String.valueOf(s));
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

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

    double nextDouble() {
        return Double.parseDouble(this.sc.next());

    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n) { ans += (n - 1) / i; }
    cout << ans << "\n";
}

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

int main() {
    for (int i = 0; i < 5; i++) {
        int x;
        std::cin >> x;
        if(x==0){
            std::cout << i+1 << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define all(s) s.begin(),s.end()
#define pi 3.14159265358979323846
#define mod 1000000007
#define fp(x) fixed<<setprecision(x)<<
template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
int sumAllInts(T n){
    int a = 1;
    int su = 0;
    while(n){
        su += n%10;
        n/=10;
    }
    return su;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}
void solve(){
    bool n; cin>>n;
    cout<<!n;
    
}
int main(){
    quickie;
    //txt;
    int t= 1;
    while(t--){
        solve(); 
        newl; 
    } 
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String letter = scanner.next();
		char a = 'a';
		
		if(letter.equals(letter.toUpperCase()))
			a = 'A';
		System.out.print(a);
	}
}


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

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

    vector<int> s(3);
    vector<int> ans(60000);
    while(!(s[0] == 99 && s[1] == 99 && s[2] == 99)) {
        if (s[0] < 99) {
            s[0]++;
        }
        else if (s[1] < 99) {
            s[1]++;
            s[0] = 0;
        }
        else {
            s[2]++;
            s[0] = 0;
            s[1] = 0;
        }
        if (s[0] == 0 || s[1] == 0 || s[2] == 0) {
            continue;
        }
        ans[pow(s[0] + s[1] + s[2], 2) - (s[0]*s[1] + s[1]*s[2] + s[2]*s[0])]++;
    }

    int i;
    for(i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3588
/// 13:24 13/09/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)

#include<bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef long long ll;

bool updatePrimeMap(ll n, map<ll, ll> &m) {
    if (n == 1) {
        return false;
    }
    if (n % 2 == 0) {
        if (m.count(2) > 0) {
            return true;
        }
        while (n % 2 == 0) {
            n /= 2;
            m[2]++;
        }
    }
    for (ll i = 3; i * i <= n; i += 2) {
        if (n % i == 0) {
            if (m.count(i) > 0) {
                return true;
            }
            while (n % i == 0) {
                n /= i;
                m[i]++;
            }
        }
    }
    if (n > 1) {
        if (m.count(n) > 0) {
            return true;
        }
        m[n]++;
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll gcd = 0;
    for (auto &x:v) {
        cin >> x;
        gcd = __gcd(x, gcd);
    }
    if (gcd > 1) {
        cout << "not coprime";
        return 0;
    }
    map<ll, ll> m;
    bool flag = false;
    updatePrimeMap(v[0], m);
    for (ll i = 1; i < n; i++) {
        if (updatePrimeMap(v[i], m)) {
            flag = true;
            break;
        }
    }
    if (flag) {
        cout << "setwise coprime";
    } else {
        cout << "pairwise coprime";
    }
    return 0;
}


Measured memory_bytes: 11100
#pragma GCC optimize("O3")
            #pragma comment(linker, "/stack:200000000")
            #pragma GCC optimize("unroll-loops")
             
            #include <algorithm>
            #include <bitset>
            #include <cassert>
            #include <chrono>
            #include <cmath>
            #include <complex>
            #include <cstdio>
            #include <cstdlib>
            #include <cstring>
            #include <ctime>
            #include <deque>
            #include <functional>
            #include <iomanip>
            #include <iostream>
            #include <iterator>
            #include <limits>
            #include <climits>
            #include <list>
            #include <map>
            #include <numeric>
            #include <queue>
            #include <random>
            #include <ratio>
            #include <set>
            #include <sstream>
            #include <stack>
            #include <string>
            #include <unordered_map>
            #include <unordered_set>
            #include <utility>
            #include <vector>
            using namespace std;
             
            typedef long long ll;
            typedef long double ld;
            #define int ll
            #define double ld
            #define pb push_back
            #define mp make_pair
            #define REP(i,n) for (int i = 0; i < n; i++)
            #define loop(i,n) for (int i = 0; i < n; i++)
            #define FOR(i,a,b) for (int i = a; i < b; i++)
            #define REPD(i,n) for (int i = n-1; i >= 0; i--)
            #define FORD(i,a,b) for (int i = a; i >= b; i--)
            #define remax(a,b) a = max(a,b)
            #define remin(a,b) a = min(a,b)
            #define mem(a, b) memset(a, b, sizeof a)
            #define append push_back
            #define all(v) v.begin(),v.end()
            #define F first
            #define S second
            #define print(x) cout << (x) << endl
            #define PRECISION(x) cout << fixed << setprecision(x)
            #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
            
            const double PI=acos(-1);
            const int MOD = 1000000007;
            const int FMOD = 998244353;
            const double eps = 1e-9;
             
            mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
 
signed main(){

	int n,k;
	cin>>n>>k;
	map<int,int> mp1;
	loop(i,k)
	{
		int p;
		cin>>p;
		loop(j,p)
		{
			int x;
			cin>>x;
			mp1[x]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(mp1[i]==0)
		ans++;
	}
	cout<<ans;
}
			

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  int n;
  cin >> n;
  map<string , int> mp;
  vs s(n);
  rep(i,n){
    cin >> s[i];
    mp[s[i]]++;
  }
  int max_element=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    max_element = max(max_element , itr->second);
  }
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    if(itr->second == max_element) cout << itr->first << endl;
  }
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



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


int main() {
  string S;
  cin >> S;
  int N = S.size();
  //操作後のSはS1かS2になる
  
  string S1 = S;//S1 = 0101010...
  string S2 = S;//S2 = 1010101...

    for(int i = 0;i<N;i++){
      if(i%2 ==0) S1[i] = '0';
      else  S1[i] = '1';
    }
    for(int i = 0;i<N;i++){
      if(i%2 ==0) S2[i] = '1';
      else  S2[i] = '0';
    }
  int c = 0;
  int d = 0;
  //SとS1,SとS2で異なる文字数をカウントし、小さいほうが答え
  for(int i = 0;i<N;i++){
    if(S[i] != S1[i]) c++;
  }
  for(int i = 0;i<N;i++){
    if(S[i] != S2[i]) d++;
  }
  cout << min(c,d) <<endl;

}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

int K;
int A,B;

int main(){
  
  cin>>K;
  cin>>A>>B;
  
  string ans = "NG";
  
  for(int i = A; i <= B; ++i){
    if(i % K == 0) ans = "OK";
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int sum=0;
  int count;
  while(1){
    count=0;
    cin>>n;
    if(n==0) break;
    for(int i=1;i<n-1;i++){
      sum=0;
      for(int j=0;j<n;j++){
	sum+=(i+j);
	if(sum>n) break;
	if(sum==n) count++;
      }
    }
    cout<<count<<endl;
  }
  return 0;
}




Measured memory_bytes: 3112
#include <stdio.h>
#include <string.h>
#define MAX 100000000
 
char str[14];
char H[MAX];
 
int find(void);
void insert(void);
int getChar(char);
int getKey(void);
 
int main(){
    int i,j,n;
    char a[7];
 
    scanf("%d",&n);
 
    for(i=0;i<n;i++){
        scanf("%s %s",a,str);
        if(a[0]=='i'){
            insert();
        }
        else if(a[0]=='f'){
            if(find())printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}
 
int getChar(char c){
    if(c == 'A')return 1;
    else if(c == 'C')return 2;
    else if(c == 'G')return 3;
    else if(c == 'T')return 4;
}
 
int getKey(){
    int sum=0, p=1,i;
    for(i=0;i<strlen(str);i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
 
int find(){
  
    int key = getKey();
    if(H[key]) return 1;
    else return 0;
}
 
void insert(){
    H[getKey()] = 1;
}

Measured memory_bytes: 10088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;


int main(int argc, char **argv)
{
	string s; cin >> s;
	string res;
	if (s == "ABC")
		res = "ARC";
	else
		res = "ABC";
	std::cout << res << std::endl;
}

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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<VVB> V3B;
typedef vector<V3B> V4B;
typedef vector<PII> VPII;

#define Y first
#define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[2][4]={{1,0,-1,0}, {-1, 0, 1, 0}};
const int DY[2][4]={{0,-1,0,1}, {0, -1, 0, 1}};

int W, H;
VVS tss;

PII find_start(VS &ts, char c) {
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (ts[y][x] == c) {
				return MP(y, x);
			}
		}
	}
	exit(1);
}

bool solve() {
	queue<vector<PII>> qs;
	V4B dones(H, V3B(W, VVB(H, VB(W))));

	qs.push({find_start(tss[0], 'L'), find_start(tss[1], 'R')});

	while (qs.size()) {
		auto q = qs.front();
		PII a = q[0];
		PII b = q[1];
		qs.pop();

		if (dones[a.Y][a.X][b.Y][b.X]) { continue; }
		else { dones[a.Y][a.X][b.Y][b.X] = true; }

		bool g1 = tss[0][a.Y][a.X] == '%';
		bool g2 = tss[1][b.Y][b.X] == '%';
		if (g1 && g2) { // ????????°???
			return true;
		} else if (g1 ^ g2) { // ????????°???
			continue;
		}

		for (int di = 0; di < 4; di++) {
			VPII ns(2);
			for (int i = 0; i < 2; i++) {
				int x = q[i].X + DX[i][di];
				int y = q[i].Y + DY[i][di];

				if (!RANGE(x, y, W, H) || tss[i][y][x] == '#') {
					x = q[i].X;
					y = q[i].Y;
				}

				ns[i].X = x;
				ns[i].Y = y;
			}

			qs.push(ns);
		}
	}

	return false;

}

int main(void) {
	while (cin >> W >> H, W) {
		tss = VVS(2, VS(H));

		for (int y = 0; y < H; y++) {
			cin >> tss[0][y] >> tss[1][y];
		}

		cout << (solve() ? "Yes" : "No") << endl;
	}

	return 0;
}

Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  bool good = true;
  rep(i, S.length()) {
    if (i % 2 == 0 && S[i] == 'L') good = false;
    else if (i % 2 == 1 && S[i] == 'R') good = false;
  }

  if (good) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdio.h>
int main()
{
    int i, j, k, h, m, a, l;
    char n[202], x;
    while (scanf("%s", n))
    {
        if (strcmp(n, "-") == 0)
            break;
        scanf("%d", &m);
        int len = strlen(n);
        for (i = 0; i < m; i++)
        {
            scanf("%d", &a);
            for (l = 0; l < a; l++)
            {
                x = n[0];
                for (j = 0; j < len; j++)
                {
                    n[j] = n[j + 1];
                }
                n[len - 1] = x;
            }
        }
        for (k = 0; k < len - 1; k++)
        {
            printf("%c", n[k]);
        }
        printf("%c\n", n[len - 1]);
    }
    return 0;
}


Measured memory_bytes: 2040
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(input[i]);
        }

        long r = 0;
        long h = 0;
        for (int i = 0; i < n; i++)
        {
            if (h > a[i])
            {
                r += h - a[i];
            }
            else
            {
                h = a[i];
            }
        }
        Console.WriteLine(r);
    }
}

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

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

Measured memory_bytes: 3636
import bisect
import sys
import math
import itertools
import collections
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

h,w,n=ii()
kuro=[(0,0) for j in range(n)]
for j in range(n):
    kuro[j]=ii()
ans=[0]*10
sq=[]

for x,y in kuro:
    for dx,dy in itertools.product((-1,0,1),(-1,0,1)):
        if 2<=x+dx<=h-1 and 2<=y+dy<=w-1:
            sq.append((x+dx)*w+(y+dy))

cdict=collections.Counter(sq)
for num,cnt in cdict.items():
    ans[cnt]+=1

ans[0]=(h-2)*(w-2)-sum(ans)

for j in range(10):
    print ans[j]


Measured memory_bytes: 167736
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
string s;
set<char>b;
int main()
{
	SPEED;
	cin>>s;
	for(auto j:s)
		b.insert(j);
	if(b.size()==4)
		return cout<<"Yes"<<endl,0;
	if(b.size()==2)
	{
		auto j=b.begin();
		char x=*j;
		j++;
		char y=*j;
		if((x=='N'&&y=='S')||(x=='E'&&y=='W'))
			return cout<<"Yes"<<endl,0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  string s,t;cin>>s>>t;
  t.pop_back();
  cout<<(s==t ? "Yes":"No")<<endl;
}


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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;

	writeln((1000 - (N%1000)) % 1000);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2696
a=input()
ac,bc,cc=0,0,0
for i in range(3):
    if a[i]=='a':
        ac+=1
    if a[i]=='b':
        bc+=1
    if a[i]=='c':
        cc+=1
if ac==1 and bc==1 and cc==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, K, X, Y, sum = 0, count = 0;
	cin >> N >> K >> X >> Y;
	if( N <= K ) {
		for(int i = 0; i < N; i++)
			sum = sum + X;
	} else {
		
		for(int i = 0; i < K; i++)
			sum = sum + X;
		for(int i = K; i < N; i++)
			sum = sum + Y;
	}
	printf("%d",sum);
}

Measured memory_bytes: 256
import bisect
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for i in range(N):
  a=bisect.bisect_left(A,B[i])
  b=N-bisect.bisect_right(C,B[i])
  if b==0:
    break
  ans+=a*b
print(ans)

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

int main()
{
	int a = 0, b = 0;
	cin >> a >> b;
	if (a == b) cout << "a == b" << endl;
	else if (a < b) cout << "a < b" << endl;
	else cout << "a > b" << endl;
	return 0;
}

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

const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;

using namespace std;

vector<int> c[maxn];
int w[maxn];

int fsp(int bs, int p) {
  int rt = 1;
  while (p) {
    if (p & 1) rt = 1ll * rt * bs % mod;
    bs = 1ll * bs * bs % mod, p >>= 1;
  }
  return rt;
}

int fac[maxn], caf[maxn];
void init(int n) {
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = 1ll * i * fac[i - 1] % mod;
  caf[n] = fsp(fac[n], mod - 2);
  for (int i = n; i >= 1; --i) caf[i - 1] = 1ll * i * caf[i] % mod;
}

int main() {
  int n, X, Y;
  scanf("%d%d%d", &n, &X, &Y);
  init(n);
  for (int i = 1, tc, tw; i <= n; ++i) {
    scanf("%d%d", &tc, &tw);
    if (!c[tc].size()) w[tc] = tw;
    c[tc].push_back(tw), w[tc] = min(tw, w[tc]);
  }
  int mc1 = 0, mc2 = 0;
  for (int i = 1; i <= n; ++i)
    if (c[i].size() && (!mc1 || w[i] < w[mc1])) mc1 = i;
  for (int i = 1; i <= n; ++i)
    if (c[i].size() && i != mc1 && (!mc2 || w[i] < w[mc2])) mc2 = i;
  if (!mc2 || w[mc1] + w[mc2] > Y) return puts("1"), 0;
  int res1 = 0, res2 = 1;
  for (int i = 1, cnt; i <= n; ++i) {
    if (!c[i].size() || w[i] + w[mc1] > Y) continue;
    cnt = 0;
    for (vector<int>::iterator j = c[i].begin(); j != c[i].end(); ++j) {
      cnt += ((*j) + w[mc1 - i ? mc1 : mc2] <= Y || (*j) + w[i] <= X);
    }
    res1 += cnt, res2 = 1ll * caf[cnt] * res2 % mod;
  }
  printf("%lld\n", 1ll * fac[res1] * res2 % mod);
  return 0;
}


Measured memory_bytes: 11648
// Problem Code: abc174_d

#include <iostream>
#include <string>

using namespace std;

int alter_altar(int N, string& c) {
	int cnt, l, r;
	cnt = l = 0;
	r = c.length() - 1;

	while (l < r) {
		if (c[l] != 'W')
			l++;
		else if (c[r] != 'R')
			r--;
		else {
			cnt++;
			swap(c[l], c[r]);
		}
	}

	return cnt;
}

int main() {
	int N;
	string c;
	cin >> N >> c;
	cout << alter_altar(N, c);
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e9;

struct p3{
  double x,y,z,r;
  p3(){x=y=z=r=0;}
  p3(double x,double y,double z):x(x),y(y),z(z){};
  p3(double x,double y,double z,double r):x(x),y(y),z(z),r(r){};
  p3 operator + (const p3 a)const {return p3(x+a.x,y+a.y,z+a.z,r);}
  p3 operator - (const p3 a)const {return p3(x-a.x,y-a.y,z-a.z,r);}
  p3 operator * (const double a)const{return p3(x*a,y*a,z*a,r);}
  p3 operator / (const double a)const{return p3(x/a,y/a,z/a,r);}
  bool operator == (const p3 a)const {return abs(x-a.x)<EPS&&abs(y-a.y)<EPS&&abs(z-a.z)<EPS;}
  double Abs()const{return sqrt(x*x+y*y+z*z);}
  double dis(const p3 a)const{return sqrt((a.x-x)*(a.x-x)+(a.y-y)*(a.y-y)+(a.z-z)*(a.z-z));}
};

double dot(p3 a,p3 b){return a.x*b.x+a.y*b.y+a.z*b.z;}

struct L3{
  p3 s,t;
  L3(){s=t=p3();}
  L3(p3 s,p3 t):s(s),t(t){};
  bool operator == (const L3 a)const{return s==a.s&&t==a.t;}
};

L3 getRay(L3 a,p3 b){
  a.t = a.t-a.s;
  b = b-a.s;
  p3 e = a.t / a.t.Abs(); 
  p3 s = e*dot(e,b); //|b|cosx = a*b/|a|
  
  double d = s.dis(b);
  if(dot(e,b)<EPS||d>b.r+EPS)return L3();
  s = e * (s.Abs()-sqrt(b.r*b.r-d*d));
  
  p3 n = (b-s)/(b-s).Abs(); //??????????????????
  n = n*dot(a.t*(-1),n)*2;
  p3 t = a.t+n+s;
  return L3(s+a.s,t+a.s);
}

int n;
vector<p3> A;
p3 calc(L3 ray){
  while(1){
    double mn = INF;
    L3 nray;
    for(int i=0;i<n;i++){
      L3 res = getRay(ray,A[i]);
      double dis = ray.s.dis(res.s);
      if(res==L3())continue;
      if(mn>dis) mn=dis,nray = res;
    }
    if(mn==INF) return ray.s;
    ray = nray;
  }
}

int main(){
  while(cin>>n,n){
    L3 start;
    cin>>start.t.x>>start.t.y>>start.t.z;
    
    A.resize(n);  
    for(int i=0;i<n;i++)cin>>A[i].x>>A[i].y>>A[i].z>>A[i].r;

    p3 ans = calc(start);
    printf("%lf %lf %lf\n",ans.x,ans.y,ans.z);
  }
  return 0;
}

Measured memory_bytes: 3220