akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d",&a,&b);
  if((a + b) % 2 == 0)
    c = (a + b) /2;
  else
    c = (a + b) /2 + 1;
  printf("%d\n",c);
}

Measured memory_bytes: 1696
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;
int main(){
	ll N,K;
	cin>>N>>K;
	ll w[110],v[110];
	for(ll i = 0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	ll dp[110][100100] = {0};
	for(ll i = 0;i<N;i++){
		for(ll sum = 0;sum<=K;sum++){
			if(sum-w[i]>=0){
				dp[i+1][sum]=max(dp[i+1][sum],dp[i][sum-w[i]]+v[i]);
			}
			dp[i+1][sum] = max(dp[i+1][sum],dp[i][sum]);
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}

Measured memory_bytes: 86272
N,A,B=map(int,input().split())
V=[int(x) for x in input().split()]
V.sort(reverse=True)
val=0
mi=10**15+1
cnt=0
for i in range(A):
  val+=V[i]
  if V[i]==mi:
    cnt+=1
  else:
    mi=V[i]
    cnt=1

#階乗計算
factorial=[1]
for i in range(1,N+1):
    factorial.append(factorial[i-1]*i)
    
def nCr(n,r):
  return int(factorial[n]/(factorial[r]*factorial[n-r]))    

ave=val/A
if ave == V[0]:
  for i in range(A,N):
    if V[i]==V[0]:
      cnt+=1
    else:
      break
  ans=0
  for i in range(A,min(B+1,cnt+1)):
    ans+=nCr(cnt,i)
  print(ave)
  print(ans)
else:
  res=cnt
  for i in range(A,N):
    if V[i]==V[A-1]:
      res+=1
  print(ave)
  print(nCr(res,cnt))


Measured memory_bytes: 3188
h, w, k = map(int, input().split())
dp = [[0 for _ in range(w)] for _ in range(h+1)]
perm = [1, 2, 3, 5, 8, 13, 21, 34]
law = 1000000007
for row in range(h+1):
    for col in range(w):
        if row == 0:
            dp[row][col] = int(col == 0)
        else:
            if col > 0:
                dp[row][col] = (dp[row][col] + dp[row-1][col-1] * perm[max(0,col-2)] * perm[max(0, w-col-2)]) % law
            if col < w - 1:
                dp[row][col] = (dp[row][col] + dp[row-1][col+1] * perm[max(0,col-1)] * perm[max(0, w-col-3)]) % law
            dp[row][col] = (dp[row][col] + dp[row-1][col] * perm[max(0,col-1)] * perm[max(0,w-col-2)]) % law
print(dp[h][k-1])


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
inline char nc() {
//	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 2000 + 50;
int n, k;
int a[maxn];
inline int add(int x) {
	return x >= mod ? x - mod : x;
}
int solve() {
	int an = 0;
	int d = (ll)k * (k - 1) / 2 % mod;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) if(i != j) {
			if(a[i] <= a[j]) continue;
			if(i < j) an = add(an + k);
			an = add(an + d);
		}
	}
	return an;
}
int main() {
	read(n), read(k);
	for(int i = 1; i <= n; ++i) {
		read(a[i]);
	}
	printf("%d\n", solve());
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  long long x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[311][333][333];
int l[310];
int j[302];

long long x,y,z,mod=1000000007;
//string r;
char r[111];

P u[1];
queue<int> q;

//stack<int> s;
set<int> s;
map<int,int> p;
vector<P> v[200101];

bool as(P a,P b)
{
  if(a.x==b.x)
  return a.y<b.y;
  return a.x<b.x;
}

long long f(int n,int m,int c)
{
  if(m<0) return mod*mod;
  if(n>a) return 0;
  if(o[n][m][c]>=0) return o[n][m][c];
  return o[n][m][c]=min(f(n+1,m-1,c),f(n+1,m,n)+max(0,l[n]-l[c]));
}

int main()
{
  scanf("%d %d",&a,&b);
  memset(o,-1,sizeof(o));
  for(int t=1;t<=a;t++)
    scanf("%d",&l[t]);
  printf("%lld",f(1,b,0));
}




Measured memory_bytes: 274432
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
    char W[11],T[1001],t[1001];
    int i,ct=0;
    scanf("%s",W);
    while(1){
        scanf("%s",T);
        if(strcmp(T,"END_OF_TEXT")==0){
            break;
        }
        t[0]='\0';
        for(i=0;T[i]!='\0';i++){
            t[i]=tolower(T[i]);
        }
        t[i]='\0';
        if(strcmp(t,W)==0){
            ct++;
        }
    }
    printf("%d\n",ct);
    return 0;
}


Measured memory_bytes: 2032
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	ll m,b,x;
	cin>>m>>b>>x;
	for(int i=0;i<10;++i) {
		cout<<(x=x*m-b)<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3588
def find_root(x):
    if parent[x] == x:
        return x
    else:
        return find_root(parent[x])


# x,yの属する集合の併合
def unite(x, y):
    x = find_root(x)
    y = find_root(y)

    if x != y:
        if rank[x] < rank[y]:
            parent[x] = y
            size[y] += size[x]
        else:
            parent[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1


# xとyが同じグループかどうか判定
def same(x, y):
    return find_root(x) == find_root(y)


N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

parent = [i for i in range(N)]  # 根
rank = [1] * N  # 深さ
size = [1] * N  # iを根とするグループのサイズ

edge = [[xy[M - 1 - i][0] - 1, xy[M - 1 - i][1] - 1] for i in range(M)]
for i in range(M):
    unite(edge[i][0], edge[i][1])

ans = 0
for i in range(N):
    if p[i]-1 == i or same(p[i]-1, i):
        ans += 1
print(ans)


Measured memory_bytes: 50336
S=input()

if S=='SUN':
  print(7)
elif S=='MON':
  print(6)
elif S=='TUE':
  print(5)
elif S=='WED':
  print(4)
elif S=='THU':
  print(3)
elif S=='FRI':
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
def gcd(a, b):
    while b != 0 :
        t = a % b
        a = b
        b = t
    return a
        
sum = 0
N=int(input(""))
for a in range(1, N + 1):
    for b in range(1, N + 1):
        x = gcd(a, b)
        if x == 1:
            sum = sum + N
        elif x == 2:
            sum = sum + (N + 1) // 2 + N // 2 * 2
        elif x == 3:
            sum = sum + N // 3 * 3 + (N - N // 3)
        elif x == 5:
            sum = sum + N // 5 * 5 + (N - N // 5)
        else:
            for c in range(1, N + 1):
                sum = sum + gcd(x, c)
print(sum)

Measured memory_bytes: 9212
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ');
            long step = 0;

            for (int i = 1; i < N; i++)
            {
                if(int.Parse(A[i]) < int.Parse(A[i - 1])){
                    long diff = int.Parse(A[i - 1]) - int.Parse(A[i]);
                    step += diff;
                    A[i] = (int.Parse(A[i]) + diff).ToString();
                }
            }

            System.Console.WriteLine(step);
        }
    }
}


Measured memory_bytes: 52336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int N,M,X,Y,tmp,max,min;
	int f=0;
	vector<int> XN;
	vector<int> YM;
	cin >> N >> M >> X >> Y;

	for(int i=0;i<N;i++)
	{
		cin >> tmp;
		XN.push_back(tmp);
	}
	
	for(int i=0;i<M;i++)
	{
		cin >> tmp;
		YM.push_back(tmp);
	}

	max = *max_element( XN.begin(), XN.end() );
	min = *min_element( YM.begin(), YM.end() );


	for(int i=X;i<Y;i++)
	{
		if(i>X&&i<=Y)
		{
			if(max<i&&min>=i)
			{
				f=1;
			}
		}
	}

	if(f==0)
	{
		cout << "War" << endl;
	}
	else if(f==1)
	{
		cout << "No War" << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#define ll long long
using namespace std;

bool IsPalin(const vector<pair<char,int> >& SS) {
    
    int L=SS.size();
    
    for(int i=0;i<L;i++) {
        if (SS[i].first!=SS[L-1-i].first)
            return false;
    }
    return true;
}

int counts[111111];


int Solve(const string& S) {
    vector<pair<char,int> > SS;
    for(int i=0;i<S.size();i++) {
        if (S[i]!='x') {
            SS.push_back({S[i],i});
        }
    }

    
    
    if (!IsPalin(SS))
        return -1;


    if (SS.empty())
        return 0;
    
    
    
    
    
    
    int lc,rc;
    if (SS.size()%2==0) {
        lc = SS.size()/2-1;
        rc = SS.size()/2;
    } else {
        lc = rc = SS.size()/2;
    }

    // cccxccxxcxxxc
    int L=S.size();
    int ans = 0;
    for(int j=0;;j++) {
        
        // j and SS.size()-1-j
        
        // j-1 to j
        
        
        int k = SS.size()-1-j;
        // SS.size()-1-j to SS.size()-j
        // k to k+1;
        
        if (j > k)
            break;
        
        
        int ct1;
        if (j == 0) {
            ct1 = SS[j].second;
        } else {
            ct1 = SS[j].second-SS[j-1].second-1;
        }
        
        int ct2;
        if (k == SS.size()-1) {
            ct2 = L-SS[k].second-1;
        } else {
            ct2 = SS[k+1].second-SS[k].second-1;
        }
        
        ans += abs(ct1-ct2);
    }
    

    return ans;
    
}

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

    cout << Solve(S) << endl;
    
    
    
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    REP(i, n)
    cin >> v[i];
    // vector<pair<ll, ll>> e_max, o_max;
    map<ll, ll> e_count, o_count;
    for (int i = 0; i < n; i += 2)
    {
        e_count[v[i]]++;
        o_count[v[i + 1]]++;
    }

    pair<ll, ll> e_max_pair = make_pair(-1, -1);
    pair<ll, ll> o_max_pair = make_pair(-1, -1);
    for (auto elem : e_count)
    {
        if (elem.second > e_max_pair.second)
            e_max_pair = elem;
    }
    e_count.erase(e_max_pair.first);

    for (auto elem : o_count)
    {
        if (elem.second > o_max_pair.second)
            o_max_pair = elem;
    }
    o_count.erase(o_max_pair.first);

    if (e_max_pair.first == o_max_pair.first)
    {
        pair<ll, ll> e_second_max_pair = make_pair(-1, -1);
        pair<ll, ll> o_second_max_pair = make_pair(-1, -1);
        for (auto elem : e_count)
        {
            if (elem.second > e_second_max_pair.second)
                e_second_max_pair = elem;
        }
        e_count.erase(e_second_max_pair.first);

        for (auto elem : o_count)
        {
            if (elem.second > o_second_max_pair.second)
                o_second_max_pair = elem;
        }
        o_count.erase(o_second_max_pair.first);

        if (e_second_max_pair.second > o_second_max_pair.second) {
            e_max_pair = e_second_max_pair;
        } else {
            o_max_pair = o_second_max_pair;
        }
    }

    ll count = 0;
    for (size_t i = 0; i < n; i+=2) {
        if (v[i] != e_max_pair.first) count++;
        if (v[i+1] != o_max_pair.first) count++;
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 7296
fun pow(base: Int, exp: Int): Long{
    var ans=1L
    if(exp==0) return ans
    if (exp%2==1) ans*=base
    return ans*pow(base*base, exp/2)
}

fun main(args: Array<String>) {
    var k= readLine()!!.toInt()
    var a=Array(9){(it+1).toLong()}.toMutableList()
    var value: Long
    var last: Long
    for(i in 0 until k-1){
        value=a[i]
        last=value%10
        if (last==0L){
            a.add(10*value+last)
            a.add(10*value+last+1)
        }else if(last==9L){
            a.add(10*value+last-1)
            a.add(10*value+last)
        }else{
            a.add(10*value+last-1)
            a.add(10*value+last)
            a.add(10*value+last+1)
        }
    }
    println(a[k-1])
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

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

	ll a;
	cin >> a;
	cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
 using namespace std;
 const long long mod = 1e9 + 7;

 int main() {
	 int N;
	 string a = "No";
	 cin >> N;


	 for (int i = 1; i < 10; i++) {
		 for (int j = 1; j < 10; j++) {
			 if (i * j == N) {
				 a = "Yes";
			 }
		 }
	 }

	 cout << a;

	 return 0;
 }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string S;
    cin >> S;
    int ans = 0;
    REP(i,6) if(S[i] == '1') ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int64_t n, m;
    cin >> n >> m;

    int64_t a = n * 100 + m * 1800;
    int64_t q = 1 << m;


    cout << a * q << endl;

    return 0;
}

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

int main()
{
		double a, b, c, C, S, L, h, rad;
		static const double pi = 3.141592653589793;
		cin >> a >> b >> C;
		rad = pi/(180/C);
		c = sqrt((a*a)+(b*b)-(2*a*b*cos(rad)));
		S = (1.0/2.0)*a*b*sin(rad);
		L = a+b+c;
		h = 2*S/a;
		cout << fixed << S << "\n";
		cout << fixed << L << "\n";
		cout << fixed << h << "\n";
}

Measured memory_bytes: 3528
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

long long m[128][128];
bool v[128][128];

void flood(int i, int j) {
    v[i][j] = true;
    if (!v[i+1][j] && m[i][j] == m[i+1][j]) flood(i+1,j);
    if (!v[i-1][j] && m[i][j] == m[i-1][j]) flood(i-1,j);
    if (!v[i][j+1] && m[i][j] == m[i][j+1]) flood(i,j+1);
    if (!v[i][j-1] && m[i][j] == m[i][j-1]) flood(i,j-1);
}

int main() {
    int N, x[2][64], y[2][64], xx[128], yy[128], i, j, k, NN, MX, MY, RES;
    double tmpx, tmpy;
    long long mask;

    while (cin >> N && N) {
        for (i=0; i<N; i++) {
            cin >> x[0][i] >> y[0][i] >> x[1][i] >> y[1][i];
            xx[i] = x[0][i]; xx[N+i] = x[1][i];
            yy[i] = y[0][i]; yy[N+i] = y[1][i];
        }
        xx[2*N] = yy[2*N] = -1; xx[2*N+1] = yy[2*N+1] = 1000001; NN = 2*N+2;
        sort(xx, xx+NN); sort(yy, yy+NN);

        for (i=MX=1; i<NN; i++) if (xx[i] != xx[i-1]) {
            for (j=MY=1; j<NN; j++) if (yy[j] != yy[j-1]) {
                mask = 0LL; tmpx = (xx[i]+xx[i-1])/2.0; tmpy = (yy[j]+yy[j-1])/2.0;
                for (k=0; k<N; k++) if (tmpx > x[0][k] && tmpx < x[1][k] && tmpy > y[1][k] && tmpy < y[0][k]) mask ^= (1LL<<k);
                m[MX][MY] = mask;
                MY++;
            }
            MX++;
        }

        memset(v, false, sizeof(v));
        for (i=0; i<=MX; i++) v[i][0] = v[i][MY] = true;
        for (i=0; i<=MY; i++) v[0][i] = v[MX][i] = true;

//        for (i=1; i<MY; i++) {
//            for (j=1; j<MX; j++) cout << m[j][i] << ' '; cout << endl;
//        }
//        cout << endl;

        RES = 0;
        for (i=1; i<MX; i++) for (j=1; j<MY; j++) if (!v[i][j]) {RES++; flood(i, j);}
        cout << RES << endl;
    }

    return 0;
}

Measured memory_bytes: 2084
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    if s.len() < 2 {
        println!("0");
        return;
    }
    
    let mut ans = 0_i64;
    let mut rena = 0;
    let mut i = 0;
    while i < s.len() {
        if s[i] == 'A' {
            rena += 1;
            i += 1;
        } else if i < s.len()-1 && s[i] == 'B' && s[i+1] == 'C' {
            ans += rena;
            i += 2;
        } else {
            rena = 0;
            i += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
require 'pp'
H,W = gets.split.map(&:to_i)

c = []
H.times do
  c << gets.chomp.chars
end

score = c.flatten.count('.')
# p score

c[0][0] = 0

# puts c.map(&:join).join("\n")

stack = [[0,0,0]]


until stack.empty?
  s = stack.shift
  break if s.nil?
  h, w = s[0], s[1]
  cnt = c[h][w]
  [
    [h + 1,w],
    [h - 1,w],
    [h,w + 1],
    [h,w - 1]
  ].select{|(hh,ww)| 0 <= hh && hh < H && 0 <= ww && ww < W}.each do |(hh,ww)|
    if c[hh][ww] == '.'
      stack << [hh,ww]
      c[hh][ww] = cnt+1 if c[hh][ww] == '.' || c[hh][ww] > cnt+1
    end
  end
end


c2 = c.map{|x|x.map{|x|format('%3s ', x.to_s)}.join}.join("\n")

# puts c2
# p c[-1][-1]
if c[-1][-1] == '.'
  p -1
else
  p score - c[-1][-1] - 1
end




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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (S.at(K - 1) == 'A')
    S.at(K - 1) = 'a';
  else if (S.at(K - 1) == 'B')
    S.at(K - 1) = 'b';
  else
    S.at(K - 1) = 'c';
  cout << S << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] a = new int[N];

		for (int i = 0; i < N; i++)
			a[i] = sc.nextInt();

		long s = 0;
		long min =Long.MAX_VALUE;

		for (int i = 0; i < N; i++)
			s += a[i];

		long x = 0, y = 0;

		for (int i = 0; i < N - 1; i++) {
			x += a[i];
			y = s - x;
			min = Math.min(min, Math.abs(x - y));
		}

		System.out.println(min);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22992
#include <vector>
#include <string>
#include <iostream>
//#include <algorithm>
using namespace std;

int ConvStrToInt(std::string checkStr)
{
	return atoi(checkStr.c_str());
}
std::string ConvIntToStr(int checkNum)
{
	return std::to_string(checkNum);
}

int main(void)
{
	int count = 0;
	std::vector<int> v_cin;

	cin >> count;

	for (int i = 0; i < count; ++i)
	{
		int tmp = 0;
		cin >> tmp;
		v_cin.push_back(tmp);
	}
	int resultValue = 0;
	for (int i = 0;; ++i)
	{
		bool isFail = false;
		for (int j = 0; j < v_cin.size(); ++j)
		{
			if(v_cin.at(j) % 2 == 0)
			{
				v_cin.at(j) = v_cin.at(j) / 2;
			}
			else
			{
				isFail = true;
				break;
			}
		}
		if (isFail)
		{
			break;
		}
		else
		{
			++resultValue;
		}
	}
	cout << resultValue << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> pii;
const int N = 5e4+5;
const int M = 5*1e5+5;
#define pi acos(-1)
#define INF 1e18
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int main()
{
	int cnt = 0,n;sd(n);
	map<string,int> mp;
	for(int i=1;i<=n;++i)
	{
		string s;cin >> s;
		if(mp[s] == 0) cnt++,mp[s]++;
	}
	pr(cnt);
	//system("pause");
	return 0;
}

Measured memory_bytes: 19412
#include <stdio.h>
int main(void){
  int a,b,n,r=0,t,s;
  for(scanf("%d%d%d",&n,&a,&b);n;--n){
    for(t=n,s=0;t>0;t/=10)s+=t%10;
    r=a<=s?s<=b?r+n:r:r;
  }
  printf("%d\n",r);
  return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())

def bi(h, w):
    s = h * w
    if h % 2 == 0 or w % 2 == 0:
        s0 = h * w // 2
    else:
        s0 = (max(h, w) + 1) // 2 * min(h, w)
    return [s0, s - s0]

ans = h * w
for i in range(1, h):
    arr = bi(h - i, w)
    arr.append(w * i)
    ans = min(ans, max(arr) - min(arr))

for i in range(1, w):
    arr = bi(h, w - i)
    arr.append(h * i)
    ans = min(ans, max(arr) - min(arr))

print(ans)

Measured memory_bytes: 44380
#include <stdio.h>

using namespace std;
int main()
{

    char s[4];
    scanf("%s", s);
    int ret = 1;

    for(int i = 0; i<3; i++)
        {
            if(s[i]==s[i+1]){
                ret = 0;
                break;
            }
        }

    if(ret ==  1){
        printf("%s\n", "Good");
    }else{
        printf("%s\n", "Bad");
    }
    return 0;
}

Measured memory_bytes: 128
import itertools
import math

n=int(input())
lis=[i for i in range(1,n+1)]
P_lis=itertools.permutations(lis)
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))

P=list(P_lis)
P=sorted(P)
#print(P)
#print(a,P.index(a))
#print(b,P.index(b))
print(abs(P.index(a)-P.index(b)))

Measured memory_bytes: 8228
N, K = map(int, input().split())
S = list(str(input()))

length = len(S)
point=0

tmp = S[0]
for i in range(1, len(S)):
    if tmp==S[i]:
        length-=1
        point+=1
    tmp = S[i]

capacity = length-1
point += min(capacity, K*2)

# print(length)
print(point)

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,x,y;
  cin >> n >> x >> y;
  x--;
  y--;
  int dist = 0;
  vector<int> dists(n,0);
  REP(i,n){
    FOR(j,i+1,n){
      dist = j-i;
      chmin(dist,abs(x-i)+1+abs(y-j));
      chmin(dist,abs(y-i)+1+abs(x-j));
      dists[dist]++;
    }
  }
  FOR(i,1,n){
	cout << dists[i] << endl;
  }
  return 0;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int keta = log10(b);
	int y = a * pow(10, keta + 1) + b;

	int x = sqrt(y);

	if (pow(x, 2) == y) cout << "Yes" << endl;
	else           cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/abc176/tasks/abc176_a
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int n, x, t;
	cin >> n >> x >> t;
	int ans = (n/x)*t;
	if (n%x) ans+=t;
	cout << ans << endl;
	return 0;
}
	


Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <utility>

using namespace std;

int main() {
  string from, to;

  cin >> from >> to;

  if (from == to.substr(0, from.size()) && from.size() + 1 == to.size()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3128
//WrittenBiDP
//grid

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

#define MOD 1000000007	

using namespace std;

typedef long long ll;
typedef double ld;

typedef vector <bool> vb;
typedef vector <ll> vi;
typedef vector <ld> vd;
typedef vector <vi> vvi;
typedef vector <vb> vvb;
typedef vector <vd> vvd;

vd p;
vvd f;

int main() {
	//ifstream In("input.txt");
	//ofstream Out("output.txt");

	int n;
	cin >> n;


	for (int i = 0; i < n; i++) {
		double t;
		cin >> t;
		p.push_back(t);
	}

	f.resize(n + 1);
	for (int i = 0; i <= n; i++) {
		f[i].assign(n, 0);
	}

	f[0][0] = 1 - p[0];
	f[1][0] = p[0];

	for (int i = 1; i < n; i++) {
		f[0][i] = f[0][i - 1] * (1 - p[i]);
	}

	for (int j = 1; j < n; j++) {
		for (int i = 1; i <= n; i++) {
			f[i][j] = f[i - 1][j - 1] * p[j] + f[i][j - 1] * (1 - p[j]);
		}
	}

	double ans = 0;

	for (int i = n / 2 + 1; i <= n; i++) {
		ans += f[i][n - 1];
	}
	cout.fixed;
	cout.precision(12);
	cout << ans;

	return 0;
}

Measured memory_bytes: 70656
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t
    val zero : t
    val neg_inf : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない
       2n回呼び出されるので，リストを作るのに時間がかかるならメモ化すること *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 経路に負閉路が含まれる頂点を覚えるやつ *)
    let neg = Array.make n false in
    d.(s) <- Weight.zero;
    (* n回目以降の反復 手動ループアンローリング *)
    let rec loop' n =
      if
        0 < n &&
        es.fold (fun (u, v, c) b -> (* bは更新の有無 *)
          let open Weight in
          (* c は u から v への辺の重さ
             d.(u) + c < d.(v) *)
          0 < Weight.compare d.(v) (d.(u) + c)
          (* n 回目以降に変更が起こった場合，v までの経路に負閉路が含まれている *)
          && (d.(v) <- d.(u) + c; neg.(v) <- true; true) || b) false
      then loop' (n - 1) in
    (* n-1回目までの反復 *)
    let rec loop = function
      | 0 -> loop' n
      | n ->
          if
            es.fold (fun (u, v, c) b ->
              let open Weight in
              0 < Weight.compare d.(v) (d.(u) + c) && (d.(v) <- d.(u) + c; true) || b) false
          then loop (n - 1) in
    loop (n - 1);
    fun v -> if neg.(v) then Weight.neg_inf else d.(v)
end

module G = WeightedDirectedGraph (struct
  type t = int
  let inf = -123456789012345678
  let zero = 0
  let neg_inf = 123456789012345678
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let abcs = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abcs } 0 (n - 1) in
  if 123456789012345678 <= d
  then print_endline "inf"
  else Printf.printf "%d\n" d


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define uns unsigned
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
const str v = "RGB";
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    str s;
    cin >> n >> s;
    vvi pref(3, vi(n)), suf(3, vi(n));
    for (int i = 0; i < 3; i++)
        if (s[0] == v[i])
            pref[i][0] = 1;
    for (int i = 1; i < n; i++)
        for (int j = 0; j < 3; j++)
        {
            pref[j][i] = pref[j][i - 1];
            if (s[i] == v[j])
                pref[j][i]++;
        }
    for (int i = 0; i < 3; i++)
        if (s.back() == v[i])
            suf[i][n - 1] = 1;
    for (int i = n - 2; i >= 0; i--)
        for (int j = 0; j < 3; j++)
        {
            suf[j][i] = suf[j][i + 1];
            if (s[i] == v[j])
                suf[j][i]++;
        }
    int res = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (s[i] == 'R')
            res += pref[1][i - 1] * suf[2][i + 1] + pref[2][i - 1] * suf[1][i + 1];
        else if (s[i] == 'G')
            res += pref[0][i - 1] * suf[2][i + 1] + pref[2][i - 1] * suf[0][i + 1];
        else
            res += pref[0][i - 1] * suf[1][i + 1] + pref[1][i - 1] * suf[0][i + 1];
        for (int j = 1; i + j < n && i - j >= 0; j++)
            if (s[i] != s[i - j] && s[i] != s[i + j] && s[i - j] != s[i + j])
                res--;
    }
    cout << res << endl;
    GAME_OVER;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairInt;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N, K;

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

  set<int> not_replyed;
  set<int> not_replying;
  multimap<int, int> replying;

  FOR1(i, 1, N + 1) { not_replyed.insert(i); }

  FOR1(i, 1, N + 1) {
    int a;
    scanf("%d", &a);
    if (a != 0) {
      replying.insert(make_pair(i, a));
      not_replyed.erase(a);
    } else {
      not_replying.insert(i);
    }
  }

  set<int> displayed(not_replyed);
  set<int> temp(not_replyed);
  FOR(i, K - 1) {
    set<int> temp2;
    for (auto x : temp) {
      using iterator = decltype(replying)::iterator;
      pair<iterator, iterator> ret = replying.equal_range(x);
      for (auto it = ret.first; it != ret.second; it++) {
        if (displayed.find(it->second) == displayed.end()) {
          temp2.insert(it->second);
          displayed.insert(it->second);
        }
      }
    }
    temp = move(temp2);
    // printf("displayed%d:{", i);
    // for (auto x : displayed) {
    //   printf("%d, ", x);
    // }
    // printf("}\n");
  }
  displayed.insert(not_replying.begin(), not_replying.end());

  printf("%lu\n", displayed.size());

  return 0;
}

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

using namespace std;

int dp[6005];
pair <int, int> a[3005];

int main() {
	int n, t;
	scanf("%d%d", &n, &t);
	
	for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);
	
	sort(a, a + n);
	
	int maxTime = t + a[n - 1].first - 1;
	
	for (int i = 0; i <= maxTime; i++) dp[i] = -1;
	dp[0] = 0;
	
	for (int i = 0; i < n; i++) {
		for (int j = maxTime; j >= a[i].first; j--) {
			if (j - a[i].first >= t) continue;
			if (dp[j - a[i].first] != -1) dp[j] = max(dp[j], dp[j - a[i].first] + a[i].second);
		}
	}
	
	int res = *max_element(dp, dp + maxTime + 1);
	
	printf("%d\n", res);
}


