akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    
    int n, k, x, y; cin >> n >> k >> x >> y;

    int s = 0;

    s += min(n, k) * x;


    if(n > k) s += (n - k) * y;

    print(s);


    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>


using namespace std;
static const int MAX = 100000;

int N;
int color_num = 0;
vector<int> G[MAX];
vector<int> visited(MAX, 0);
vector<pair<int, int> > vp;
map<pair<int, int>, int> I;
void bfs(int node_num, int edge_num);

int main() {
    cin >> N;
    int k, l;
    for (int i = 0; i < N-1; i++) {
        scanf("%d %d", &k, &l);
        k--; l--;
        G[k].push_back(l);
        G[l].push_back(k);
        I[make_pair(k, l)] = 0;
        vp.push_back(make_pair(k, l));
    }

    bfs(0, 0);

    cout << color_num << '\n';
    for (auto p:vp) cout << I[p] << '\n';

}

void bfs(int node_num_start, int edge_num_start) {
    queue<pair<int, int> > q;
    q.push(make_pair(node_num_start, edge_num_start));
    visited[node_num_start] = 1;
    pair<int, int> tmp;
    int node_num, edge_num_cur;
    int edge_num_used;
    while ( !q.empty()) {
        tmp = q.front();
        node_num = tmp.first;
        edge_num_used = tmp.second;
        q.pop();
        edge_num_cur = 1;
        for (int v = 0; v < G[node_num].size(); v++) {
            
            int cur = G[node_num][v];

            if (visited[cur] == 1) continue;
            visited[cur] = 1;
            if (edge_num_cur != edge_num_used) {
                I[make_pair(node_num, cur)] = edge_num_cur;
            }
            else {
                edge_num_cur++;
                I[make_pair(node_num, cur)] = edge_num_cur;
            }
            color_num = max(color_num, edge_num_cur);
            q.push(make_pair(cur, edge_num_cur));
            edge_num_cur++;
        }
    }
}


Measured memory_bytes: 13556
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	int H,W;
	string C[100];
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
			cin >> C[i];
	}



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


	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N, K, Q;
int A[2010];
int B[2010];

signed main()
{
	cin >> N >> K >> Q;
	REP(i, N)
	{
		cin >> A[i];
		B[i] = A[i];
	}
	ARY_SORT(B, N);
	int min = B[Q - 1] - B[0];

	for (int i = 0; i < N; i++)
	{
		vector<int> v;
		vector<int> v1;

		for (int j = 0; j < N; j++)
		{
			if (B[i] > A[j])
			{
				SORT(v1);
				int loop = ((int)(v1.size() - K) + 1);
				for (int k = 0; k < loop; k++)
				{
					v.push_back(v1[k]);
				}
				v1.clear();
			}
			else
			{
				v1.push_back(A[j]);
			}
		}
		SORT(v1);
		for (int k = 0; k < ((int)v1.size() - K) + 1; k++)
		{
			v.push_back(v1[k]);
		}

		if ((int)v.size() >= Q)
		{
			SORT(v);
			int n = v[Q - 1] - v[0];
			min = MIN(min, n);
		}
	}

	cout << min << endl;
}






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

class Program
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).OrderBy(x=>x).ToArray();
        var num = N / 2;
        var sa = d[num] - d[num - 1];
        Console.WriteLine(sa);
    }
}


Measured memory_bytes: 21600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,m){
        cin>>pp[i].first>>pp[i].second;
    }
    sort(pp,pp+m);
    aa[1]=1;
    ab[1]=1;
    for(int i=2;i<n+1;i++){
        rep(j,m){
            if(pp[j].first>i-1){
                break;
            }
            if(ab[i-pp[j].first]<ab[i-pp[j].second-1]) aa[i]+=ab[i-pp[j].first]-ab[i-pp[j].second-1]+998244353;
            else aa[i]+=ab[i-pp[j].first]-ab[i-pp[j].second-1];
            aa[i]%=998244353;
        }
        ab[i]=aa[i]+ab[i-1];
    }
    cout<<aa[n];
}

