akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

int main() {
	
	string S;
	int count = 0;

	cin >> S;

	for (int i = 0; i < S.size(); i++) {

		if (S[i] == '1')count++;

	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int x;
    cin>>x;
    if(x<100){
        cout<<0<<endl;
    }else{
        if(x>=2000){
            cout<<1<<endl;
        }else{
            int a=100,b=105,ans=0;
            for(i=1;i<=19;i++){
                if(x>=a*i&&x<=b*i)ans=1;
            }
            cout<<ans<<endl;
        }
    }
}

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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}

int main()
{
    stringstream ss;
    // 入力
    int A[4];
    cin>>A[1]>>A[2]>>A[3];
    int A12=abs(A[1]-A[2]);
    int A13=abs(A[1]-A[3]);
    int A23=abs(A[2]-A[3]);
    int ans=A12+A13;
    if(ans>A12+A23)ans=A12+A23;
    if(ans>A13+A23)ans=A13+A23;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int popcnt(int x) {
	int ret = 0;
	for(int i = 0; i < 17; i++) ret += (x >> i) & 1;
	return ret;
}

void build(int mask, int A, int B, int mask_val, int l, int r, vector<int> & ans) {
	if(l+1 == r) { // A == B
		ans[l] = mask_val;
		return;
	}
	int dif = A ^ B, c = (l + r) / 2;
	for(int i = 0; i < 17; i++) if((dif >> i) & 1) {
		if(mask == (1<<i)) {
			build(0, 0, 0, A | mask_val, l, c, ans);
			build(0, 0, 0, B | mask_val, c, r, ans);
			break;
		}
		for(int j = 0; j < 17; j++) if(j != i) if((mask >> j) & 1) {
			int C = (A - (A & (1<<i))) ^ (1<<j);
			build(mask - (1<<i), A - (A & (1<<i)), C, mask_val | (A & (1<<i)), l, c, ans);
			build(mask - (1<<i), C, B - (B & (1<<i)), mask_val | (B & (1<<i)), c, r, ans);
			break;
		}
		break;
	}
}

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, A, B;
	cin >> N >> A >> B;
	if(popcnt(A^B) % 2 == 0) {
		cout << "NO\n";
		return 0;
	}
	vector<int> ans(1<<N);
	build((1<<N)-1, A, B, 0, 0, 1<<N, ans);
	cout << "YES\n";
	for(int i = 0; i < (1<<N); i++) cout << ans[i] << ((i == (1<<N)-1) ? "\n" : " ");
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 1536
/*2.3 hightierra*/
#include <stdio.h>
#include <math.h>

int main(void){
  int N,K; //変数の定義
  scanf("%d %d",&N,&K); //入力
  
  int i = 0; //カウンターを定義
  
  /*K^(i-1)<=N<K^iのとき、NはK進法でi桁*/
  while(pow((double)K,(double)i)<=N){
    i++;
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
    char s[11];
    scanf("%s", s);
    if(s[5] == '0' && (s[6] == '1' || s[6] == '2' ||s[6] == '3' || s[6] == '4')) {
        printf("Heisei");
    } else printf("TBD");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    if ((B-A)%2==0) cout << (B-A)/2 << endl;
    else {
        auto m = min(abs(N-B),B-1);
        auto m2 = min(abs(N-A),A-1);
        // 壁最短コストを出す
        auto wall_min = min(m,m2);
        // どっちかが壁まで移動
        auto ans = wall_min;
        // 距離を出しとく
        auto last = B-A;
        // 壁側がいったん無駄な行動を取る
        ans++;
        last--;
        // 隣接してた場合これで終わり
        if (last==0) {
            cout << ans << endl;
            return 0;
        }
        // まだ距離がある場合
        cout << ans+(last/2) << endl;


    }
    return 0;
}


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

#define REP(i, s, e) for(int i = (int)s; i < (int) e; i++)
#define rep(i, n) REP(i, 0 ,n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

typedef long long ll;


struct SCC{//O(V+E)
    static const int MAX_V = 1010;
    int V;
    vector<int> G[MAX_V], rG[MAX_V];
    vector<int> vs;
    bool used[MAX_V];
    int cmp[MAX_V];
    vector<vector<int> > res;
 
 
    SCC(int v) : V(v){};
    void add_edge(int from, int to){
        G[from].push_back(to);
        rG[to].push_back(from);
    }
 
    void dfs(int v){
        used[v] = true;
        for(int i = 0; i < G[v].size(); i++){
            if(!used[G[v][i]]) dfs(G[v][i]);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k){
        used[v] = true;
        cmp[v] = k;
        for(int i = 0; i < rG[v].size(); i++){
            if(!used[rG[v][i]]) rdfs(rG[v][i], k);
        }
    }
 
    int scc(){
        memset(used, 0, sizeof(used));
        vs.clear();
        for(int v = 0; v < V; v++){
            if(!used[v]) dfs(v);
        }
        memset(used, 0, sizeof(used));
        int k = 0;
        for(int i = vs.size() - 1; i >= 0; i--){
            if(!used[vs[i]]) rdfs(vs[i], k++);
        }
 
        res.clear();
        res.resize(k);
        for(int i = 0; i < V; i++){
            res[cmp[i]].push_back(i);
        }
        return k;
    }
};

int main(){
    int n;
    cin>>n;
    SCC scc(250);
    int a, b;
    string s;
    rep(i, n){
        cin>>a>>s>>b;
        if(s == "lock") scc.add_edge(b + 110, a);
        else scc.add_edge(a, b + 110);
    }
    bool f = false;
    scc.scc();
    rep(i, scc.res.size()) f |= (scc.res[i].size()>1);
    if(f) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 3304
import sys

n, *xyh = map(int, sys.stdin.read().split())
xyh = list(zip(*[iter(xyh)] * 3))

def conflict(cx, cy, ch, x, y, h):
    return h != max(ch - abs(x - cx) - abs(y - cy), 0)

def main():
    for x, y, h in xyh:
        if h >= 1:
            xt, yt, ht = x, y, h
            break
    
    for cx in range(101):
        for cy in range(101):
            ch = ht + abs(cx - xt) + abs(cy - yt)
            for x, y, h in xyh:
                if conflict(cx, cy, ch, x, y, h):
                    break
            else:
                return cx, cy, ch

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Measured memory_bytes: 3064
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
X = make_divisors(N)
if len(X) % 2:
    i = X[int((len(X)-1)/2)]
    j = X[int((len(X)-1)/2)]
else:
    i = X[int((len(X))/2)]
    j = X[int((len(X))/2-1)]    

print((i-1)+(j-1))

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,h,m;
  long double pi = 3.14159265358979323846;
  cin >> a >> b >> h >> m;
  long double radian = (((long double) h / 12 + ((long double) m / 60)/12) - ((long double) m / 60)) * 2*pi;

  long double ans = (long double)(a*a + b*b) - (long double)(2*a*b)*cosl(radian);
  printf("%.20Lf\n",sqrt(ans));
}


Measured memory_bytes: 4148
s0_r = list(input())[::-1]
t_r = list(input())[::-1]

for k in range(len(s0_r)-len(t_r)+1):
    for i in range(len(t_r)):
        if s0_r[k+i] != t_r[i] and s0_r[k+i] != "?":
            break
    else:
        for i in range(len(t_r)):
            s0_r[k+i] = t_r[i]
            s0 = s0_r[::-1]
        for k in range(len(s0)):
            if s0[k] == "?":
                s0[k] = "a"
        print(''.join(s0))
        break
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
use std::fmt::Debug;
use std::str::FromStr;

pub struct TokenReader {
    reader: std::io::Stdin,
    tokens: Vec<String>,
    index: usize,
}

impl TokenReader {
    pub fn new() -> Self {
        Self {
            reader: std::io::stdin(),
            tokens: Vec::new(),
            index: 0,
        }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index += 1;
        self.tokens[self.index - 1].parse().unwrap()
    }

    pub fn vector<T>(&mut self) -> Vec<T>
    where
        T: FromStr,
        T::Err: Debug,
    {
        if self.index >= self.tokens.len() {
            self.load_next_line();
        }
        self.index = self.tokens.len();
        self.tokens.iter().map(|tok| tok.parse().unwrap()).collect()
    }

    pub fn load_next_line(&mut self) {
        let mut line = String::new();
        self.reader.read_line(&mut line).unwrap();

        self.tokens = line
            .split_whitespace()
            .map(String::from)
            .collect();
        self.index = 0;
    }
}

fn divisors(mut n: i64) -> i64 {
    let mut div = 1;
    let mut fac = 2;

    while fac * fac <= n {
        let mut pow = 0;
        while n % fac == 0 {
            n /= fac;
            pow += 1;
        }

        div *= pow + 1;
        fac += 1;
    }
    if n > 1 {
        div *= 2;
    }

    div
}

fn solve(n: i64) -> i64 {
    let mut res = 0;
    for i in 1..n {
        res += divisors(n - i);
    }
    res
}

fn main() {
    let mut reader = TokenReader::new();
    let n = reader.next();

    let res = solve(n);
    println!("{}", res);
}


Measured memory_bytes: 2144
#include<iostream>
#include <climits>
#include <cstdint>
#include<cmath>
#include<algorithm>

#define ll long long

using namespace std;

struct Item{
  int w,v;
};

ll solve(Item arr[],int n,int w){
    ll dp[n+1][w+1];
    
    for(int wx = 0;wx <= w;wx++){
      dp[1][wx] = 0;
    }
    dp[1][arr[1].w] = arr[1].v;

    for(int i = 2;i<=n;i++){
      for(int j = 0;j<=w;j++){
        dp[i][j] = dp[i-1][j];
        if(arr[i].w > j){
          continue;
        }
        dp[i][j] = max(dp[i][j],arr[i].v + dp[i-1][j-arr[i].w]);
      }
    }

    return *max_element(dp[n],dp[n]+w+1);
}

int main(){
  int n,w;
  cin >> n >> w;
  Item arr[n+1];
  for(int i =1;i<=n;i++)
    cin >> arr[i].w >> arr[i].v;
  cout << solve(arr,n,w) << endl;
}


Measured memory_bytes: 78336
#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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    printf("%.12f %d\n", W * H / 2.0, (W == x * 2) && (H == y * 2));
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC107_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var n = input[0];
            var k = input[1];

            var nums = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var list = new List<long>();

            for(var i = 0;i <= n - k;i++){
                //left to right
                list.Add(Math.Abs(nums[i]) + Math.Abs(nums[i + k - 1] - nums[i]));
                // right to left
                list.Add(Math.Abs(nums[i + k - 1]) + Math.Abs(nums[i + k - 1] - nums[i]));
            }
            Console.WriteLine(list.Min());
        }
    }
}