Measured memory_bytes: 256
--myProd :: Integer -> Integer -> Integer
myProd _ 0 = 0
myProd 0 _ = 0
myProd _ (-1) = -1
myProd x y
    | y > 10 ^ 18 = -1
    | otherwise   = x * y

--solve :: [Integer] -> Integer
solve xs = foldr1 myProd (1:xs)

main :: IO ()
main = do
    getLine
    getLine >>= return . solve . map read . words >>= print


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

int main(void){
    int row, col;
    cin >> row >> col;
    
    int matrix[row][col];
    int colVector[col];
    
    for(int i=0; i<row; i++){
        for(int j=0; j<col; j++){
            cin >> matrix[i][j];
        }
    }
    
    for(int i=0; i<col; i++){
        cin >> colVector[i];
    }
    
    // result
    for(int i=0; i<row; i++){
        int sum = 0;
        for(int j=0; j<col; j++){
            sum += (matrix[i][j] * colVector[j]);
        }
        cout << sum << "\n";
    }

    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define tc int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define vpi vector<pair<int,int> > 
#define vpll vector<pair<lli,lli> > 
#define vvi vector<vector<int> >
#define vvll vector<vector<lli> >
#define maxn 200005
#define mod 1000000007
#define inf 10000000000000000


int main(){
    fastio;
    string s;
    cin>>s;
    int cnt=0,ans=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        cnt++;
        else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    cout<<max(ans,cnt)<<"\n";
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(){
int a=0,b=0,c=0,d=0,e=0,f=0,g,i;
for(i=0;i<10;i++){
scanf("%d\n",&g);
if(g>a){
c=b;
b=a;
a=g;
}
else if(g>b){
c=b;
b=g;
}
else if(g>c){
c=g;
}
}
for(i=0;i<10;i++){
scanf("%d\n",&g);
if(g>d){
f=e;
e=d;
d=g;
}
else if(g>e){
f=e;
e=g;
}
else if(g>f){
f=g;
}
}
printf("%d %d\n",a+b+c,d+e+f);
return 0;
}



Measured memory_bytes: 2100
x,y,z,q=map(int,input().split())
a=sorted(map(int,input().split()),reverse=True)
b=sorted(map(int,input().split()),reverse=True)
c=sorted(map(int,input().split()),reverse=True)
 
def bisect(l,r):
  cnt=(l+r)//2
  if cnt==l:
    return l-1+judge(l)
  if judge(cnt):
    return bisect(cnt+1,r)
  else:
    return bisect(l,cnt)
def judge(thr):
  m=0
  for i in range(x):
    for j in range(y):
      if i*j>q:
        break
      for k in range(z):
        if i*j*k>q or a[i]+b[j]+c[k]<thr:
          break
        m+=1
        if m>=q:
          return True
  return False
def make(thr):
  m=0
  l=[]
  for i in a:
    for j in b:
      for k in c:
        n=i+j+k
        if n<thr+1:
          break
        m+=1
        l+=[n]
  l.sort(reverse=True)
  return l+[thr]*(q-len(l))
thr=bisect(0,a[0]+b[0]+c[0]+1)
ans=make(thr)
for w in ans:
  print(w)

Measured memory_bytes: 3572
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;

int n,m,c,b[110],a[110][110],ans=0;

int main()
{
	cin>>n>>m>>c;
	rept(i,0,m) cin>>b[i];
	rept(i,0,n)
	{
		int res=0;
		rept(j,0,m)
		{
			cin>>a[i][j];
			res+=a[i][j]*b[j];
		}
		if (res+c>0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#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)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s; cin>>s;
    set<char> m;
    rep(i,s.size()){
        if(!m.count(s[i]))m.insert(s[i]);
        else {cout<<"no"<<endl;return 0;}
    }
    cout<<"yes"<<endl ;return 0;
}


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

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

    if(((A <=C) && (C <= B))||((B <=C) && (C <= A))) {
        cout << "Yes" << endl;
    }
      else{
        cout << "No" << endl;
}
       }


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, now = 0;
  scanf("%lld", &n);
  ll a[n], b[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &a[i], &b[i]);
  for(i = n - 1; i >= 0; --i) now = (a[i] + now + b[i] - 1) / b[i] * b[i] - a[i];
  printf("%lld", now);
  return 0;
}

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

int main()
{
    int n,k;
    int min_price = 0;

    cin >> n >> k;

    vector<int> p(n);

    for (int i = 0; i < n ; i++)
    {
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());

    for (int i = 0 ; i < k ; i++)
    {
        min_price += p.at(i);
    }

    cout << min_price << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		calc(n, 0, "");

		scan.close();
	}

	private static void calc(int max, int c, String str) {
		if (str.length() == max) {
			System.out.println(str);
			return;
		}

		for(char i = 0; i < c + 1; i++) {
			String str2 = str + String.valueOf((char)('a' + i));
			calc(max, Math.max(c, i + 1), str2);
		}
	}
}


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

int main(){
  long long N;
  cin >> N;
  long long ans=1e15;
  for(long long i=1;i<=pow(N,0.5);i++){
    if(N%i==0){
      ans =min(ans,i+N/i-2);
    }
  }
  cout << ans << endl;   
    
  
}
      
    
      


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

int main(){
    int flag=1;
    int n;
    int ans=0;
    int distx=0,disty=0;

    int MAX=0;

    map< pair<int,int> , int> map1;
    map< pair<int,int> ,int>::iterator p;

    cin >>n;
    int x[n];
    int y[n];

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


    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if(j==i)continue;
            distx = x[j]-x[i];
            disty = y[j]-y[i];

            auto temp = make_pair(distx,disty);

            p=map1.find(temp);

            if(p != map1.end()){  //m[] == p->second??
                map1[temp] += 1;

                if(map1[temp] > MAX){
                    MAX = map1[temp];

                    //std::cout <<"("<<x[i]<<","<<y[i]<<"to"<<x[j]<<","<<y[j]<<")";
                    //cout << temp.first<<","<<temp.second<<":"<<MAX<< endl;
                    
                    auto pq = temp;
                }

            }else{
                /*
                auto temp2 = make_pair(-1*distx,-1*disty);
                p=map1.find(temp2);
                if(p != map1.end()){
                    map1[temp2] += 1;
                    if(map1[temp2] > MAX){
                        MAX = map1[temp2];

                        std::cout <<"("<<x[i]<<","<<y[i]<<"to"<<x[j]<<","<<y[j]<<")";
                        std::cout << "(::gyaku::)" << std::endl;
                        cout << temp2.first<<","<<temp2.second<<":"<<MAX<< endl;
                    
                        auto pq = temp2;
                    }
                }*/

                map1[temp] = 1;

                if(map1[temp] > MAX){
                    MAX = map1[temp];
                    auto pq = temp;
                }

            }
        }
    }
    
    cout << n-MAX <<endl;

    //std::cout << << << << '\n';
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 384
Mod = 10**9+7
def f(s,t):
  if s[-1] == t[-1]:
    if len(s) == 1:
      return 3
    elif s[-2] == t[-2]:
      return 2*f(s[:-1],t[:-1])%Mod
    else:
      return 1*f(s[:-1],t[:-1])%Mod
  else:
    if len(s) == 2:
      return 6
    elif s[-3] == t[-3]:
      return 2*f(s[:-2],t[:-2])%Mod
    else:
      return 3*f(s[:-2],t[:-2])%Mod