Measured memory_bytes: 13716
#include<bits/stdc++.h>
#define S 100000
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
vector<int>E[S];
int u[2 * S], v[2 * S], r[2 * S], ans[2 * S], d[S], cnt = 1, b[2 * S], ok[S]{ 1 };
queue<int>que;
void bfs(int u) {
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		for (int v : E[p]) {
			if (d[v] > d[p] && !ok[v]) {
				ok[v] = 1; cnt++; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; scanf("%d%d%d", &n, &m, &q);
	rep(i, m) {
		scanf("%d%d", &u[i], &v[i]);
		u[i]--; v[i]--;
		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; que.push(0);
	while (!que.empty()) {
		int p = que.front(); que.pop();
		for (int i : E[p]) {
			if (!~d[i]) {
				d[i] = d[p] + 1; que.push(i);
			}
		}
	}
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		scanf("%d", &r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] - d[u[i]] == 1) {
				E[u[i]].push_back(v[i]);
			}
		}
	}
	bfs(0);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].push_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]]);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool f = (A == B && A != C && B != C) || (A == C && A != B && B != C) || (B == C && A != B && A != C);
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

const int N=100005;
int x[N],w[N],ans[N];

int main(){
	int n,L,T,pos=0;
	scanf("%d%d%d\n",&n,&L,&T);
	for (int i=0;i<n;i++){
		scanf("%d%d\n",&x[i],&w[i]);
		if (w[i]==2) w[i]=-1;
		ans[i]=((x[i]+w[i]*T)%L+L)%L;
	}
	for (int i=1;i<n;i++)
	if (w[i]!=w[0]){
		int t=T*2-((w[0]*(x[i]-x[0])%L+L)%L)-1;
		if (t>=0) pos=(pos+t/L+1)%n;
	}
	pos=(pos*w[0]+n)%n;
	int v=ans[0];
	std::sort(ans,ans+n);
	for (int i=0;i<n;i++)
	if (ans[i]==v){
		i+=(i<n-1 && ans[i]==ans[i+1] && w[0]==-1);
		pos=(i-pos+n)%n;break;
	}
	for (int i=0;i<n;i++) printf("%d\n",ans[(i+pos)%n]);
}

Measured memory_bytes: 2304
def jug(l,income):
    assert len(income)==12, "income strange"
    s = 0 
    for i in range(len(income)):
        inc = income[i]
        s += inc[0] - inc[1]
        if s >= l:
            return(str(i+1))
    return("NA")

while True:
    income=[]
    l=int(input())
    if l==0:
        break
    for i in range(12):
        m,n = list(map(int,input().strip().split()))
        income.append((m,n))
    print(jug(l,income))



Measured memory_bytes: 5620
#include "bits/stdc++.h"

using namespace std;