Measured memory_bytes: 24544
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
int n, m;
int dp1[5001][5001];
int dp[5001][5001], two[5001];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	string s; cin >> s; m = s.size();
	
	dp1[0][0] = 1;
	rep(i, 5000) rep(j, 5001){
		
		if(j < 5000) (dp1[i + 1][j + 1] += 2ll * dp1[i][j] % mod) %= mod;
		(dp1[i + 1][max(0, j - 1)] += dp1[i][j]) %= mod;
	}
	
	dp[0][0] = 1;
	rep(i, 5000) rep(j, 5001){
		
		if(j < 5000) (dp[i + 1][j + 1] += dp[i][j]) %= mod;
		if(j > 1) (dp[i + 1][j - 1] += dp[i][j]) %= mod;
	}
	
	two[0] = 1;
	rep(i, 5000) two[i + 1] = two[i] * 2 % mod;
	
	ll ans = 0;
	rep(i, n+1){
		//i回押したとき最後に0になった
		//残りn - i回で長さmをつくる
		if(n - i - m >= 0) ans += (ll)two[(n - i - m) / 2] * dp[n - i][m] % mod * dp1[i][0] % mod;
		/*
		dbg(i, two[(n - i - m) / 2], dp[n - i][m], dp1[i][0]);
		dbg(two[(n - i - m) / 2] * dp[n - i][m] % mod * dp1[i][0] % mod);
		*/
	}
	cout << ans % mod << endl;
	
	return 0;
}

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