n = int(input())
x = input()
y = input()
print(f(x,y))

Measured memory_bytes: 3064
Q = int(input())


# 約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
N = 5*10**4
acc = [0]*(N+1)
cnt = 0
for i in range(N+1):
    n1 = 2*i + 1
    n2 = i+1
    div1 = make_divisors(n1)
    div2 = make_divisors(n2)    
    if len(div1) == len(div2) == 2:
        cnt += 1
    acc[i] = cnt
# print(acc[:10])
for i in range(Q):
    l_,r_ = map(int, input().split())
    l = (l_-1)//2
    r = (r_-1)//2
    if l > 0:
        print(acc[r]-acc[l-1])
    else:
        print(acc[r])

Measured memory_bytes: 52312
#include <stdio.h>
int main(){
    int b,f,r,v,n;
    int people[5][4][11];
    
    for(b=1;b<=4;b++){
        for(f=1;f<=3;f++){
            for(r=1;r<=10;r++){
                people[b][f][r]=0;
            }
        }
    }
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        people[b][f][r]+=v;
    }
    
    for(b=1;b<=4;b++){
        for(f=1;f<=3;f++){
            for(r=1;r<=10;r++){
                printf(" %d",people[b][f][r]);
            }
            printf("\n");
        }
        
        if(b==4) break;
        printf("####################\n");
    }
    return 0;
}


