akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long, long>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a, b) get<a>(b)
#define INF (ll)1e18 + 100
#define vl vector<ll>
#define vi vector<int>
#define vll vector<pair<ll, ll>>
#define vii vector<pair<int, int>>
#define all(v) v.begin(),v.end()
#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
   return powM(a, m-2, m);
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].ff=a[i];
        v[i].ss=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].ff;
        b[i]=v[i].ss;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int r;
    cin>>r;cout<<r*r;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m;

int main(){
    while(cin >> n >> m && n){
        ll sa = 0;
        vector<ll> a(n);
        rep(i,n){
            cin >> a[i];
            sa += a[i];
        }
        ll sb = 0;
        vector<ll> b(m);
        rep(i,m){
            cin >> b[i];
            sb += b[i];
        }
        ll sum = INF;
        P ans = P(-1,-1);
        rep(i,n){
            rep(j,m){
                if(sa - a[i] + b[j] == sb - b[j] + a[i]){
                    if(sum > a[i]+b[j]){
                        sum = a[i]+b[j];
                        ans = P(a[i],b[j]);
                    }
                }
            }
        }
        if(ans.first == -1)cout << -1 << endl;
        else cout << ans.first << " " << ans.second << endl;
    }
}


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

int main(){
    string s; cin >> s;
    int q; cin >> q;
    int t;
    int rev=0;
    for(int i=0; i<q; i++){
        int t; cin >> t;
        if(t==1){   
            rev++;
        }else if(t==2){
            int f; cin >> f;
            string c; cin >> c;
            if((f==1 && rev%2==0) || (f==2 && rev%2==1)){
                s.insert(0, c);
            }else if((f==2 && rev%2==0) || (f==1 && rev%2==1)){
                s.append(c);
            }
        }
    }
    if(rev%2==1){
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll ans,dp[2105];
string s;
int main(){
	cin >> s;
	for(int i=0;i<s.size();i++){
		int a[2105]={0};
		a[s[i]-'0']++;
		if(i>0)
			for(int j=0;j<2019;j++)
				a[(j*10+(s[i]-'0'))%2019]+=dp[j];
		ans+=a[0];
		for(int i=0;i<2019;i++)
			dp[i]=a[i];
	}
	cout << ans;	
	return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <math.h>

int main(void){

	int Num, i;
	double X1, Y1, X2, Y2, X3, Y3;
	double Xp, Yp, R;

	scanf("%d",&Num);
	
	for(i = 0; i < Num; i++){
		scanf("%lf %lf %lf %lf %lf %lf", &X1, &Y1, &X2, &Y2, &X3, &Y3);
		R = 2*(X1*(Y2-Y3) + X2*(Y3-Y1) + X3*(Y1-Y2));
		Xp = ((X1*X1 + Y1*Y1)*(Y2-Y3) + (X2*X2 + Y2*Y2)*(Y3-Y1) + (X3*X3 + Y3*Y3)*(Y1-Y2))/R;
		Yp = ((X1*X1 + Y1*Y1)*(X3-X2) + (X2*X2 + Y2*Y2)*(X1-X3) + (X3*X3 + Y3*Y3)*(X2-X1))/R;
		R = hypot(Xp-X1,Yp-Y1);
		printf("%.03lf %.03lf %.03lf\n", Xp, Yp, R);
	}
	
	return 0;
}

Measured memory_bytes: 668
# Reference: https://tjkendev.github.io/procon-library/python/min_cost_flow/primal-dual.html
from heapq import heappush, heappop
class MinCostFlow:
    INF = 10**18

    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap, cost):
        forward = [to, cap, cost, None]
        backward = forward[3] = [fr, 0, -cost, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def flow(self, s, t, f):
        N = self.N; G = self.G
        INF = MinCostFlow.INF

        res = 0
        H = [0]*N
        prv_v = [0]*N
        prv_e = [None]*N

        d0 = [INF]*N
        dist = [INF]*N

        while f:
            dist[:] = d0
            dist[s] = 0
            que = [(0, s)]

            while que:
                c, v = heappop(que)
                if dist[v] < c:
                    continue
                r0 = dist[v] + H[v]
                for e in G[v]:
                    w, cap, cost, _ = e
                    if cap > 0 and r0 + cost - H[w] < dist[w]:
                        dist[w] = r = r0 + cost - H[w]
                        prv_v[w] = v; prv_e[w] = e
                        heappush(que, (r, w))
            if dist[t] == INF:
                return None

            for i in range(N):
                H[i] += dist[i]

            d = f; v = t
            while v != s:
                d = min(d, prv_e[v][1])
                v = prv_v[v]
            f -= d
            res += d * H[t]
            v = t
            while v != s:
                e = prv_e[v]
                e[1] -= d
                e[3][1] += d
                v = prv_v[v]
        return res

###

# source >>> 1~n rows >>> (1,1)~(n,n) squares >>> 1~n columns >>> sink

from sys import stdin
input = stdin.buffer.readline

def main():
    n, k = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(n)]

    mcf = MinCostFlow(n*(n+2) + 2)

    source = n*(n+2)
    sink = n*(n+2) + 1

    # add edges
    #source >>> sink
    mcf.add_edge(source, sink, n*k, 0)

    for i in range(n):
        # source >>> rows
        mcf.add_edge(source, n*n + i, k, 0)
        # columns >>> sink
        mcf.add_edge(n*(n+1) + i, sink, k, 0)

        for j in range(n):
            # rows >>> squares
            mcf.add_edge(n*n + i, n*i + j, 1, -a[i][j])
            # squares >>> columns
            mcf.add_edge(n*i + j, n*(n+1) + j, 1, 0)

    print(-mcf.flow(source, sink, n*k))

    ans = [['.'] * n for _ in range(n)]
    for i in range(n):
        for j in range(n):
            if mcf.G[n*i + j][0][1]:
                ans[i][j] = 'X'

    for row in ans:
        print(''.join(row))

main()

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

using namespace std;


int main(void){
    string S;
    int num_win, num_day;
    std::cin >> S;
    num_win = std::count(S.cbegin(), S.cend(), 'o');
    num_day =  15 - S.length();
    
    if(num_win + num_day < 8)
        std::cout << "NO" << std::endl;
    else
        std::cout << "YES" << std::endl;
    
    return 0;
}


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

int main(void) {
	string S;
	unsigned int pa, pz;

	cin >> S;
	pa = S.find_first_of('A');
	pz = S.find_last_of('Z');

	cout << pz - pa + 1 << '\n';
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

INF = pow(10,5)

def countProcedure(lst,char,cnt=0):
  flags = [x == char for x in lst]
  if all(flags):
    return cnt
  else:
    _lst = [char if lst[i] == char or lst[i+1] == char else lst[i] for i in range(len(lst)-1)]
    return countProcedure(_lst,char,cnt+1)

# @njit
def solve(s):
  s = list(s)
  res = INF
  for char in (chr(ord("a") + i) for i in range(26)):
    res = min(res,countProcedure(s,char))

  return res



def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9100
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
int main(){
    ll a, b;
    cin >>a >> b;
    ll x = gcd(a, b);
    show(x);
    cout << prime_factor(x).size() + 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		if (b - a == c - b) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

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

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int s,w; cin>>s>>w;
  if (s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;

    return 0;
}


Measured memory_bytes: 3628
import sys
from math import ceil
"""
def input():
    return sys.stdin.readline().strip()
"""
def check(k):
    tmp = list(h)
    for i in range(N):
        tmp[i] -= B*k
    
    flag = False
    for i in tmp:
        if i > 0:
            flag = True
            break
    if not flag:
        return True

    lf = 0
    for i in tmp:
        if i > 0:
            lf += ceil(i/(A-B))

    if lf <= k:
        return True
    else:
        return False

N,A,B = map(int,input().split())
h = tuple(int(input()) for _ in range(N))

left = -1
right = 1e9

while abs(left-right) > 1:

    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(int(right))

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
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;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

vvi graph;
int n, m, ans = 0;
void dfs(int visited, int d) {
  if (visited+1 == (1 << n)) {
    ans++;
    return;
  }
  for (auto &nxt : graph[d]) {
    if ((visited >> nxt) & 1) continue;
    dfs(visited+(1<<nxt), nxt);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  std::cin >> n >> m;
  graph.resize(n);
  rep(i, m) {
    int a, b; std::cin >> a >> b;
    --a, --b;
    graph[a].pb(b), graph[b].pb(a);
  }
  int visited = 1;
  dfs(visited, 0);
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
use std::cmp;

fn run(args: &Vec<String>) -> i32 {
    let n: i32 = args[0].parse().unwrap();
    let ai: Vec<i32> = args[1].split(' ').map(|s| s.parse().unwrap()).collect();
    let ave = ai.iter().fold(0, |a, b| a + b) / n;

    let a1 = sum(&ai, ave - 1);
    let a2 = sum(&ai, ave);
    let a3 = sum(&ai, ave + 1);

    cmp::min(cmp::min(a1, a2), a3)
}

fn sum(ai: &Vec<i32>, v: i32) -> i32 {
    ai.into_iter().fold(0, |a, b| a + (b - v) * (b - v))
}

fn main() {
    let stdin = io::stdin();
    let args = stdin.lock().lines().map(|l| l.unwrap()).collect();
    let r = run(&args);
    println!("{}", r);
}


Measured memory_bytes: 380
#include<stdio.h>


int main(){
    int N,i,b[50]={0},k=0;
    scanf("%d",&N);

    int p[N];
    for(i=0;i<N;i++){
        scanf("%d",&p[i]);
    }
    for(i=0;i<N;i++){
        if(p[i]!=i+1){
            b[i]=1;
        }
        if(b[i]==1){
            k++;
        }
    }
    if(k<3){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
  char ans[10],moji[10];
  int i=0,last=0;
  scanf("%s\n",moji);
  while(1){
     if(moji[i]=='B'){
        if (last > 0) last--;
     }
     else if(moji[i]=='0'||moji[i]=='1'){
       ans[last] = moji[i];
       last++;
     }
     else
       break;
    i++;
  }
  for(i=0;i<last;i++)
  	printf("%c",ans[i]);
}

Measured memory_bytes: 128
// ref. https://www.youtube.com/watch?v=ENSOy8u9K9I&feature=youtu.be

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

bool check(const vector<P>& s) {
  int h = 0;
  for (const P& p : s) {
    int b = h+p.first; // proceed to min.
    if (b < 0) { return false; }
    h += p.second;
  }
  return true;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;

  int total = 0;
  vector<P> ls, rs;
  rep(i,n) {
    string s;
    cin >> s;
    int h = 0, b = 0; // h .. sum, b .. min
    for (char c : s) {
      if (c == '(') {
        ++h;
      } else {
        --h;
      }
      chmin(b, h);
    }
    if (h>0) {
      ls.emplace_back(b,h);
    } else {
      rs.emplace_back(b-h,-h); // from right.
    }
    total += h;
  }
  sort(ls.rbegin(), ls.rend()); // decreasing order
  sort(rs.rbegin(), rs.rend()); // decreasing order
  if (check(ls) && check(rs) && total == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 19056
#include <bits/stdc++.h>
int main(){int n,d,x,r;int a[d];std::cin>>n>>d>>x;for(int i=0;i<n;i++)std::cin>>a[i];for(int i=0;i<n;i++){int t=0,l=1;while(t<=d){t=a[i]*(l)+1;l++;r++;}}std::cout << r + x << std::endl;}

Measured memory_bytes: 2304
N,K=map(int,input().split())
S=[0]*(N+1);w=0
P=list(map(int,input().split()))
for i in range(1,N+1):
  S[i-1]=[i,P[i-1]]
S[-1]=[0,1000]
S.sort(key=lambda x: x[1])
#print(S)
for i in range(K):
  w=w+S[i][1]
print(w)

Measured memory_bytes: 9184
n = gets.to_i
a = gets.split.map(&:to_i)
k = a.max

b = []
c = []
0.upto(k).each{|i| c[i] = 0}
0.upto(n-1).each{|j| c[a[j]] += 1}
1.upto(k).each{|i| c[i] = c[i] + c[i-1]}
(n-1).downto(0).each{|j|
  b[c[a[j]]] = a[j]
  c[a[j]] -= 1
}

puts b.select{|x| x != nil}.join(" ")

Measured memory_bytes: 175168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int N=1e5+5;
int main()
{
    ios::sync_with_stdio(false);
    int a,b,k,i,flag=0;
	scanf("%d%d%d",&k,&a,&b); 
    for(i=a;i<=b;i++)
    {
    	if(i%k==0)
    	{
    		flag=1;break;
		}
	}
    if(flag==1) printf("OK\n");
    else printf("NG\n");
    return 0; 
}

Measured memory_bytes: 3696
#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;
int selectionSort(int*a, int n){
    int cnt = 0;
    for(int i=0;i<n;i++){
        int minj = i;
        for(int j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj = j;
            }
        }
        if(i!=minj){
            swap(a[i], a[minj]);
            ++cnt;
        }
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int* a = (int *)calloc(n, sizeof(int));
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    int cnt = selectionSort(a, n);

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


Measured memory_bytes: 3088
#include <iostream>
#include<limits.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
int main() {
int day,manycloth;
cin>>day>>manycloth;
int kion[200];
for(int i = 0;i<day;i++){cin>>kion[i];}
int cloth[200][3];
for(int i = 0;i<manycloth;i++){
	for(int j=0;j<3;j++){
		cin>>cloth[i][j];
	}
}
int dp[201][200];
for(int i = 0;i<201;i++){for(int j= 0;j<200;j++){dp[i][j]=INT_MIN;}}
for(int i=0;i<200;i++){dp[0][i]=0;}
for(int i = 0;i<=day;i++){
	for(int j =0;j<manycloth;j++){
		if(cloth[j][0]>kion[i] or cloth[j][1]<kion[i]){
			dp[i][j]=-1;}
		else{
			if(i!=0){
				for(int h= 0;h<manycloth;h++){
					if(dp[i-1][h]!=-1){
						dp[i][j]=max(dp[i][j],dp[i-1][h]+abs(cloth[h][2]-cloth[j][2]));
					}
				}
			}
		}
	}
}
int ans = INT_MIN;
for(int i =0;i<manycloth;i++){
if(ans<dp[day-1][i]){ans=dp[day-1][i];}
}
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1320
from itertools import product
from collections import Counter
def main():
    N,*D=map(int, open(0).read().split())
    C=Counter(D)
    ans=min(D)
    for i in range(1,12):
        if i in C and C[i]>=3:
            ans=0
    if 12 in C and C[12]>=2:
        ans=0
    if ans:
        X1=[k for k,v in C.items() if v==1]
        X2=[k for k,v in C.items() if v==2]
        Y=[False]*24
        for x in X2:
            Y[x]=Y[-x]=True
        res=0
        for p in product((True, False), repeat=len(X1)):
            Z=Y.copy()
            for t,x in zip(p,X1):
                if t:
                    Z[x]=True
                else:
                    Z[-x]=True
            res2=12
            I=[i for i,p in enumerate(Z) if p]
            for i in I:
                for j in I:
                    if i==j: continue
                    res2=min(res2,abs(i-j))
            res=max(res,res2)
        ans=min(ans,res)
    print(ans)

if __name__ == "__main__":
    main()

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

int main() {
  int N;
  int work=0;
  int count=0;
  cin >> N;
  work = N;
  int point = 10000000;
  for (int i = 0; i < 8; i++){
    count += work / point;
    work -= (work / point) * point;
    point /= 10;
  }
  if ( !(N % count) ){
     cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

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

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}
use std::collections::HashSet;
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.input();
    let m: usize = sc.input();

    if n % 2 == 1 {
        for i in 0..m {
            println!("{} {}", n - i, i + 1);
        }
    } else {
        for i in 0..m {
            if i % 2 == 0 {
                println!("{} {}", n - i / 2, i / 2 + 1);
            } else {
                println!("{} {}", n / 2 + i / 2 + 2, n / 2 - i / 2);
            }
        }
    }
}


Measured memory_bytes: 2144
import math


def main():
    N = int(input())
    sqrt = int(math.sqrt(N))
    ans = [0] * (N+1)
    for x in range(1, sqrt+1):
        for y in range(1, sqrt+1):
            for z in range(1, sqrt+1):
                tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if tmp <= N:
                    ans[tmp] += 1
    for i in range(1, N+1):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 91324
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n;
int MAX = 100000;

int powi(int x, int y){
	int r = 1;
	for(int i = 1; i <= y; i++){r *= x;}
	return r;
}

int calc(int x, int y){
	if(x > MAX){return MAX;}
	int r = 0;
	for(int d = y; d >= 0; d--){
		r += x/powi(y, d);
		x %= powi(y, d);
	}
	return r;
}

int main(){
	cin >> n;
	
	int ans = MAX;
	for(int i = 0; i <= n; i++){
		ans = min(calc(i, 6)+calc(n-i, 9), ans);
	}
	
	cout << ans << endl;
	return 0;
}

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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

Node * find(Node *u, int k){
    while (u!=NIL && k!=u->key){
        if (k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}

void insert(int k){
    Node *y =NIL;
    Node *x=root;
    Node *z;
    
    z=(Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        } else {
            x=x->right;
        }
        }
        z->parent=y;
        if(y==NIL){
            root = z;
        } else {
            if(z->key < y->key){
                y->left = z;
            } else {
                y -> right = z;
            }
        }
    }
    
    void inorder(Node *u){
        if(u==NIL) return;
        inorder(u->left);
        printf(" %d", u->key);
        inorder(u->right);
    }
    void preorder(Node *u){
        if(u==NIL)return;
        printf(" %d", u->key);
        preorder(u->left);
        preorder(u->right);
    }
    
    int main(){
        int n, i, x;
        string com;
        
        scanf("%d", &n);
        
        for (i=0; i<n; i++){
            cin >> com;
            if (com[0]=='f'){
                scanf("%d",&x);
                Node *t = find(root, x);
                if(t!=NIL)printf("yes\n");
                else printf("no\n");
               }else if (com == "insert"){
                scanf("%d", &x);
                insert(x);
            }else if(com=="print"){
                inorder(root);
                printf("\n");
                preorder(root);
                printf("\n");
            }
        }
        return 0;
    }



Measured memory_bytes: 21940
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define rep(i,j) for(int  i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
class s_data{
    public:
    int id;
    int score;
    s_data(){}
    s_data(int _id,int _score){
        id = _id;
        score = _score;
    }
    bool operator<(const s_data &a)const{
        if(a.score == score)return id > a.id;
        return score<a.score;
    }
};
class Seg{
    public:
    int size;
    vector < s_data > dat;
    void init(int _k){
        int k = 1;
        while(k < _k)k*=2;
        dat = vector<s_data>(2*k-1,s_data(INF,0));
        size = k;
    }
    void update(s_data q){
        int index = q.id;
        index += size - 1;
        dat[index].score += q.score;
        dat[index].id = q.id;
        while(index > 0){
            index = (index-1)/2;
            dat[index] = max(dat[index*2+1],dat[index*2+2]);
        }
    }
};
s_data cam[100001];
int main(){
    int N,R,L;
    scanf("%d%d%d",&N,&R,&L);
    Seg seg;
    seg.init(N);
    rep(i,N){
        seg.update(s_data(i,0));
    }

    int bef = 0;
    int mid = 0;
    rep(i,R){
        int d,t,x;
        scanf("%d%d%d",&d,&t,&x);
        d--;
        seg.update(s_data(d,x));
        cam[mid].id = mid;
        cam[mid].score += (t-bef);
        mid = seg.dat[0].id;
        bef = t;
    }
    cam[mid].id = mid;
    cam[mid].score += L-bef;
    s_data ans = s_data(INF,-INF);
    rep(i,N){
        ans = max(ans,cam[i]);
    }
    printf("%d\n",ans.id+1);
    return 0;
}

Measured memory_bytes: 5224
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		String s;
		// 判定
		if((a*b) % 2 == 0){
			s = "Even";
		}else{
			s = "Odd";
		}
		//出力
		Console.WriteLine(s);
	}
}


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

int main() {
	int a, b, c, d, e, f, g;
	char s[100], t[100], u[100], v[100];

	scanf("%d %d %d", &a, &b, &c);
	if ((a == 5 && b == 5 && c == 7) || (a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5)) {
		printf("YES");
	}
	else
		printf("NO");

	printf("\n");
	return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c) cout << 1 << endl;
  else if(a != b && b !=  c && c != a) cout << 3 << endl;
  else cout << 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define bs binary_search
#define pi 3.1415926535
#define pob pop_back
const ll MAX=INT_MAX;
const ll MIN=INT_MIN;
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define memo(a,b) memset(a,b,sizeof(a))
#define loopr(i,s,n) for(ll i=s;i>=n;i--)
#define I first
#define II second
#define mp make_pair
#define mt make_tuple
//for(int x:v ){cout<<x;}
int main()
{	ios::sync_with_stdio(0);
/*freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
cin.tie(NULL);cout.tie(NULL);
	ll x,y,i;
 	cin>>x>>y;
 	if(y%2!=0 || 4*x<y)
    {
    	cout<<"No"<<endl;
      return 0;
    }
 else
 {
 loop(i,0,x+1)
 {
 	if(i+2*(x-i)==y/2 || (x-i)+2*i==y/2)
    {
    cout<<"Yes"<<endl;
      return 0;
    }
 }
   cout<<"No"<<endl;
 }
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
 
using namespace std;
 
int main()
{
  int N;
  cin>>N;
  
  int a=N%10;
  if(a==3){
    cout<<"bon"<<endl;
  }
  else if(a==0||a==1||a==6||a==8){
    cout <<"pon"<<endl;
  }
  else{
    cout <<"hon"<<endl;
  }
  
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	if(s == "AKIHABARA" || s == "KIHABARA" || s == "AKIHBARA" || s == "KIHBARA" || s == "AKIHABRA" || s == "KIHABRA" || s == "AKIHBRA" || s == "KIHBRA" || s == "AKIHABAR" || s == "KIHABAR" || s == "AKIHBAR" || s == "KIHBAR" || s == "AKIHABR" || s == "KIHABR" || s == "AKIHBR" || s == "KIHBR"){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

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

int main(int argc, char const *argv[])
{
    int a1,a2,a3,s;
    cin >> a1 >> a2 >> a3;
    if (a1>a2)
    {
        s = a2;
        a2 = a1;
        a1 = s;
    }
    if (a2>a3)
    {
        s = a3;
        a3 = a2;
        a2 = s;
    }
    if (a1>a2)
    {
        s = a2;
        a2 = a1;
        a1 = s;
    }

    cout << a1 << " " << a2 << " " << a3 << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

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

int main(void) {
  ll r, d, x_2000;
  cin >> r >> d >> x_2000;

  ll x = x_2000;
  rep(i,10){
    x = r*x-d;
    prt(x);
  }
}


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

using namespace std;

constexpr long long mod = 1000000007;

constexpr double eps = 0.00001;

int n;
double p[300][2];

inline double dist2(double x1, double y1, double x2, double y2) {
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

int cnt_c(double x, double y) {
    int ret = 0;
    for (int i = 0; i < n; i++) {
        if (dist2(x, y, p[i][0], p[i][1]) < (1.0 + eps) * (1.0 + eps)) ret++;
    }
    return ret;
}

int main() {
    while (1) {
        scanf("%d", &n);
        if (n == 0) return 0;
        int r = 1;
        for (int i = 0; i < n; i++) {
            scanf("%lf %lf", &p[i][0], &p[i][1]);
        }
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++) {
                if (dist2(p[i][0], p[i][1], p[j][0], p[j][1]) > (2 + eps) * (2 + eps)) continue;
                double ok, ng, dr;
                ok = dr = atan2(p[j][1] - p[i][1], p[j][0] - p[i][0]);
                ng = ok + M_PI;
                while (abs(ok - ng) > eps / 1000) {
                    double m = (ok + ng) / 2;
                    if (dist2(p[i][0] + cos(m), p[i][1] + sin(m), p[j][0], p[j][1]) <= 1)
                        ok = m;
                    else ng = m;
                }
                double is = (ok + ng) / 2;
                r = max(r, cnt_c(p[i][0] + cos(is), p[i][1] + sin(is)));
                r = max(r, cnt_c(p[i][0] + cos(dr * 2 - is), p[i][1] + sin(dr * 2 - is)));
            }
        cout << r << endl;
    }
}


Measured memory_bytes: 3644
#include <numeric>
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;

#define _(x) {cout << #x << " = " << x << " ";}
#define fast ios::sync_with_stdio(false);cin.tie(NULL)

#define fi first 
#define se second 
#define mp make_pair
#define pb push_back

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define clr(v,d) memset(v,d,sizeof(v))
#define sz(v) ((int)((v).size()))

const int MAXN = 1e5 + 10;
ll n,m,j,k,s,t,e,q,l,r,d,cou=0,i;
int a[100][100];
int main()
{   
    
    fast;
    cin>>l>>r;
    if(l/2019<r/2019)
            cout<<0;
    else
    {
        ll ans = INT_MAX;
        rep(i,l,r+1)
        {
            rep(j,i+1,r+1)
            {
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg
#define newl cout<<"\n"
using namespace std;
typedef long long ll;
ll N,M;
ll x[NMAX];
ll d[NMAX];
int main(){
  scan(N);scan(M);
  rep(i,M)scan(x[i]);
  sort(x,x+M);
  rep(i,M-1) d[i]=x[i+1]-x[i];
  sort(d,d+M-1);
  ll res=0;
  if(M-N>0){
    rep(i,M-N)res+=d[i];
  }
  prin(res);newl;
  
  return 0;
}


Measured memory_bytes: 1792
n,k=map(int, input().split())
r, s, p=map(int, input().split())
t = input()

#print(t)

m={'r':'R','s':'S','p':'P'}
rot = {'R':'p','S':'r','P':'s'}
ans = t.translate(str.maketrans(m))
ans = ans.translate(str.maketrans(rot))
#print(ans)

#print('#####################')
val = 0
for i in range(k):
    #print(ans[i::k])#.replace('pp','pX').replace('ss','sX').replace('rr','rX'))
    tmp = (ans[i::k].replace('pp','pX').replace('ss','sX').replace('rr','rX'))
    val += tmp.count('r')*r + tmp.count('s')*s + tmp.count('p')*p


#result = ans.count('r')*r + ans.count('s')*s + ans.count('p')*p
#print('####################')
print(val)

Measured memory_bytes: 3832
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (n, k): (usize, usize),
    };

    let mut v = vec![0; n + 1];

    for _ in 0..k {
        input! {
            d: usize,
            aa: [usize; d]
        };

        for a in aa {
            v[a] += 1;
        }
    }

    let mut ans = 0;
    for i in 1..=n {
        if v[i] == 0 {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2164
package main

import "fmt"

func main() {
    var x, y int

    for {
        fmt.Scanf("%d %d", &x, &y)
        if x == 0 && y == 0 {
            break
        }

        if x < y {
            fmt.Printf("%d %d\n", x, y)
        } else {
            fmt.Printf("%d %d\n", y, x)
        }
    }
}


Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeu(int n){
		if(n<10)
			putchar(n+'0');
		else{
			writeu(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		int n=readu();
		int sum=0;
		while(n){
			sum+=n%10;
			n/=10;
		}
		writeu(sum==1? 10: sum);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	string S;
	cin >> S;
	if (S == "RRR") {
		cout << 3 << endl;
	}
	else if (S == "RRS" || S == "SRR") {
		cout << 2 << enld;
	}
	else if (S == "SSS") {
		cout << 0 << enld;
	}
	else {
		cout << 1 << enld;
	}
}

Measured memory_bytes: 3620
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
N = int(input())
a = readints()
ans = [0]*(N+1)
for i in range(len(a)):
    ans[(a[i])] += 1
for i in range(len(ans)-1):
    print(ans[i+1])


Measured memory_bytes: 92848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,y; cin >> x >> y;
    int ans = 0;
    if(x<=3) ans += (4-x)*100000;
    if(y<=3) ans += (4-y)*100000;
    if(x==1 && y==1) ans += 400000;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

ll dp[1000][100000];

ll knapsack(ll weight[], ll val[], ll n, ll w ){

	if(n==0||w==0){

		return 0;
	}

	if(weight[n-1]>w)
		return knapsack(weight, val, n-1, w);

	if(dp[n][w]!=-1)
		return dp[n][w];
	dp[n][w] = max(val[n-1]+knapsack(weight, val, n-1, w-weight[n-1]), knapsack(weight, val, n-1, w));
	return dp[n][w];


}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
memset(dp, -1, sizeof(dp));

ll n, w;
cin >> n >> w;

ll weight[n], val[n];

for(ll i=0; i<n; i++){
	ll a, b;
	cin >> a >> b;
	weight[i]=a;
	val[i]=b;
}

cout << knapsack(weight, val, n, w );


return 0;
}



Measured memory_bytes: 781568
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define ll long long
#define MOD_P 1000000007
using namespace std;

int main()
{
	string str;
	vector<char> v;
	int q;
	int mode, type;
	int rev = 1;
	char c;

	cin >> str;

	int len = str.size();
	for (int i = 0; i < len; i++) {
		v.emplace_back(str[i]);
	}

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> mode;
		if (mode == 1) {
			rev *= -1;
		} else {
			cin >> type;
			cin >> c;
			type = type * 2 - 3;
			if (rev * type > 0) {
				v.emplace_back(c);
			} else {
				v.insert(v.begin(), c);
			}
		}
	}

	len = v.size();

	if (rev == -1) {
		reverse(v.begin(), v.end());
	}

	for (int i = 0; i < len; i++) {
		printf("%c", v[i]);
	}

	return 0;
}

Measured memory_bytes: 1148
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)n; ++i)

int partition(vector<int> &A, int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for(int j = p; j < r; ++j) {
		if(A[j] <= x) {
			++i;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

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

	int n;
	cin >> n;
	vector<int> A(n);
	REP(i, n) cin >> A[i];

	int p = partition(A, 0, n - 1);
	REP(i, n) {
		if(i == p) cout << '[' << A[i] << ']';
		else cout << A[i];
		(i != n - 1)? cout << ' ' : cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1532
from operator import itemgetter
def resolve():
    N, C = list(map(int, input().split()))
    STC = sorted([list(map(int, input().split())) for _ in range(N)], key=itemgetter(2, 0))
    
    counts = [0]*(10**5+1)
    prevt, prevc = -1, -1
    for stc in STC:
        s, t, c = stc
        if prevt == s and prevc == c:
            counts[s] += 1
        else:
            counts[s - 1] += 1
        counts[t] -= 1
        prevt, prevc = t, c
    for i in range(1, 10**5+1):
        counts[i] += counts[i-1]
    #print(counts[:15])
    print(max(counts))


if '__main__' == __name__:
    resolve()

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

void solve()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= 13)
        ans = b;
    else if (a >= 6)
        ans = b / 2;
    else
        ans = 0;
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3496
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n, m;
  map<int, int> mp1;
  map<int, int> mp2;
  
  cin >> n;
  rep(i, n) {
    int t; cin >> t;
    mp1[t]++;
  }

  cin >> m;
  rep(i, m) {
    int t; cin >> t;
    mp2[t]++;
  }

  for (auto it = mp2.begin(); it != mp2.end(); it++) {
    int f = it->first;
    int s = it->second;
    if (mp1[f] < s) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a;
    cin>>a;
    map<string,int>mp;
    for(int i=0;i<a;i++)
    {
        string s;
        cin>>s;
        mp[s]=i;
    }
    cout<<mp.size()<<endl;

    return 0;
}


Measured memory_bytes: 19176