int main() {
	string arr[2];
	cin >> arr[0];
	cin >> arr[1];

	if (arr[0][0] == arr[1][2] && arr[0][1] == arr[1][1] && arr[0][2] == arr[1][0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
//#ifdef YANG33
//#include "mydebug.hpp"
//#else
//#define DD(x) 
//#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/10/23  Problem: ABC 088 D / Link: http://abc088.contest.atcoder.jp/tasks/abc088_d  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

inline bool IN(int y, int x, int H, int W) { return (0 <= y && y < H && 0 <= x && x < W); }

int bfs2D(pair<int, int> s, pair<int, int> t, int Height, int Width, const VS & masu) {
	vector<vector<int> > d(Height, vector<int>(Width, 1e9));

	d[s.first][s.second] = 0;
	queue<pair<int, pair<int, int>>>q;
	q.push(make_pair(0, s));

	while (!q.empty()) {
		pair<int, pair<int, int>>a = q.front(); q.pop();
		int dist = a.first; pair<int, int> pos = a.second;
		if (d[pos.first][pos.second] < dist)continue;
		FOR(k, 0, 4) {
			int ny = pos.first + DY[k]; int nx = pos.second + DX[k];
			if (IN(ny, nx, Height, Width)) {
				if (masu[ny][nx] == '.')
					if (d[ny][nx] > d[pos.first][pos.second] + 1) {
						d[ny][nx] = d[pos.first][pos.second] + 1;
						q.push(make_pair(d[ny][nx], pair<int, int>(ny, nx)));
					}
			}
		}
	}

	return d[t.first][t.second]; // (int)
}

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


	int H, W; cin >> H >> W;
	int ans = H * W;
	VS vs(H);
	int C = 0;
	FOR(i, 0, H) {
		cin >> vs[i];
		FOR(j, 0, W) {
			if (vs[i][j] == '#')C++;
		}
	}
	int res = bfs2D(PII(0, 0), PII(H - 1, W - 1), H, W, vs);
	ans = H * W - C - (res + 1);
	if (res == INF)ans = -1;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int c1,c5,c10,c50,c100,c500;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	int a;
	a=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
	if(a>=1000){
		puts("1");
	}
	else{
		puts("0");
	}
	return 0;
}


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

int main(){
  long K,A,B,max=0;
  cin >> K >> A >> B;
  if(B-A<3 || K<=A) max=K+1;
  else {
    long Kpart2=K-A+1;
    if(Kpart2 % 2 == 0){
      max=(Kpart2/2)*(B-A)+A;
    }
    else {
      max=(Kpart2-1)/2*(B-A)+A+1;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

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

using namespace std;

int main() {
    LL c = 0;
    string S;
    cin >> S;

    for (LL i = 1; i < S.length(); ++i) {
        if (S[i] == S[i - 1]) {
            S[i] = (S[i] == '0') ? '1' : '0';
            ++c;
        }
    }
    
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    for(int i=1; i<=9; ++i){
        for(int j=1; j<=9; ++j){
            if(i*j==N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<int> h(n+1);
    for(int i=1;i<=n;i++) cin >> h[i];

    vector<pair<int,int>> vec(n+1);
    vector<int> wa(n+1);
    for(int i=1;i<=n;i++){
        wa[i] = h[i] + i;
        vec[i] = {i - h[i], i};
    }
    sort(vec.begin(),vec.end());
    vector<int> sa(n+1),sapos(n+1);
    for(int i=1;i<=n;i++){
        sa[i] = vec[i].first;
        sapos[i] = vec[i].second;
    }

    ll count = 0;
    for(int i=1;i<=n;i++){
        int itrl = lower_bound(sa.begin(),sa.end(),wa[i]) - sa.begin();
        int itrr = lower_bound(sa.begin(),sa.end(),wa[i]+1) - sa.begin();
        if(sa[itrl]!=wa[i]) continue;
        
        while(sapos[itrl]<=i) itrl++;
        count += itrr - itrl;
        /*while(sa[itrl]==wa[i]){
            if(sapos[itrl]>i){count++; itrl++;}
        }*/
    }

    cout << count << endl;
}

Measured memory_bytes: 8012
import networkx as nx
import sys

G = nx.Graph()

n, m = map(int, input().split())
if m == 0:
    print(1)
    sys.exit()
for i in range(m):
    a, b = map(int, input().split())
    G.add_edge(a, b)

largest_cc = max(nx.connected_components(G), key=len)
print(len(largest_cc))


Measured memory_bytes: 263408
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N = ii()
    A = list(mi())

    A.sort()
    if A[0] == 1:
        print(1)
        exit()
    
    ini = A[0]
    while len(A) > 1:
        x = A[0]
        B = set([x])
        for a in A:
            b = a%x
            if b > 0:
                B.add(b)

        A = list(B)
        A.sort()

    if len(A) > 0:
        print(A[0])
    else:
        print(ini)
            

            
        



if __name__ == "__main__":
    main()

Measured memory_bytes: 86456
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 500005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;

int main() {
	scanf("%lld %lld", &N, &M);
	for(int i = 0; i < M; i++) {
		scanf("%lld", &arr[i]);
	}
	for(int i = M; i < 2 * M; i++) {
		arr[i] = N + arr[i % M];
	}
	ll ans = 1e15;
	for(int i = 0; i < M; i++) {
		ans = min(arr[M + i - 1] - arr[i], ans);
	}
	printf("%lld\n", ans);

	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 4992
package main

import (
	"fmt"
)

func main() {
	var a, b, c string
	fmt.Scanf("%s", &a)
	fmt.Scanf("%s", &b)
	fmt.Scanf("%s", &c)

	var game = map[uint8]string{
		'a': a,
		'b': b,
		'c': c,
	}
	var owner uint8
	owner = 'a'
	for {
		game, owner = rotate(game, owner)
		if len(game[owner]) == 0 {
			fmt.Printf("%c\n", owner-32)
			return
		}
	}
}

func rotate(game map[uint8]string, owner uint8) (map[uint8]string, uint8) {
	s := game[owner]
	game[owner] = s[1:]
	return game, s[0]
}


Measured memory_bytes: 512
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	while (true) {
		string s;
		cin >> s;
		LL k = -1;
		cin >> k;
		if (s.empty() || k <= 0) break;
		int len = s.length();
		int f;
		for (f = 0; f < len; ++f) {
			if (s[0] != s[f]) break;
		}
		LL ans = 0;
		if (f == len) {
			ans = (k * len) / 2;
		} else {
			ans = k * (f / 2);
			char prev = s[f - 1];
			int cnt = 0;
			for (int i = f; i < len; ++i) {
				if (s[i] != prev) {
					cnt = 0;
				}
				if ((++cnt % 2) == 0) {
					ans += k;
				}
				prev = s[i];
			}
			if (s[0] == s[len - 1] && (f % 2) == 1 && (cnt % 2) == 1) {
				ans += k - 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n, r_cnt = 0, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        r_cnt += (s[i] == 'R' ? 1 : 0);
    }
    for (int i = 0; i < r_cnt; i++) {
        ans += (s[i] == 'W' ? 1 : 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	char s[105];
	scanf("%s", s);
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    string S;
    S = to_string(N);
    string H = to_string(S[0]-'0');
    if (S <= H + H + H)
    {
        cout << H + H + H << endl;
    }
    else
    {
        H = to_string(S[0] -'0' + 1);
        cout << H + H + H << endl;
    }
    return 0;
}

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

using namespace std;

using ull = unsigned long long;

int main() {
    string S;
    cin >> S;
    do {
        if(S[0] == S[1] && S[2] == S[3] && S[0]!=S[2]) break;
        if(S[0] == S[2] && S[1] == S[3] && S[0]!=S[1]) break;
        if(S[0] == S[3] && S[1] == S[2] && S[0]!=S[1]) break;
        cout << "No" << endl;
        return 0;
    } while(0);
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    double x1,x2,x3,x4,y1,y2,y3,y4;
    double a,b;
    int n,i;

    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        a = (y2 - y1)/(x2 - x1);
        b = (y4 - y3)/(x4 - x3);
        if(a == b) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll t;
  cin >> n >> t;
  ll a[n], cur = 0, reset = 0;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 1; i < n; i++){
    if(a[i] - cur <= t) cur = a[i];
    else reset += a[i] - cur - t, cur = a[i];
  }
  cout << cur + t - reset << endl;
  return 0;
}

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


int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K-1] = S[K-1] + 32;
    cout << S << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	int ans = 0;
	for (int i = 0;i <= s.length() - t.length();i++) {
		int tmp = 0;
		for (int j = 0;j < t.length();j++) {
			if (s[j + i] == t[j]) {
				tmp++;
			}
		}
		if (ans < tmp)ans = tmp;
	}

	cout << t.length() - ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<climits>
using namespace std;
 
const int inf = INT_MAX;
vector<int> pos;
vector<vector<pair<int, int>>> edge;
 
bool check(int src)
{
	for(int i=0; i<edge[src].size(); i++){
		int dst =edge[src][i].first;
		int d = edge[src][i].second;
 
		if(pos[dst] == inf){
			pos[dst] = pos[src] + d;
 
			if(check(dst) == false)
				return false;
		}
		else if(pos[dst] != pos[src]+d)
				return false;
	}
 
	return true;
}
 
int main(void)
{
	int N, M;
	cin >> N >> M;
 
	edge = vector<vector<pair<int, int>>>(N, vector<pair<int, int>>());
	for(int i=0; i<M; i++){
		int L, R, D;
		cin >> L >> R >> D;
 
		L--;
		R--;
 
		edge[L].push_back(make_pair(R, D));
		edge[R].push_back(make_pair(L, -D));
	}
 
	pos = vector<int>(N, inf);
	for(int i=0; i<N; i++){
		if(pos[i] != inf)
			continue;
 
		pos[i] = 0;
		if(check(i) == false){
			cout << "No" << endl;
			return 0;
		}
	}
 
	cout << "Yes" << endl;
 
	return 0;
}

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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	   int ans = 0;
	string s, t; cin >> s >> t;
	for(int i = 0; i < s.size(); i++){
		if(s.at(i) != t.at(i)) ans++;
	}
	cout << ans << endl;
} 

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s, t;
  cin >> s >> t;
  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));
  cout << (s < t ? "Yes" : "No") << endl;
}

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

using namespace std; 

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;

int main()
{
    IOS

    int numero;
    cin >> numero;

    int x = numero % 10;

    if ( x == 0 || x == 1 || x == 6 || x == 8 ) cout << "pon";
    else if ( x == 3 ) cout << "bon";
    else cout << "hon";

    return 0;
}

Measured memory_bytes: 3584
<?php
fscanf(STDIN, '%d %d', $N, $K);
$H = array_map('intval', explode(' ', trim(fgets(STDIN))));
sort($H);
$ans = 0;
for ($i = 0; $i < $N - $K; $i++) {
    $ans += $H[$i];
}
printf('%d', $ans);


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

namespace CSharpSample01
{
    

    class Program
    {
        
        
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] mon_num = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int[] yusha_power = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            long hit_cnt = 0;

            for(int i = 0; i < N; i++)
            {
                if (mon_num[i] >= yusha_power[i])
                {
                    hit_cnt += yusha_power[i];
                }
                else
                {
                    hit_cnt += mon_num[i];
                    yusha_power[i] -= mon_num[i];
                    if (mon_num[i + 1] >= yusha_power[i])
                    {
                        hit_cnt += yusha_power[i];
                        mon_num[i + 1] -= yusha_power[i];
                    }
                    else
                    {
                        hit_cnt += mon_num[i + 1];
                        mon_num[i + 1] = 0;
                    }
                }

            }

            Console.WriteLine(hit_cnt);

        }
    }
}

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

using namespace std;
int main()
{
int n;
int val;
vector<int> v,sol;
cin>>n;
int i;
for(i=0;i<n;i++)
{
    cin>> val;
    v.push_back(val);
}
int max=INT_MIN;
long long ans=0;
for(i=0;i<n;i++)
{
    if(max<v[i])
    {
        max=v[i];
        
    }
    else
    {
      ans=ans+ max-v[i];
    }
   
    
}
 cout<<ans;
  return 0;
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		long long n, x, d;
		cin >> n >> x >> d;
		if(d == 0){
			if(x == 0)cout << 1 << endl;
			else cout << n+1 << endl;
			return;
		}
		if(d < 0){
			x = -x;
			d = -d;
		}
		map<long long, vector<pair<long long, long long>>> f;
		for(long long k=0; k <= n; k++){
			auto r = ((k*x)%d + d) % d;
			auto q = (k*x-r)/d;
			auto m = (k * (k-1))/2;
			auto M = m + k * (n-k);
			f[r].push_back(make_pair(q + m, q + M + 1));
		}
		long long ret = 0;
		for(auto t: f){
			sort(t.second.begin(), t.second.end());
			long long z = numeric_limits<long long>().min();
			for(auto s: t.second){
				if(s.second <= z)continue;
				if(s.first <= z){
					ret += s.second - z;
				}else{
					ret += s.second - s.first;
				}
				z = s.second;
			}
		}
		cout << ret << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> k;
  cin >> a >> b;
  repe(i, a, b)
  {
    if (i % k == 0)
    {
      count++;
    }
  }
  if (count > 0)
  {
    cout << "OK" << endl;
  }
  else
  {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

// DP[i][j] : ｉ番目までのコインを使って、ｊ円支払うときの最小の枚数
long long int DP[51000];

int main(){
	
	int n, m;
	cin >> n >> m;
	
	for(int j = 0; j <= n; j++){
		DP[j] = INF;
	}
	DP[0] = 0;
	
	for(int i = 0; i < m; i++){
		int c;
		cin >> c;
		for(int j = c; j <= n; j++){
			DP[j] = min(DP[j], DP[j - c] + 1);
		}
	}
	
	cout << DP[n] << endl;
	
	return 0;
}


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

int main() {
    int N, X, x[100000];
    cin >> N >> X;
    rep(i, N) {
        cin >> x[i];
        x[i] = abs(x[i] - X);
    }
    if (N > 1) {
        int ans = __gcd(x[0], x[1]);
        REP(i, 2, N) {
            ans = __gcd(ans, x[i]);
        }
        cout << ans << endl;
    } else {
        cout << x[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

	int X = scan.nextInt();
	int A = scan.nextInt();
	int B = scan.nextInt();

	int sum = X - A;

	for(int i = 0; sum >= B; i++){
	    sum -= B;
	}
	System.out.println(sum);
    }
    
}


Measured memory_bytes: 23764
import sys

def f(A):
    n = len(A)
    A = sorted(A)
    B = [A[0] + n]
    for a in A[1:]:
        B.append(a-1)

    return B


def main():
    input = sys.stdin.readline
    K = int(input())

    i = 2
    while i <= 50:
        n = K // i
        m = K % i

        A = [0 for _ in range(i)]
        for j in range(i):
            A[j] = n + j

        for _ in range(m):
            A = f(A)

        if max(A) <= 10**16 + 1000:
            print(i)
            print(*A)
            return 0
        else:
            i += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct{
  int k;
  int l;
  int r;
} Node;

void insert(Node *T, int index, int key){

  int x = 0;
  int y;

  T[index].k = key;
  T[index].l = NIL;
  T[index].r = NIL;

  if( index == 0 ){
    return;
  }

  while( x != NIL ){
    y = x;

    if( key < T[x].k ){
      x = T[x].l;
    }else{
      x = T[x].r;
    }

  }

  if( key < T[y].k ){
      T[y].l = index;
    }else{
      T[y].r = index;
    }

}

void pre(Node *T, int u){

  if( u == NIL ){
    return;
  }

  printf(" %d",T[u].k);
  pre(T,T[u].l);
  pre(T,T[u].r);

}

void ino(Node *T, int u){

  if( u == NIL ){
    return;
  }

  ino(T,T[u].l);
  printf(" %d",T[u].k);  
  ino(T,T[u].r);

}


int main(){

  int i;
  int n;
  char order[8];
  Node *T;
  int index = 0;
  int key;

  scanf("%d",&n);

  T = malloc(sizeof(Node)*n);

  for( i = 0 ; i < n ; i++ ){

    scanf("%s",order);

    if( order[0] == 'i' ){
      scanf("%d",&key);
      insert(T,index,key);
      index++;
      
    }else if( order[0] == 'p' ){

      if( index > 0 ){

        ino(T,0);
        printf("\n");
        pre(T,0);
        printf("\n");

      }

    }

  }

  return 0;
}

Measured memory_bytes: 6464
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>
#include <functional>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);

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

	if (N % 2 != 0)
		a.push_back(0), N++;

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

	ll sum = 0;
	for (ll i = N / 2; i > 0; i--)
	{
		sum += a[2 * i - 1] - a[2 * i - 2];
	}
	cout << sum << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b;
    cin >> a >> b;
    if(a <= 8 && b <= 8){
    	cout << "Yay!\n";
    }
    else
    	cout << ":(\n";
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n]={};
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int sum[8]={};
    int test = 0;
    for(int i=0;i<n;i++){
        if(a[i]>=3200) test++;
        else{
            int num = a[i]/400;
            sum[num]++;
        }
    }
    int count = 0;
    for(int k=0;k<8;k++){
        if(sum[k]==0) count++;
    }
    if (count==8){
        cout << 1 << " " << test << endl;
    }
    else{
        cout << 8-count << " " << 8-count+test << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

int main(){
    int n;
    std::vector<int> d;
    int b ,c;

    std::cin >> n;
    b = n / 2;

    for(int a = 0; a < n; a++){
        std::cin >> c;
        d.push_back(c);
    }

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

    std::cout << d[b] - d[b - 1] << std::endl;

    return 0;  
}


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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
	int n, m;
	cin >> n >> m;
	int s[5], c[5];
	fori(m) cin >> s[i] >> c[i];
	if (m == 0) {
		if (n == 1) {
			cout << 0;
			return 0;
		}
		cout << 1;
		fori(n - 1) cout << 0;
		return 0;
	}
	bool x = false, y = false;
	fori(m) {
		//桁オーバー
		//頭
		if (s[i] == 1 && c[i] == 0 && n != 1) {
			cout << -1;
			return 0;
		}
	}
	fori(m) {
		//かみ合い
		forj(m) {
			if (s[i] == s[j]) {
				if (c[i] != c[j]) {
					cout << -1;
					return 0;
				}
			}
		}
	}
	string r(n, '0');
	fori(m) { r[s[i] - 1] = ('0' + c[i]); }
	if (r[0] == '0' && n != 1) r[0] = '1';
	cout << r;
	return 0;
}

Measured memory_bytes: 256
use std::cmp;
use std::cmp::{max, min};
use std::cmp::Ordering::{self, Greater, Less};
use std::collections::{HashMap, HashSet};
use std::f64::consts::PI;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[allow(dead_code)]
fn abc086_a() {
    input! {
    n: [i32; 2],
    }
    let prod: i32 = n[0] * n[1];
    let res = if prod % 2 == 0 {
        "Even"
    } else {
        "Odd"
    };
    println!("{}", res)
}


fn main() {
    abc086_a()
}



Measured memory_bytes: 4352
using System;

namespace A___White_Cells
{
    class Program
    {
        static void Main(string[] args)
        {
            var H_W = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int H = H_W[0], W = H_W[1];
            var h_w = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int h = h_w[0], w = h_w[1];

            Console.WriteLine((H - h) * (W - w));
        }
    }
}


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


int compare_num(void *a, void *b){
    return *(int*)a - *(int *)b;
}


int main(void)
{
    int N, x;
    scanf("%d %d", &N, &x);

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

    qsort(a, N, sizeof(int), compare_num);
    /*for(i = 0; i < N; i++){
        printf("%d\n",a[i]);
    }*/
    int SUM = 0;
    int COUNT = 0;
    for (i = 0; i < N; i++){
        SUM += a[i];
        if(SUM >= x){
            if(SUM == x){
                COUNT++;
                break;
            }
            COUNT - 1;
            break;
        }
        COUNT++;
    }
    
    if(SUM < x){
        COUNT--;
    }

    printf("%d\n", COUNT);

    return 0;
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	bool ok = false;
	for(int i=0;i<s.size();++i){
		if(s[i] == '7') ok = true;
	}

	cout << (ok ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	} else if (a == c) {
		cout << b << endl;
	} else {
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a+b>=c)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main()
{
	string a,b;
	cin >> a >> b;
	int last = a.size() - b.size() + 1;
	for(int i = 0;i < last;i++)
	{
		if(a[i] == b[0])
		{
			for(int j = 0;j < b.size();j++)
			{
				if(a[i+j] != b[j])break;
				if(j == b.size() -1) cout << i << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3160
import java.io.*;
import java.util.InputMismatchException;

public class Main {

    public static void main(String[] args){
        InputStream inputStream = System.in;
        InputReader in = new InputReader(inputStream);
        int n = in.nextInt();
        int m = in.nextInt();
        int x = in.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m];

        for (int i = 0; i < n; i++) {
            c[i] = in.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = in.nextInt();
            }
        }

        long ans = Long.MAX_VALUE;

       for (int i = 0; i < Math.pow(2,n); i++) {
            boolean ok = true;
            long res = 0;
           for (int k = 0; k < m; k++) {
                long sum = 0;
                for (int j = 0; j < n; j++) {
                    if ((1&i >> j) == 1) {
                        res += c[j];
                        sum += a[j][k];
                    }
                    // System.out.println(sum);
                }
                if (sum < x) {
                    ok = false;
                    break;
                }
                // System.out.println();
            }
            // System.out.println(res/m);
            if (ok) {
                ans = Math.min(ans,res/m);
            }
        }

        if (ans == Long.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1 << 16];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;
                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException ex) {
                        throw new InputMismatchException();
                    }
                    if (this.numChars <= 0) {
                        return -1;
                    }
                }
                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c = this.read();
            while(isSpaceChar(c))
                c = this.read();
            int sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }
            int res = 0;
            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }
            throw new InputMismatchException();
        }


        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }
    }
}

Measured memory_bytes: 32632
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>

using namespace std;

#define INF (1<<29)
#define PRINT(A) {for (auto it=A.begin(); it != A.end(); ++it) {cout << *it << ' ';} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define BIT_LENGTH(N) floor(log2(N)) + 1
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define RREP(I, N) for (int I = N-1; I >= 0 ; --I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RREPP(I, A, B) for (int I = A; I > (B); --I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef map<int, int> MII;
typedef set<int> SI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int main() {
    int N;
    cin >> N;
    cout << (1000 - (N % 1000)) % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3616
import bisect
n,m = map(int,input().split())

g = [[ ] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)

    #print(bisect.bisect_left(g[a],b))
    #g[a][] = b
    #g[a].append(b)
    #g[b].append(a)

#g[4].sort()
    
ans = 0

def dfs(x,check):
    #print(check,x)
    ans = 0
    if not False in check:
        #print(ans)
        return 1
        #check[x] = 0
        #print(x)
    #print(check)
    for i in g[x]:
        if check[i] == True:
            continue
        #print(i,check)
        check[i] = True
        ans += dfs(i,check)
        check[i] = False
    
    return ans
    
check = [False] * (n+1)
check[0] = True
check[1] = True

print(dfs(1,check))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    ll n,m;
    cin >> n >> m;
    multimap<ll,ll> st;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        st.insert(make_pair(a,b));
    }
    ll ans = 0;
    for(auto a : st){
        if(m < a.second){
            ans += m*a.first;
            break;
        }
        else{
            ans += a.second*a.first;
            m -= a.second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9840
# Nを入力
n = int(input())
# N割る111の1の位だけ抽出してiにいれる
i = int(n / 111)
# nを111で割った数の余りが0じゃない場合のみ、
# N割る111の1の位だけ抽出してiに1を足す
if n % 111 != 0:
    i += 1
# iと111をかける
print(i * 111)

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

not_happy = 0
R = 0
R_edge = 0

for i in range (N-1):
    if S[i] == "R" and S[i+1] == "L":
        R += 1

if S[0] == "L":
    R_edge +=1
if S[N-1] == "R":
    R_edge +=1

#print(R)
#print(R_edge)

if K <= R:
    R -= K
else:
    R = 0
    R_edge = 1

not_happy = R*2 + R_edge
happy = N - not_happy

#print(R)
#print(R_edge)
#print(not_happy)
print(happy)

Measured memory_bytes: 49392
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int length = scanner.nextInt();
        final int[] difficulties = new int[length];

        for (int i = 0; i < length; i++) {
            difficulties[i] = scanner.nextInt();
        }

        Arrays.sort(difficulties);

        final int half = length / 2;
        System.out.println(difficulties[half] - difficulties[half - 1]);
    }
}


Measured memory_bytes: 52008
#include <bits/stdc++.h>
using namespace std;
int main() {
  char a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int x = 0;
  if (b == e) {
    if (a == f) {
      if (c == d) {
        cout << "YES" << endl;
        x = 1;
      }
    }
  }
  if (x == 0) {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256