int main() {
    int32_t n;
    cin >> n;
    int32_t a[n];
    int32_t b[n];
    for (int32_t i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n);

    int32_t l = b[n / 2 - 1];
    int32_t r = b[n / 2];

    for (int32_t i = 0; i < n; i++) {
        if (a[i] <= l) {
            cout << r << endl;
        } else if (a[i] >= r) {
            cout << l << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
int main() {
	int k;
	int s;
	int cnt = 0;
	cin >> k;
	cin >> s;
	for (int i = 0; i < k+1; i++) {
		for (int j = 0; j < k+1; j++) {
			if (i + j > s)break;
			if (i + j + k >= s) {
				cnt++;
			}
		}
	}
	cout << cnt;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
b = deque([a[0]])
for i in range(1, n):
    if i % 2 == 1:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    print(* list(b))
else:
    print(* list(b)[::-1])

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

using namespace std;

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

using ll = long long;

ll ps[51];
ll hs[51];

ll h(int n) {
  if (n == 0) return (hs[0] = 1);
  return (hs[n] = (2 * h(n - 1) + 1) + 2);
}

ll p(int n) {
  if (n == 0) return (ps[0] = 1);
  return (ps[n] = (2 * p(n - 1) + 1));
}

void init() {
  h(50);
  p(50);
}

ll calc(int n, ll k) {
  if (n == 0) {
    if (k == 1) return 1;
    return 0;
  }
  if (hs[n] <= k) return ps[n];

  ll s = hs[n-1];
  if (k <= s + 1) {
    return calc(n - 1, k - 1);
  } else if (k == s + 2) {
    return ps[n-1] + 1;
  } else if (s + 2 < k) {
    return ps[n-1] + 1 + calc(n - 1, k - s - 2);
  } else {
    cout << k << ' ' << s << endl;
    assert(false); // bug?
  }
}

int main() {
  int N;
  ll K;

  init();
  cin >> N >> K;
  cout << calc(N,K) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<list>
#include<vector>
using namespace std;
static const int MAX=100000;
vector<int> G[MAX];
int N;
list<int>out;
bool V[MAX];
void dfs(int u)
{
    V[u]=true;
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        if(!V[v]) dfs(v);
    }
    out.push_front(u);
}
int main()
{
    int s,t,M;
    scanf("%d %d",&N,&M);
    for(int i=0;i<N;i++)
        V[i]=false;
    for(int i=0;i<M;i++)
    {
        scanf("%d %d",&s,&t);
        G[s].push_back(t);
    }
    for(int i=0;i<N;i++)
    {
        if(!V[i]) dfs(i);
    }
    for(list<int>::iterator it = out.begin();it!=out.end();it++)
        cout<< *it<<endl;
    return 0;
}



Measured memory_bytes: 6188
n, m = map(int, input().split())
data = [0] * m
res = [0] * m
for i in range(m):
    d = list(map(int, input().split()))
    d.append(i)
    data[i] = tuple(d)
data.sort()
city_num = data[0][0]
birth_num = 1
# print(data)
for item in data:
    # print(item, city_num)
    if item[0] != city_num:
        city_num = item[0]
        birth_num = 1
    res[item[2]] = '{:06d}{:06d}'.format(item[0], birth_num)
    birth_num += 1
for item in res:
    print(item)


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

int main() {
  int K;
  cin>>K;
  if(K==1){
   cout << "ACL" << endl; 
  }
  if(K==2){
   cout << "ACLACL" << endl; 
  }
  if(K==3){
   cout << "ACLACLACL" << endl; 
  }
  if(K==4){
   cout << "ACLACLACLACL" << endl; 
  }
  if(K==5){
   cout << "ACLACLACLACLACL" << endl; 
  }
  
  
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;

  int a=stoi(s);
  int x=a/1000;
  int y=(a%1000)/100;
  int z=(a%100)/10;
  int w=(a%10);

  int b=x*10+y,c=z*10+w;

if(b<13 && c<13 && b!=0 && c!=0) cout << "AMBIGUOUS" << endl;
else if(b<13 && b!=0) cout << "MMYY" << endl;
else if(c<13 && c!=0) cout << "YYMM" << endl;
else cout << "NA" << endl;

 return 0;
}


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

int main(){
    int n,m,a[100005];
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<m;i++)
    {
        sum+=a[i];
    }
    if(sum<=n)
        cout<<n-sum;
    else cout<<"-1";
    return 0;
}

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int y, m, d;
        cin >> y >> m >> d;
        d = 20-d+1;
        int cnt = 0;
        for(int j=y; j<1000; j++){
            for(int k=m; k<=10; k++){
                if(j%3==0){
                    cnt += d;
                }
                else {
                    if(k%2==0){
                        cnt += d-1;
                    } else {
                        cnt += d;
                    }
                }
                d = 20;
            }
            m = 1;
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>

int main()
{
    int a,b,c,d,e;
    std::cin >> a >> b >> c >> d >> e;
    
    if (a==0)
    {
        std::cout << 1 << std::endl;
    }
    
    if (b==0)
    {
        std::cout << 2 << std::endl;
    }
      
    if (c==0)
    {
        std::cout << 3 << std::endl;
    }

    if (d==0)
    {
        std::cout << 4 << std::endl;
    }

    if (e==0)
    {
        std::cout << 5 << std::endl;
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
int n;
struct node{
	double x;
	friend bool operator < (node A,node B){
		return A.x>B.x;
	}
};
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
void write(int x){
    if(x<0){x=-x;putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
signed main(){
	priority_queue<node> q;
	n=read();
	for(int i=1;i<=n;i++){
		double x;
		cin>>x;
		q.push((node){x});
	}
	for(int i=1;i<=n-1;i++){
		double x=q.top().x;
		q.pop();
		double y=q.top().x;
		q.pop();
		q.push((node){(x+y)/2.});
	}
	printf("%.7lf",q.top().x);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[10000];
		int k = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			k = Math.max(k, a[i]);
			c[a[i]]++;
		}
		sc.close();
		countingSort(a, b, c, k);
		StringBuilder sb = new StringBuilder();
		sb.append(b[0]);
		for (int i = 1; i < n; i++) {
			sb.append(' ').append(b[i]);
		}
		System.out.println(sb.toString());
	}

	private static void countingSort(int[] a, int[] b, int[] c, int k) {
		for (int i = 1; i <= k; i++) {
			c[i] += c[i - 1];
		}
		for (int i = a.length - 1; i >= 0; i--) {
			c[a[i]]--;
			b[c[a[i]]] = a[i];
		}		
	}
}



Measured memory_bytes: 515088
//2017.12.1
//ABC 079　ワーシャルフロイド法を用いる
//解答を見た　意味は理解できた。
//今回はグラフの初期化を行っていないバージョン


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

using namespace std;

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

const int max_v = 200;
const int INF = 1000000;


int main() {
	int h, w, a, ans;
	cin >> h >> w;
	int cost[10][10];

	REP(i,10){
		REP(j,10){
			cin >> cost[i][j];
		}
	}


	//ワーシャルフロイドを実行
	for(int k=0; k<10; k++){
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				cost[i][j] = min( cost[i][j], cost[i][k]+cost[k][j]);
			}
		}
	}

	REP(i,h){
		REP(j,w){
			cin >> a;
			if(a >= 0) ans += cost[a][1];

		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
import collections

#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s

#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a

def main():
    num, length = map(int, input().split())
    s = []
    for i in range(int(num)):
        s.append(input())
    s.sort()
    print(''.join(s))
    
if __name__=='__main__':
    main()

Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	m := map[string]bool{}
	for i := 1; i <= 9; i++ {
		m[strconv.Itoa(i)] = false
	}

	N, K := nextInt(), nextInt()
	for i := 0; i < K; i++ {
		m[strconv.Itoa(nextInt())] = true
	}

	// fmt.Println(m)

	for i := N; i <= 1000000; i++ {
		s := strings.Split(strconv.Itoa(i), "")
		flag := true
		for _, ss := range s {
			if m[ss] {
				flag = false
				break
			}
		}

		if flag {
			fmt.Println(i)
			return
		}
	}

}


Measured memory_bytes: 5504
S = input()
w = 'keyence'
n = len(w)
N = len(S)
ch = 0
if 'keyence' in S and len(S) == len('keyence'):
    ch = 1

elif S[:3] == 'key' and S[-4:] == 'ence':
    ch = 1

elif S[:1] == 'k' and S[-6:] == 'eyence':
    ch = 1

elif S[:2] == 'ke' and S[-5:] == 'yence':
    ch = 1
elif S[:4] == 'keye' and S[-3:] == 'nce':
    ch = 1
elif S[:5] == 'keyen' and S[-2:] == 'ce':
    ch = 1
elif S[:6] == 'keyenc' and S[-1:] == 'e':
    ch = 1

if ch == 1:
    print('YES')
else:
    print('NO')

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


/*
*/

int main() {
  int N,W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  rep(i,N){
    cin >> w[i];
    cin >> v[i];
  }

  vector<vector<ll>> dp(N+3, vector<ll>(100000+10,INF));
  dp[0][0] = 0;
  
  for(int i = 0;i<N;i++){
    for(int j = 0;j<=100000;j++){
      dp[i+1][j] = dp[i][j];
      if(j >= v[i]) dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]] + w[i]);

    }
  }
  ll ans = 0;
  for(ll j = 0;j<=100000;j++){
    if(dp[N][j] <= W) ans = j;
  }
  cout << ans << endl;
}

Measured memory_bytes: 81792
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
    getline(cin,s1);getline(cin,s2);
    cout<<s1[0];
    for(int i=0;i<s1.size()+s2.size()-1;i++)
        if(i%2)cout<<s1[i/2+1];
        else cout<<s2[i/2];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int main(){
    long long int N;
    long long int K;
    cin>>N>>K;
    long long int res=1000000000000000001;
    if(N>K) N=N%K+K;
    while(N<res){
        res=N;
        N=labs(N-K);
    }
    cout<<res<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
   int X,Y;
   scanf("%d %d",&X,&Y);
   int i;
   for(i=0;i<=X;i++){

    int a = i * 2 + (X - i) * 4;
    if (a == Y) {
     
printf("Yes");
break;
    }
}
   if(i>X){
printf("No");
   }
   return 0;
}


Measured memory_bytes: 1732
<?php

fscanf(STDIN, "%d", $count);
for($i = 0; $i < $count; $i++)
{
  fscanf(STDIN, "%d %d %d", $t[$i+1], $x[$i+1], $y[$i+1]);
}
$t[0] = 0;
$x[0] = 0;
$y[0] = 0;
for($i = 0; $i < $count; $i++)
{
  $LValue = $t[$i+1] - $t[$i];
  $RValue = ($x[$i+1] - $x[$i]) + ($y[$i+1] - $y[$i]);
  if($LValue < $RValue)
  {
    echo "No\n";
    return;
  }
  if(($RValue - $LValue) % 2 != 0)
  {
    echo "No\n";
    return;
  }
}
echo "Yes\n";

Measured memory_bytes: 47092
require "matrix"

$<.map {|a| a.split.map(&:to_i)}.each do |a|
  Matrix[[a[0], a[1]], [a[3], a[4]]]
    .lup
    .solve([a[2], a[5]])
    .map{|b| b.to_f.round(3)}
    .tap{|c| print format("%.3f %.3f\n", c[0], c[1])}
end


Measured memory_bytes: 7300
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;
 
 
#define FILENAME ""
 
const ll MAXN = 100002;

double log2 (double a) {
	double temp = (double) log(a)/log(2);
 	return temp;
}
                         
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    //freopen("sum2.in", "r", stdin);
    //freopen("sum2.out", "w", stdout);
    double n;
    cin >> n;
    double k = log2(n);
    ++k;
    cout << (long long) pow(2, (ll) k) - 1;
    re 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
using namespace std;
 
typedef long long ll;

int main(){
	int a,b,c;
    cin >> a >> b >>c;
    for(int i=100; i>0; i--){
    	if(a%i==0 && b%i==0){
        	c--;
            if(c==0){
            	cout << i << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N, T;
int a[3100];
int b[3100];
ll dp1[3100][3100];
ll dp2[3100][3100];

int main () {
  cin >> N >> T;
  rep(i, N) {
    cin >> a[i] >> b[i];
  }

  rep(i, N) {
    rep(j, T) {
      if (j >= a[i]) {
        dp1[i][j] = max(dp1[i-1][j-a[i]] + b[i], dp1[i-1][j]);
      } else {
        dp1[i][j] = dp1[i-1][j];
      }
    }
  }

  for (int i=N;i>=1;--i) {
    rep(j, T) {
      if (j >= a[i]) {
        dp2[i][j] = max(dp2[i+1][j-a[i]] + b[i], dp2[i+1][j]);
      } else {
        dp2[i][j] = dp2[i+1][j];
      }
    }
  }

  ll res = 0;

  //rep(i, N) {
  //  Rep (j, T) {
  //    cout << i << " " << j << "\n";
  //    cout << dp1[i][j] << "\n";
  //  }
  //}

  rep(i, N) {
    Rep (j, T) {
      res = max(res, dp1[i-1][j] + b[i] + dp2[i+1][T-1-j]);
    }
  }

  cout << res << "\n";

}

Measured memory_bytes: 149760
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func pow2(a int) int {
	return int(math.Pow(2, float64(a)))
}

func scanSumP(n int) int {
	a := 0
	for i := 0; i < n; i++ {
		a += div2(scanInt())
	}
	return a
}

func div2(n int) int {
	for i := 30; i > 0; i-- {
		if n%pow2(i) == 0 && n >= pow2(i) {
			return i
		}
	}
	return 0
}

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	// fmt.Println(pow2(30))
	fmt.Println(scanSumP(n))
	// fmt.Println(div2(scanSumP(n)))
}


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

int main(){
  string s,t;
  cin >> s >> t;
  if(s.size() > t.size()){
    for(int i = 0; i < t.size(); i++){
      cout << s[i] << t[i];
    }
    cout << s[s.size() - 1] << endl;
    return 0;
  }else{
    for(int i = 0; i < t.size(); i++){
      cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
  }
}

Measured memory_bytes: 3572
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int nibutan(int key,int n);
vector<int> a;
int main(void) {
	int n,temp;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> temp;
		a.push_back(temp);
	}
	sort(a.begin(),a.end());
	if(n==2){
		cout << a[1] << " " << a[0] << endl;
		return 0;
	}
	int maxi=a[n-1];
	cout << maxi << " ";
	int index=nibutan(a[n-1]/2,n);
	cout << (abs(maxi/2-a[index])<abs(maxi/2-a[index+1])?a[index]:a[index+1]) << endl;
	return 0;
}

int nibutan(int key,int n){
	int ok=0,ng=n,mid;
	while(abs(ok-ng)>1){
		mid=(ok+ng)/2;
		if(a[mid]<key)ok=mid;
		else ng=mid;
	}
	return ok;
}


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

int main()
{
    int N;
    char s[120][12];
    int p[120];
    int ans[120] = {0};

    scanf("%d", &N);

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

    // for (int i = 0; i < N; i++)
    // {
    //     printf("%s", s[i]);
    //     printf("%d", p[i]);
    // }

    // printf("%d", N);

    // forでほかの値をすべてみて、ans配列に自分の順番を入れる
    for (int i = 0; i < N; i++) {
        int cnt = 0;

        // 他の配列とすべて比較する
        for (int j = 0; j < N; j++) {
            // 自分は除外
            // if (i == j) continue;
            // printf("%d\n", i);
            // printf("%d", strcmp(s[i], s[j]));
            // s[j]の方が早い.つまり,s[i]は後ろ
            if (strcmp(s[i], s[j]) > 0)
            {
                // printf("%s%s\n", s[i], s[j]);
                cnt++;
            }
            else if (strcmp(s[i], s[j]) == 0)
            {
                // 比較相手の方が早い
                if (p[i] < p[j]) {
                    cnt++;
                }
            }
        }
        ans[cnt] += i;
        ans[cnt] += 1;
    }

    for (int i = 0; i < N; i++)
    {
        printf("%d\n", ans[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
  int ans = 0;
  int min_time = 10;
  for (int i = 0; i < 5; i++) {
    int time;
    cin >> time;
    ans += (time + 9) / 10 * 10;
    min_time = min(min_time, (time - 1) % 10);
  }
  cout << ans - 10 + min_time + 1 << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = map(int, raw_input().split())

cost = [[INF] * N for i in range(N)]
for i in range(N):
    cost[i][i] = 0

ls = []
for i in range(M):
    a, b, c = map(int, raw_input().split())
    a, b = a - 1, b - 1
    ls.append((a, b, c))
    cost[a][b] = c
    cost[b][a] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])

ans = 0
for a, b, c in ls:
    if cost[a][b] != c:
        ans += 1

print ans

Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main() {
	int N;
	int count = 0;

	cin >> N;

	for (int i = 1; i <= N; i++) {
		if ((i >= 0) && (i < 10)) {
			count++;
		}
		else if ((i >= 100)&&(i < 1000)) {
			count++;
		} else if ((i >=10000)&&(i < 100000)) {
			count++;
		} 
	}

	cout << count << endl;
	
	return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}



int main(){
  int N,K;
  cin >> N >> K;
  int ans=1;
  while(N>=K){
    N=N/K;
    ans ++;
  }

  cout << ans;
}

Measured memory_bytes: 256
//ABC175_A

#include <stdio.h>
#include <string.h>

int main(){
	char s[5]; 
	int cnt=0;
	
	scanf("%s",s);
	
	if(strcmp(s,"RRR")==0){
		cnt = 3;
	}
	else if(strcmp(s,"RRS")==0 || strcmp(s,"SRR")==0){
		cnt = 2;
	}
	else if(strcmp(s,"RSS")==0 || strcmp(s,"RSR")==0 || strcmp(s,"SSR")==0 || strcmp(s,"SRS")==0){
		cnt = 1;
	}
	else cnt = 0;
	
	printf("%d",cnt);
	
	return 0;
}


Measured memory_bytes: 1712
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long llong;
class Point {
public:
	double x, y;
};
int main() {
	int n; cin >> n;
	while (n--) {
		Point a, b, c, d;
		cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
		b.x -= a.x; a.x = 0;
		b.y -= a.y; a.y = 0;
		d.x -= c.x; c.x = 0;
		d.y -= c.y; c.y = 0;
		double z = b.x*d.y - b.y*d.x;
		if (fabs(z)<1e-10)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a, b, c, d;
    float e;
    cin >> a;
    cin >> b;
    if(b < 10)
    {
        c = 10*a + b;
    }
    else if((b >=10) && (b < 100))
    {
        c = 100*a + b;
    }
    else
    {
        c = 1000*a + b;
    }

    e = sqrt(c);
    d = e;
    if(c == d*d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

using i64 = int64_t;

bool used[100005]={0};

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

    int ans = 0, left = 0, right = 1;
    if(s.size() == 1){
        cout << 0 << endl;
        return 0;
    }
    while(right < s.size()){
        if(s[left] == s[right]){
            right++;
            left = right - 1;
        }else{
            ans += 2;
            used[right] = true;
            used[left] = true;
            right++;
            while(left >= 0 && used[left])left--;
            if(left < 0){
                right++;
                left = right - 1;
                continue;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
n = int(input())
ans = 0
now = int(input())
if now != 0:
    print(-1)
    exit()
zero = 0
for i in range(n-1):
    a = int(input())
    if a == now + 1:
        ans += 1
        now = a
    elif a <= now:
        ans += a
        zero = i-a
        now = a
    elif a >= now + 2:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 76248
def main(): 
    n = int(input())
    h = list(map(int, input().split()))

    max_i = 0
    i = 0 
    while i < n:
        cnt = 0
        for j in range(i+1, n):
            if h[j-1] >= h[j]:
                cnt += 1
            else:
                i = j
                break
                
        max_i = max(max_i, cnt)
        if max_i >= n - i - 1:
            break
    print(max_i)

if __name__ == "__main__":
    main() 

Measured memory_bytes: 15020
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>
#include <tuple>

using namespace std;

using ll = long long;

int main() {
    string s;
    cin >> s;
    
    int n = s.size();
    
    int ans = n;
    
    for (int k = 0; k < 2; k++) {
        
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] - '0' != (i + k) % 2) {
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    int x,y,z;
    cin>>x>>y>>z;

    if((x+y+z)>=22)
        cout<<"bust"<<endl;
    else
        cout<<"win"<<endl;





    return 0;
}


Measured memory_bytes: 256
//Darshan: 

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=pow(10,9)+7;

 



int checkbit(int a, int n, int pos)
{
	int res=(a&(1<<(pos-1)));
	if(res==0)
	{
		return(0);
	}
	else
	{
		return(1);
	}
}

int main()
{
		
	int n,m,x;
	cin>>n>>m>>x;
	int a[n][m+1];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}


vector<int>possible;

	for(int i=0;i<=pow(2,n);i++)
	{
		int arr[m];
		vector<int>price;
		for(int k=0;k<m;k++)
		{
			arr[k]=0;
		}
		for(int j=1;j<=n;j++)
		{
			int check=checkbit(i,n,j);
			if(check==1)
			{
				price.push_back(a[j-1][0]);
				for(int u=1;u<=m;u++)
				{
					arr[u-1]+=a[j-1][u];
				}
			}
		}
		int conf =1;
		for(int q=0;q<m;q++)
		{
			if(arr[q]<x)
			{
				conf=0;
				break;
			}
		}
		if(conf==1)
		{
			int sum=0;
			for(int i:price)
			{
				sum+=i;
			}
			price.clear();
			possible.push_back(sum);

		}
	}
	if(possible.size()==0)
	{
		cout<<-1<<endl;
	}
	else
	{
		int e= *min_element(possible.begin(),possible.end());
		cout<<e<<endl;
	}

}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD  1000000007
#define MOD2 1000000009
#define BASE  1007
#define BASE2 1009
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int n, m, r, l;
string str;
vector<int> v;
set<P> se;
ll hash = 0, hash2 = 0;

ll base_pow(int x){
	ll ret = 1;
	ll b = BASE;
	while(x){
		if(x&1) ret = ret*b%MOD;
		b = b*b%MOD;
		x >>= 1;
	}
	return ret;
}

ll base2_pow(int x){
	ll ret = 1;
	ll b = BASE2;
	while(x){
		if(x&1) ret = ret*b%MOD2;
		b = b*b%MOD2;
		x >>= 1;
	}
	return ret;
}

int main(){
	cin >> n >> m >> str;
	rep(i,n) v.push_back(str[i]-'a'+1);
	hash = v[0];
	hash2 = v[0];
	rep(i,m){
		string x;
		cin >> x;
		if(x == "R++"){
			r++;
			hash *= BASE;
			hash += v[r];
			hash2 *= BASE2;
			hash2 += v[r];
		}
		if(x == "R--"){
			hash -= v[r];
			hash2 -= v[r];
			r--;
			hash *= base_pow(MOD-2);
			hash2 *= base2_pow(MOD2-2);
		}
		if(x == "L++"){
			hash -= v[l]*base_pow(r-l);
			hash2 -= v[l]*base2_pow(r-l);
			l++;
		}
		if(x == "L--"){
			l--;
			hash += v[l]*base_pow(r-l);
			hash2 += v[l]*base2_pow(r-l);
		}
		hash += 1LL*MOD*100;
		hash2 += 1LL*MOD2*100;
		hash %= MOD;
		hash2 %= MOD2;
		se.insert(P(hash,hash2));
	}
	cout << se.size() << endl;
}

Measured memory_bytes: 21240
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

long long two_count(long long n){
    long long cnt = 0;

    while(n % 2 == 0){
        cnt++;
        n /= 2;
    }
    return cnt;
}

int main(){
    long long n;
    cin >> n;
    vector<long long> a(101, 0);

    for(long long i = 1; i <= n; i++) a[i] = two_count(i);

    long long maxv = 0;

    for(long long i = 1; i <= n; i++) maxv = max(maxv, a[i]);

    long long number;
    for(long long i = 1; i <= n; i++) if(maxv == a[i]) number = i;

    cout << number << endl;
    return 0;
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

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

using namespace std;

int N;
int L[3000];
int ary_cnt;
int ary[3000 * 3000];

int A = 0;

//にぶたん
bool isOK(int index)
{
	return (L[index] > A);
}

int binary_search()
{
	int left = -1;
	int right = N;
	while (right - left > 1)
	{
		int mid = left + (right - left) / 2;
		if (isOK(mid))
			right = mid;
		else
			left = mid;
	}
	return right;
}

signed main()
{
	cin >> N;
	for (int i = 0; i < N; i++) cin >> L[i];

	ARY_SORT(L, N);

	int ans = 0;
	for (int i = 1; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			int a = L[i];
			int b = L[j];
			int n = b - a;

			A = n;
			int y = binary_search();
			ans += MAX(0, i- y);
		}
	}
	cout << ans << endl;
}



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

#define lint long long


int main(){
    int N; cin >> N;
    vector<int> a(N), b(N);
    map<int, int> cnt;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        if(a[i]%4 == 0){
            b[i] = 2;
            cnt[2]++;
        } else if(a[i]%2 == 0){
            b[i] = 1;
            cnt[1]++;
        } else {
            b[i] = 0;
            cnt[0]++;
        }
    }
    if(cnt[0] > cnt[2]){
        if(cnt[1] == 0 && cnt[0] == cnt[2] + 1){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "Yes" << endl;
    }
    
}


Measured memory_bytes: 1024