Measured memory_bytes: 2108
import copy
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]

a_l = []
for i in range(n):
    a_l.append(a[i][0])
a1 = sorted(a_l)
m1 = a1[-1]
m2 = a1[-2] 

for i in a_l:
    if i == m1:
        print(m2)
    else:
        print(m1) 

Measured memory_bytes: 50692
n, x=map(int, input().split())
c=list(map(int, input().split()))
c.sort()
ans=0
for i in range(n-1):
  if c[i]<=x:
    x-=c[i]
    ans+=1
  else:
    break
if c[n-1]==x:
  ans+=1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdlib>
#include<cstdio>
#define LL long long
using namespace std;
const int mod=1e9+7;
LL n,m,a,b,f[200010],ni[200010],fx[200010],ans;
int s1,s2,t1,t2;
int main(){
	scanf("%d %d %d %d",&n,&m,&a,&b);
	f[0]=f[1]=1;fx[0]=fx[1]=1;ni[0]=ni[1]=1;
	for(int i=2;i<=200000;++i)f[i]=f[i-1]*i%mod;
	for(int i=2;i<=200000;++i)ni[i]=(mod-mod/i)*ni[mod%i]%mod;
	for(int i=2;i<=200000;++i)fx[i]=fx[i-1]*ni[i]%mod;
	s1=n-a-1;s2=b;t1=a;t2=m-b-1;
	LL tmp=f[s1+s2]*fx[s1]%mod*fx[s2]%mod;
	tmp=(tmp*f[t1+t2]%mod*fx[t1]%mod*fx[t2]%mod)%mod;
	ans=(ans+tmp)%mod;
	while(s1>0&&s2<m-1)
	  {s1--;s2++;t1++;t2--;
	   LL tmp=f[s1+s2]*fx[s1]%mod*fx[s2]%mod;
	   tmp=(tmp*f[t1+t2]%mod*fx[t1]%mod*fx[t2]%mod)%mod;
	   ans=(ans+tmp)%mod;}
	cout<<ans<<endl;
	return 0;}

Measured memory_bytes: 4992