akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9+7;
const int N=1e5+2;
int mat[N],par[N];
struct Dinic 
{
   int n, s, t;
   struct Edge 
   {
      int to, cap, flow, rev;
      Edge(int to = 0, int cap = 0, int flow = 0, int rev = 0) :
         to(to), cap(cap), flow(flow), rev(rev) {}
   };
   vector <int> d;
   vector <int> ptr;
   vector<vector<Edge>> g;
 
   Dinic(int n = 0, int s = 0, int t = 0) :
      n(n), s(s), t(t), d(n + 2), ptr(n + 2), g(n + 2) {}
   void addEdge(int u, int v, int cap) 
   {
      g[u].emplace_back(v, cap, 0, g[v].size());
      g[v].emplace_back(u, 0, 0, g[u].size() - 1);
   }
 
   bool bfs() 
   {
      fill(d.begin(), d.end(), -1);
      fill(ptr.begin(), ptr.end(), 0);
 
      queue <int> q;
      d[s] = 0;
      q.push(s);
      while (!q.empty()) 
      {
         int u = q.front();
         q.pop();
         for (auto e : g[u]) 
         {
            if (d[e.to] == -1 && e.cap > e.flow) 
            {
               d[e.to] = d[u] + 1;
               q.push(e.to);
            }
         }
      }
      return d[t] != -1;
   }
 
   int dfs(int u, int flow) 
   {
      if (u == t) 
      {
         return flow;
      }
      for (int &i = ptr[u]; i < (int)g[u].size(); i++) 
      {
         auto &e = g[u][i];
         if (e.cap <= e.flow || d[e.to] != d[u] + 1) 
            continue;
         int nxt = dfs(e.to, min(flow, e.cap - e.flow));
         if (nxt) 
         {
            e.flow += nxt;
            g[e.to][e.rev].flow -= nxt;
            return nxt;
         }
      }
      return 0;
   }
   int maxFlow() 
   {
      int ans = 0;
      while (bfs()) 
      {
         while(true)
         {
            int now = dfs(s, inf);
            if (now) ans += now;
            else break;
         }
      }
      return ans;
   }
   void trace(){
   	    for(int i=2;i<=(n-1)/2;i++){
	     for(int j=0;j<g[i].size();j++){
	     	//cout<<g[i][j].cap<<' '<<g[i][j].flow<<' '<<i<<' '<<g[i][j].to<<endl;
	     	if(g[i][j].cap==g[i][j].flow&&g[i][j].cap>0){
	     		mat[g[i][j].to-(n-1)/2]=i;
			 }
		 }
	    }
   }
};
vector<int> lis[N];
bool used[N];
void dfs1(int x){
	used[x]=true;
	for(int i=0;i<lis[x].size();i++){
		if(!used[mat[lis[x][i]]]){
			used[mat[lis[x][i]]]=true;
			par[lis[x][i]]=x;
			dfs1(mat[lis[x][i]]);
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l;
	cin>>n;
	Dinic dn(2*n+1,n+1,2*n+1);
	for(i=2;i<=n;i++){
		cin>>j;
		while(j--){
			cin>>k;
			lis[k].push_back(i);
			if(k!=1){
				dn.addEdge(k,n+i,1);
			}
		}
		dn.addEdge(n+1,i,1);
		dn.addEdge(i+n,2*n+1,1);
	}
	if(dn.maxFlow()!=n-1){
		cout<<"-1";
		return 0;
	}
	dn.trace();
//	for(i=1;i<=n;i++){
//		cout<<mat[i]<<endl;
//	}
	dfs1(1);
	for(i=1;i<=n;i++){
		if(!used[i]){
			cout<<"-1";
			return 0;
		}
	}
	for(i=2;i<=n;i++){
		cout<<par[i]<<' '<<mat[i]<<'\n';
	}
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI;typedef pair<ll,ll> pii;
const int mod = (int)1e9 + 7;


int main()
{
	
	ll n,m;
	cin >>n >>m;
	
	
	ll ans = min(n,m/2);
	m -=  2 * ans;
	if(m>0) ans += m/4;
	
	cout << ans <<endl;
	
	return 0;

}


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

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	long long int a, b, c, k;
	cin >> a >> b >> c >> k;

	long long int total = min(k, a);
	k = k - a;

	if (k > 0) {
		k = k - b;

		if (k > 0) {
			total += min(k, c) * -1;
		}
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef complex<double> cmplx;
const double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = (int)1e+9 + 7;
const double eps = 1e-8;
const int N = 500'000;

int n, m, k;

void solve()
{
    cin >> n;
    set<string> st;
    string s;
    cin >> s;
    st.insert(s);
    bool ok = true;
    for (int i = 1; i < n; ++i) {
        string s1; cin >> s1;
        if (s.back() != s1.front() ||
            st.find(s1) != st.end())
            ok = false;
        s = s1;
        st.insert(s);
    }
    if (ok)
        cout << "Yes";
    else
        cout << "No";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int test = 1;
    //cin >> test;
    for (; test; --test)
        solve();
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()

    val inputs = readLine()!!.split(" ").map { it.toInt() }
    val (lowMid, highMid) = inputs.sorted().subList(N / 2 - 1, N / 2 + 1)

    inputs.forEach {
        if (it <= lowMid) println(highMid)
        else println(lowMid)
    }
}

Measured memory_bytes: 98844
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main(){

    input!{
        k: usize,
        x: usize,
    }

    if 500*k>=x{
        println!("Yes");
    } else {
        println!("No");
    }

}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#define PI 3.14159265358979323846264

using namespace std; 



int main(void){

	int n;
	double v,box_area[5],height,width,depth,min_area;
	
	vector<double> hole;
	vector<double> hole_area;
	
	while(1){
	
		height=0;
		width=0;
		depth=0;
		n=0;
		min_area=0;
		
		hole.clear();
		
		hole_area.clear();

		for(int i=0;i<5;i++){
			box_area[i]=0;
		}
		
		scanf("%lf %lf %lf",&height,&width,&depth);
		
		if(height==0 && width==0 && depth==0){
			break;
		}
		
		scanf("%d",&n);

		for(int i=0;i<n;i++){
			cin>>v;
			hole.push_back(v);
		}

		for(int i=0;i<n;i++){
			hole_area.push_back(hole[i]*2.0);
			//printf("hole_area[%d]=%lf\n",i,hole_area[i]);
		}

		box_area[0]=sqrt(1.0*height*height+1.0*width*width);	//¼ûÌÌ3ÊÌ»ê¼êÌÎpü
		box_area[1]=sqrt(1.0*height*height+1.0*depth*depth);
		box_area[2]=sqrt(1.0*width*width+1.0*depth*depth);

		/*for(int i=0;i<3;i++){
			printf("box_area[%d]=%lf\n",i,box_area[i]);
		}
		printf("hei=%lf wid=%lf dep=%lf\n",height,width,depth);*/
		
		min_area=min(box_area[0],min(box_area[1],box_area[2]));
		
		//printf("¼ûÌÌÅ¬ÊÏÍ:%lf\n",min_area);

	
		for(int i=0;i<n;i++){
			
			if(hole_area[i]>min_area){
				printf("OK\n");			
			}
			else{
				printf("NA\n");	
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
<?php
fscanf(STDIN, '%d', $N);
for ($i = 0; $i < $N; $i++) {
	fscanf(STDIN, '%d', $n);
	if ($i === 0) {
		$min = $n;
		continue;
	} elseif ($i === 1) {
		$profit = $n - $min;
		$prev = $n;
		continue;
	}

	if ($prev < $min) {
		$min = $prev;
	}

	$result = $n - $min;
	$prev = $n;

	if ($result > $profit) {
		$profit = $result;
	}
}

echo $profit, PHP_EOL;

Measured memory_bytes: 6552
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(abs(a - c) <= abs(d)){
		printf("Yes\n");
	}
	else if(abs(a - b) <= abs(d) && abs(c - b) <= abs(d)){
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}

	

Measured memory_bytes: 128
n = gets.strip.to_i
a = 1
m = 1
c = 1000000007

(1..n).each do |i|
  a = m * i
  m = a % c
end
puts m

# 参考URL
# https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

Measured memory_bytes: 1788
using System;

namespace Wandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var imp = Console.ReadLine().Split(' ');
            int N = int.Parse(imp[0]);
            int K = int.Parse(imp[1]);
            int ask = N%K;
            if(ask == 0) Console.Write("0");
            else Console.Write('1');
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

template <template <class, class...> class TT, class... Args>
ostream& operator<<(ostream& out, TT<Args...> const& cont) {
    for (auto&& elem : cont) out << elem << " ";
    return out;
}
template <class T> ostream& operator<<(ostream& out, const vector<vector<T>>& vs) {
    for (auto&& v : vs) cout << v << endl;
    return out;
}
template <class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> const& val) {
    return (out << "{" << val.first << " " << val.second << "}");
}

void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) {
    cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...);
}
#ifdef _MY_DEBUG
#define dump(...)                                                                                                    \
    cerr << "/* " << #__VA_ARGS__ << " [" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), \
        cerr << "*/\n\n";
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: CREATED_TIMESTAMP
 **/

constexpr Int INF = 1e18;
signed main() {
    Int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<Int> dp(n + 1, INF);
    dp[n] = 0;
    Int cur = n;
    while (cur > 0) {
        Int nxt = cur;
        REPI(i, max(0LL, cur - m), cur) {
            if (s[i] == '1') continue;
            chmin(nxt, i);
            dp[i] = dp[cur] + 1;
        }
        if (nxt == cur) {
            cout << -1 << endl;
            return 0;
        }
        cur = nxt;
    }
    vector<Int> ans;
    cur = 0;
    REP(i, n + 1) {
        dump(i);
        if (dp[i] == dp[cur] - 1) {
            ans.push_back(i - cur);
            cur = i;
        }
    }
    for (Int x : ans) cout << x << " ";
    cout << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e10

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n;
	while(cin>>n, n!=0){
		vll a(n);
		rep(i, n) cin >> a[i];
		sort(all(a));

		ll mini=INF;
		rep(i, n-1){
			mini = min(mini, a[i+1]-a[i]);
		}
		cout << mini << "\n";
	}
	return 0;
}


Measured memory_bytes: 3216
#!/usr/bin/env python3
from itertools import product
S = input()
cur = 0
ans = False
for i, j in product(range(len(S)), range(len(S))):
    if i >= j:
        continue
    if S[:i] + S[j:] == 'keyence':
        ans = True
print(['NO', 'YES'][ans or S == 'keyence'])


Measured memory_bytes: 3060
n,m,c=map(int, input().split())
b=list(map(int,input().split()))
A = [list(map(int, input().split())) for _ in range(n)]
def mul(x,y,co):
    p=sum([x[i]*y[i] for i in range(len(x))])
    return p+co
print(sum([mul(a,b,c)>0 for a in A]))


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    string s;
    int n, a, b, c, d;

    cin >> n >> a >> b >> c >> d;
    cin >> s;
    a--;b--;c--;d--;

    bool toureru = true;
    for (int i = a; i < c; i++) {
            if(s[i] == '#' and s[i+1] == '#') toureru = false;
    }
    for (int i = b; i < d; i++) {
            if(s[i] == '#' and s[i+1] == '#') toureru = false;
    }


    if (d < c) {
        int num_space = 0;
        bool irekawareru = false;
        for (int i = b; i <= d; i++) {
            if(i-1<0 or i+1>=n)continue;
            if (s[i] == '.' and s[i+1] == '.' and s[i-1] == '.'){
                irekawareru = true;
            }
            //cout << num_space << " " ;
        } //cout << endl;

         if (toureru and irekawareru) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (toureru) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	long long ans = 0;
	if (a + b > c * 2) {
		while (x > 0 && y > 0) {
			x--, y--;
			ans += c * 2;
		}
		if (x > 0) {
			if (a < c * 2) {
				while (x > 0) {
					x--, ans += a;
				}
			} else {
				while (x > 0) {
					x--, ans += c * 2;
				}
			}
		}
		if (y > 0) {
			if (b < c * 2) {
				while (y > 0) {
					y--, ans += b;
				}
			} else {
				while (y > 0) {
					y--, ans += c * 2;
				}
			}
		}
	} else {
		while (x > 0) {
			x--, ans += a;
		}
		while (y > 0) {
			y--, ans += b;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	if (n % 2 == 1) {
		for (int i = 1; i < m + 1; i++) {
			cout << i << " " << n - i + 1 << endl;
		}
	}
	if (n % 2 == 0) {
		for (int i = 1; i < m+1; i++) {
			if (i <= n / 4) {
				cout << i << " " << n - i + 1 << endl;
			}
			else {
				cout << i << " " << n - i  << endl;
			}
		}
		
	}

	
}

Measured memory_bytes: 3612
# Aizu Problem ITP_1_11_A: Dice I
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def do_roll(dice, roll):
    d1, d2, d3, d4, d5, d6 = dice
    if roll == 'E':
        return [d4, d2, d1, d6, d5, d3]
    elif roll == 'W':
        return [d3, d2, d6, d1, d5, d4]
    elif roll == 'N':
        return [d2, d6, d3, d4, d1, d5]
    elif roll == 'S':
        return [d5, d1, d3, d4, d6, d2]
    else:
        assert False, "We should never reach this point!"
    

dice = [int(_) for _ in input().split()]
for roll in input().strip():
    dice = do_roll(dice, roll)

print(dice[0])

Measured memory_bytes: 7816
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define se second
#define pb push_back
#define ft fflush(stdout)
 
 
using namespace std;
 
 
const int N = 3e3 + 123;
const int PLS = 3e5 + 123;
const ll mod = 1e9 + 7;
const ll inf = 1e16;


ll n, dp[N], p[N], sf[N];
char s[N];


int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> s[i];
    dp[1] = 1;
    p[0] = sf[n + 1] = 0;
    for (int j = 1; j <= n; j++)
        p[j] = (p[j - 1] + dp[j]) % mod;
    for (int j = n; j >= 1; j--)
        sf[j] = (sf[j + 1] + dp[j]) % mod;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= n; j++)
            dp[j] = 0;
        for (int j = 1; j <= i; j++) {
            if (s[i - 1] == '<')
                dp[j] = p[j - 1];
            else
                dp[j] = sf[j];
        }
        for (int j = 1; j <= n; j++)
            p[j] = (p[j - 1] + dp[j]) % mod;
        for (int j = n; j >= 1; j--)
            sf[j] = (sf[j + 1] + dp[j]) % mod;
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans = (ans + dp[i]) % mod;
    cout << ans;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  string S = readString();
  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  int count = 0;
  FOR(i, 2, S.length() - 1) {
    if (S[i] == 'C') count++;
  }
  if (count != 1) {
    cout << "WA" << endl;
    return 0;
  }
  REP(i, S.length()) {
    if (S[i] < 'a' && S[i] != 'A' && S[i] != 'C') {
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
}


Measured memory_bytes: 2304
#AIsing2020 c
 
import sys,math,collections,itertools
input = sys.stdin.readline
 
N = int(input())
ans = [0]*N
 
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n <= N:
                ans[n-1] +=1
                
 
for i in range(N):
    print(ans[i])
      

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

int main() {
	map<char, int> m;
	m['I'] = 1;
	m['V'] = 5;
	m['X'] = 10;
	m['L'] = 50;
	m['C'] = 100;
	m['D'] = 500;
	m['M'] = 1000;

	string str = "";
	int sum, n;
	while (cin >> str) {
		sum = 0;
		n = 114514;
		for (int i = 0; i < str.size(); i++) {
			if (m[str[i]] <= n) {
				n = m[str[i]];
				sum += n;
			} else {
				sum += m[str[i]];
				sum -= (n * 2);
				n = 114514;
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int H, W;
    cin >> H >> W;
    int s[50][50];
    for(int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < W; j++) {
            s[i][j] = S[j] == '#';
        }
    }
    for(int y = 0; y < H; y++) {
        for(int x = 0; x < W; x++) {
            bool flag = false;
            if(!s[y][x])continue;
            for(int d = 0; d < 4; d++) {
                int cy = y + dir[d][0];
                int cx = x + dir[d][1];
                if(cy < 0 || H <= cy || cx < 0 || W <= cx) {
                    continue;
                }
                if(s[cy][cx]) flag = true;
            }
            if(!flag) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int X;
    cin >> X;
    if (X < 100)
    {
        cout << 0 << endl;
        return 0;
    }
    int a = X % 100;
    int fives = a / 5;
    if (a % 5 != 0)
    {
        fives++;
    }
    if (X >= 100 * fives)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int a[n];
    bool chk = 0;
    rep (i, n) {
        cin >> a[i];
        if (a[i] % 2 == 1) chk = 1;
    }
    if (chk) cout << "first\n";
    else
        cout << "second\n";
}

Measured memory_bytes: 640
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	Main(){
		new AOJ1277();
	}
	
	class AOJ1277{
		int N,T,L,B;
		AOJ1277(){
			while(true){
				N=sc.nextInt(); T=sc.nextInt();
				L=sc.nextInt(); B=sc.nextInt();
				if(N==0)	break;
				solve();
			}
		}
		void solve(){
			HashSet<Integer>	lose=new HashSet<Integer>(),
								back=new HashSet<Integer>();
			for(int i=0; i<L; ++i)	lose.add(sc.nextInt());
			for(int i=0; i<B; ++i)	back.add(sc.nextInt());
			
			double[][] dp=new double[N+1][T+2];
			dp[0][0]=1;
			for(int t=0; t<T; ++t){
				for(int a=0; a<N; ++a){
					for(int d=1; d<=6; ++d){
						int pos=(a+d>N? N-((a+d)-N): a+d);
						pos = (back.contains(pos)? 0: pos);
						int offset = (lose.contains(pos)? 1: 0);
						dp[pos][t+1+offset] += dp[a][t]/6;
					}
				}
			}
			double ans=0;
			for(int t=1; t<=T; ++t)	ans+=dp[N][t];
			System.out.printf("%.6f\n", ans);
		}
	}
}

Measured memory_bytes: 26620
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll X;
	cin >> X;

	ll a = 0, b = 0;
	for (a = 0; a * a * a * a * a <= X; ++a) {
		for (b = 0; a * a * a * a * a + b * b * b * b * b <= X; ++b) {
			if (a * a * a * a * a + b * b * b * b * b == X) {
				cout << max(a, b) << " " << -min(a, b) << endl;
				return 0;
			}
		}
	}

	map<ll, ll> prime_count;
	vector<bool> is_prime(X + 1, true);
	is_prime[0] = false;
	is_prime[1] = false;
	{
		ll val = X;
		for (ll p = 2; p <= sqrt(X) + 1; ++p) {
			if (!is_prime[p]) {
				continue;
			}
			while (val % p == 0) {
				val /= p;
				if (prime_count.count(p) == 0) {
					prime_count[p] = 0;
				}
				++prime_count[p];
			}
			for (ll k = 1; k * p <= sqrt(X) + 1; ++k) {
				is_prime[k * p] = false;
			}
		}
		if (val != 1) {
			prime_count[val] = 1;
		}
	}

	ll div_num = 1;
	for (auto iter = prime_count.begin(); iter != prime_count.end(); ++iter) {
		div_num *= iter->second + 1;
	}

	for (ll div_case = 0; div_case < div_num; ++div_case) {
		ll div = 1;
		ll val = div_case;
		for (auto iter = prime_count.begin(); iter != prime_count.end(); ++iter) {
			for (ll i = 0; i < val % (iter->second + 1); ++i) {
				div *= iter->first;
			}
			val /= iter->second + 1;
		}
		for (b = 0;; ++b) {
			a = b + div;
			ll equ_val = a * a * a * a + a * a * a * b + a * a * b * b + a * b * b * b + b * b * b * b;
			if (equ_val == X / div) {
				cout << a << " " << b << endl;
				return 0;
			}
			if (equ_val > X / div) {
				break;
			}
		}
	}

	cout << "Not Found " << endl;

	return 0;
}


Measured memory_bytes: 123412
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    print('ABC' if N <= 999 else 'ABD')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    REP(i,n){
        if (s[i] != '.') continue;
        int l = i - 1, r = i + 1;
        while (l >= 0 && s[l] == 'W') l--;
        while (r < n && s[r] == 'W') r++;
        if (l >= 0 && s[l] == 'B' && r < n && s[r] == 'B') continue;
        l = i - 1, r = i + 1;
        while (l >= 0 && s[l] == 'B') l--;
        while (r < n && s[r] == 'B') r++;
        // cout << i << " " << l << " " << r << endl;
        if (l >= 0 && s[l] == 'W'){
            chmax(ans, i - l - 1);
        }
        if (r < n && s[r] == 'W'){
            chmax(ans, r - i - 1);
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N, M;
    cin >> N >> M;
    cout << ((N == M) ? "Yes" : "No") << endl;

    return 0;
}

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

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

	vector<int> dp(n+2);
	dp[0]=0;
	dp[1]=0;
	dp[2]=abs(x[1]-x[0]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(x[i-1]-x[i-2]) , dp[i-2]+abs(x[i-1]-x[i-3]));
	}
	// for(int i=1;i<=n;i++)
	cout<<dp[n];
	return 0;

}

Measured memory_bytes: 1024
#include<iostream>
#include <stdlib.h>
#include <limits.h>
#include<vector>
#include <climits>
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <random>
using namespace std;
#define pb push_back
#define F first
#define S second
#define um unordered_map<ll, ll>
#define endl '\n'
#define sim template < class c
#define ris return * this
#define ll long long int
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j)
{
    return rge<c> {i, j};
}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
}
eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&)
    {
        ris;
    }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void solve()
{ ll n;
    cin >>n;
    if(n%1000!=0){
    cout<<1000-(n%1000)<<"\n";
    }
    else{
        cout<<"0"<<"\n";
    }
}


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

solve();


return 0;
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
struct UF {
  vector<int> p;
  UF(int n) : p(n, -1) {}
  int r(int x) {
    if (p[x] < 0) return x;
    return p[x] = r(p[x]);
  }
  void m(int x, int y) {
    x = r(x); y = r(y);
    if (x == y) return;
    if (-p[x] > -p[y]) swap(x, y);
    p[y] += p[x];
    p[x] = y;
  }
};

int main() {
  int n, k, l; cin >> n >> k >> l;
  UF a(n), b(n);
  while (k--) {
    int f, t; cin >> f >> t; f--; t--;
    a.m(f, t);
  }
  while (l--) {
    int f, t; cin >> f >> t; f--; t--;
    b.m(f, t);
  }
  map<pair<int, int>, int> m;
  for (int i = 0; i < n; i++) {
    m[{a.r(i), b.r(i)}]++;
  }
  for (int i = 0; i < n; i++) {
    if (i) cout << ' ';
    cout << m[{a.r(i), b.r(i)}];
  }
  cout << endl;
}

Measured memory_bytes: 13568
#include <stdio.h>

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int n;

  scanf ( "%d", &n );

  while ( n-- )
  {
    double x1, x2, x3, x4;
    double y1, y2, y3, y4;

    scanf ( " %lf %lf", &x1, &y1 );
    scanf ( " %lf %lf", &x2, &y2 );
    scanf ( " %lf %lf", &x3, &y3 );
    scanf ( " %lf %lf", &x4, &y4 );

    if ( ( y2 - y1 ) / ( x2 - x1 ) == ( y4 - y3 ) / ( x4 - x3 ) )
    {
      printf ( "YES\n" );
    }
    else
    {
      printf ( "NO\n" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}



int main(void){
   
long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,b,count1=0,a2,b2;
char a[10000];
scanf("%s",a);
for(i=0;i<strlen(a);i++){
    if(a[i]=='R' && (i+1)%2==0){
        printf("No");
        return 0;
    }
    if(a[i]=='L' && (i+1)%2!=0){
        printf("No");
        return 0;
    }
}
printf("Yes");
return 0;
}


Measured memory_bytes: 128
ls = [list(input().split()) for i in range(2)]
#print(ls)
N = int(ls[0][0])
#print(N)
K = int(ls[0][1])
#print(K)
S = ls[1][0]
#print(S)

S0 = S[:K-1]
#print(S0)
S1 = S[K-1:K]
#print(S1)
S2 = S[K:]
#print(S2)

if S1 == 'A' :
    S_New = 'a'
elif S1 == 'B' :
    S_New = 'b'
elif S1 == 'C' :
    S_New = 'c'
print(S0 + S_New + S2)

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

int a[100000];
int main() {
  int n, k;
  cin >> k >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  
  long sum = a[n - 1] - a[0];
  vector<int> v;
  for (int i = 1; i < n; ++i) {
    v.push_back(a[i] - a[i - 1]);
  }
  sort(v.rbegin(), v.rend());
  
  int l = min(k - 1, n - 1);
  for (int i = 0; i < l; ++i) {
    sum -= v[i];
  }
  cout << sum << endl;
}

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

int main(){

  int a,b;
  cin >> a >> b;

  if (a == 1) {
    a = 14;
  }
  if (b == 1) {
    b = 14;
  }

  if (a > b) {
    std::cout << "Alice" << '\n';
  } else if (a < b) {
    std::cout << "Bob" << '\n';
  } else {
    std::cout << "Draw" << '\n';
  }











}


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

int main(){
    string a, b, c;
    cin >> a >> b >> c;

    char p = 'a';
    while(1){
        if(p == 'a' && !a.size()) {
            cout << 'A' << endl;
            return 0;
        } else if(p == 'b' && !b.size()) {
            cout << 'B' << endl;
            return 0;
        } else if(p == 'c' && !c.size()) {
            cout << 'C' << endl;
            return 0;
        }

        if(p == 'a') {
            p = a[0];
            a.erase(0, 1);
        } else if(p == 'b') {
            p = b[0];
            b.erase(0, 1);
        } else if(p == 'c') {
            p = c[0];
            c.erase(0, 1);
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(3*n);
	rep(snip_i, 3*n) cin >> a.at(snip_i);
	sort(a.begin(), a.end());
	int index = n*3-2;
	ll ans = 0;
	while(n>0){
		ans += a.at(index);
		index -= 2;
		n--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long
// #define mod 1000000007
// #define mod 998244353
// #define COMMENT

/*   nCr % mod

const int N = 2000099;
ll fact[N];
ll finv[N];
ll inv[N];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < N;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int k, q, n, x, m;
int D[6666];

int find_answer() {
  int Q = (n-1) / k;
  int R = (n-1) % k;
  int ans = 0;
  int q1 = x/m;
  ll q2 = x;
  for(int i = 0;i < k;i++) {
    if(D[i] % m == 0) {
      ans += Q + (i < R);
    }

    q2 += 1LL*(D[i]%m)*Q + (i < R ? (D[i]%m) : 0);
  }

  q2 /= m;
  return n-1-ans-(q2-q1);
}

int main() {

//  freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> k >> q;
  for(int i = 0;i < k;i++) {
    cin >> D[i];
  }

  while (q--) {
    cin >> n >> x >> m;
    cout << find_answer() << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
string normal = "-";
void stchange(string &a, string b) {
	if (a == normal)a = b;
	else if (a.size() < b.size())a = b;
	else if (a.size() == b.size()) {
		if (a < b)a = b;
	}
}
int match[10] = {0,2,5,5,4,5,6,3,7,6 };
int main() {
	int N, M;
	cin >> N >> M;
	vector<int>A(M);
	for (int i = 0; i < M; ++i)cin >> A[i];
	string dp[11000];
	for (int i = 0; i < 11000; ++i) {
		dp[i] = normal;
	}
	dp[0] = "";
	for (int i = 0; i <= N; ++i) {
		if (dp[i] == normal)continue;
		else {
			for (int j=0; j < M;++j){
				stchange(dp[i + match[A[j]]], dp[i] + (char)('0' + A[j]));
			}
		}
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 43776
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n, r;
  cin >> n >> r;

  if(n >= 10) cout << r << endl;
  else{
    cout << r + 100 * (10 - n) << endl;
  }
  return 0;
}

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

int main()
{
    int k, n;
    char s[1000];

    scanf("%d %s %d", &n, s, &k);

    for(int i=0; i<n; i++)
    {
        if(s[i]!=s[k-1]) printf("*");
        else printf("%c", s[k-1]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  int flag = (A[0]!=0);
  REP(i,N-1){
    if(A[i]+2<=A[i+1]){
      flag=1;
    }
  }
  if(flag==1){
    cout << -1 << endl;
  }else{
    ll ans = 0;
    A.push_back(0);
    REP(i,N){
      if((A[i]>=A[i+1])){
        ans+=A[i];
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 4808
import sys
n, k = map(int, input().split())
if k == 0:
  print(n * n)
  sys.exit()
ans = n * n
for b in range(1, n + 1):
  if b <= k:
    ans -= n
    continue
  ans -= (n + 1) // b * k - 1
  ans -= min((n + 1) % b, k)
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    char r[101];
    while(scanf("%s",r)==1)
    {
        a=strlen(r);
        cout<<r[0]<<a-2<<r[a-1]<<endl;
    }
        return 0;
}




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

int main()
{
	int n;
	int a[100];
	cin.tie(0);
	cin >> n;

	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = n - 1; i >= 0; i--) {
		cout << a[i];
		if (i != 0) cout << " ";
	}
	cout << "\n";
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
class Solve{
    public int[] S;
    public int length;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        if(length != 1){
            int k = 1;
            long count = 0;
            for(int i=0;i < length-1;i++){
                k *= 2;
            }
            for(int i=0;i < k;i++){
                bool[] b = new bool[length-1];
                int l = i;
                long num = S[0];
                for(int j = 0;j < length-1;j++){
                    if(l % 2 == 1){
                        b[j] = true;
                    }
                    else{
                        b[j] = false;
                    }
                    l /= 2;
                }
                for(int j = 0;j < length-1;j++){
                    if(b[j]){
                        count += num;
                        num = S[j+1];
                    }
                    else{
                        num = num*10+S[j+1];
                    }
                    if(j == length-2){
                        count += num;
                    }
                }
            }
            Console.WriteLine(count);
        }
        else{
            Console.WriteLine(S[0]);
        }
    }
    void getinput(){
        string str = Console.ReadLine();
        length = str.Length;
        S = new int[length];
        for(int i=0;i < length;i++){
            S[i] = int.Parse(str[i]+"");
        }
    }    
}

Measured memory_bytes: 2648
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
typedef pair<int,int>P;
int main(void)
{
	int n,m,c;
	int l[100001],i,j,sum,cnt,x,y;
	P pp[100000];
	scanf("%d %d %d",&n,&m,&c);
	for(i=1;i<=c;i++)	scanf("%d",&l[i]);
	for(i=0;i<n;i++)	{
		scanf("%d",&pp[i].second);
		scanf("%d",&pp[i].first);
	}
	sort(pp,pp+n,greater<P>() );
	sum=0;
	cnt=0;
	for(i=0;i<n;i++)	{
		x=pp[i].second;	y=pp[i].first;
		if(l[x]>0)	{
			sum+=y;
			l[x]--;
			cnt++;
			if(cnt==m)	break;
		}
	}
	printf("%d\n",sum);
	return 0;
}


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

int main () {
	long long n, a, b;
	cin >> n >> a >> b;
	long long sum = a + b;
	long long div = n / sum;
	long long ans = a * div;
	long long mult = sum * div;
	if(mult + a <= n) {
		ans += a;
	}else {
		ans += n - mult;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N, A, B = iInM()

ans = min(A * N, B)

print(ans)

Measured memory_bytes: 61988
a, b, c, x = map(int, [input() for i in range(4)])
count = 0

for a_num in range(a+1):
    for b_num in range(b+1):
        for c_num in range(c+1):
            if a_num * 500 + b_num * 100 + c_num * 50 == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
	long n,q;
	long long sum=0;
	cin >>n;
	long count[100002];
	for(int i=0;i<100002;i++){
		count[i]=0;
	}
	for(int i=0;i<n;i++){
		int temp;
		cin >>temp;
		count[temp]++;
		sum+=temp;
	}
	cin >>q;
	long long ans[q];
	for(int i=0;i<q;i++){
		int b,c;
		cin >>b>>c;
		sum=sum-b*count[b]+c*count[b];
		ans[i]=sum;
		count[c]+=count[b];
		count[b]=0;
	}
	for(int i=0;i<q;i++){
		cout <<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
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';
  if (S.at(K-1) == 'B') S.at(K-1) = 'b';
  if (S.at(K-1) == 'C') S.at(K-1) = 'c';
  cout << S <<endl;
 }

Measured memory_bytes: 256