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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int ans=0;
  int t=0;
  for(int i=0; i<N; i++){
    if(t < d.at(i)){
      t = d.at(i);
      ans++;
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

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

    int cnt = 0, max = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            cnt = 1;
            for (int j = i + 1; j < s.length(); j++)
            {
                if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')
                {
                    cnt++;
                }
                else
                {
                    break;
                }
            }
            if (cnt > max)
            {
                max = cnt;
            }
        }
    }
    cout << max << endl;
}


Measured memory_bytes: 256
import sys
def calc(a,d):
    K=list(format(d,'04b'))
    ans=0
    t=[]
    for i in range(4):
        if K[i]=='0':
            ans+=a[i]
            t.append('+')
        else:
            ans-=a[i]
            t.append('-')
    return ans,t
s=list(input())
for i in range(4):
    s[i]=int(s[i])
for i in range(1<<3+1):
    r,f=calc(s,i)
    if r==7:
        print(str(s[0])+f[1]+str(s[1])+f[2]+str(s[2])+f[3]+str(s[3])+'=7')
        sys.exit()


Measured memory_bytes: 3064
N = int(input())
T, A = map(int, input().split())

diff = 10 ** 15
index = 1
ans = 10 ** 15

def cal(H):
    return T - H * 0.006


for i in input().split():
    if abs(cal(int(i))-A) <= diff:
        diff = abs(cal(int(i))-A)
        ans = index
    index += 1

print(ans)


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

int a,b;

int main()
{
	cin>>a>>b;
	int i,x,y,total=0;
	double s;
	for(i=1;i<=a;i++)
	{
		cin>>x>>y;
		s=sqrt(1ll*x*x+1ll*y*y);
		if(s<=b)
		  total++;
	}
	cout<<total;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 2e5+5;
int a[M],b[M];
int getRes(int x,int n)
{
	vector<int> v;
	for(int i=1;i<=n;i++)
		v.pb(b[i]%(2*x));
	sort(all(v));
	int cnt = 0;
	for(int i=1;i<=n;i++)
	{
		int y = a[i];
		y = y%(2*x);
		int p = (int)(lower_bound(all(v),x-y)-v.begin());
		int q = (int)(lower_bound(all(v),2*x-y)-v.begin());
		int r = (int)(lower_bound(all(v),3*x-y)-v.begin());
		p = n-p,q=n-q,r=n-r;
		cnt = (cnt+p+r-q)%2;
	}
	if(cnt)
		return x;
	return 0;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	int ans = 0;
	for(int i=0;i<=28;i++)
	{
		ans += getRes((1<<i), n);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 6616
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
  	int a,b;
    Scanner scan = new Scanner(System.in);
    a = scan.nextInt();
    b = scan.nextInt();
    if((a * b)%2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


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

    ll n;
    cin>>n;
    ll ans = 0;
    ans += n/500;
    ans *= 1000;
    n %= 500;
    ll ret = n/5;
    ret *= 5;
    cout << ans + ret << endl;
}

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

int main(int argc, char* argv[])
{
  int N, A, B;
  std::cin >> N >> A >> B;

  std::string judge = "Alice";
  if ((B-A) % 2 == 1) {
    judge = "Borys";
  }
  std::cout << judge << std::endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import math

N = int(input())

init, tmp, ans = N // 10, 50, 0
if N % 2 == 0:
    while True:
        if N // tmp > 0:
            ans += N // tmp
            tmp = tmp * 5
        else:
            break
    print(init + ans)
else:
    print(0)


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

int main(void) {
  int n, ans = 0;
  cin >> n;
  
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans += a - 1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val h1 = sc.nextInt()
    val m1 = sc.nextInt()
    val h2 = sc.nextInt()
    val m2 = sc.nextInt()
    val k = sc.nextInt()
    val t1 = h1 * 60 + m1
    val t2 = h2 * 60 + m2
    println(t2 - t1 - k)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<string, int> si;
typedef pair<si, int> sii;
bool comparesii (sii i,sii j) {
  if(i.first.first == j.first.first) {
    return i.first.second > j.first.second;
  } else {
    return i.first.first < j.first.first;
  }
}
typedef pair<string, int> si;
typedef pair<si, int> sii;
int main() {
  int N;
  cin >> N;
  vector<sii> res;
  for(int i = 0; i < N; i++) {
    string name;
    int score;
    cin >> name >> score;
    si r; r.first = name; r.second = score;
    sii rr; rr.first = r; rr.second = i + 1;
    res.push_back(rr);
  }
  sort(res.begin(), res.end(), comparesii);
  for(sii &i : res) {
    cout << i.second << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
# import sys
matches = input()
matches_list = list(matches)
# o = 0
x = 0
for i in matches_list:
  # if i == 'o':
  #   o += 1
  if i == 'x':
    x += 1

if x >= 8:
  print('NO')
else:
  print('YES')
  # sys.exit()

# print(x, matches_list)

Measured memory_bytes: 2940
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ab = a+b;
	int bc = b+c;
	int ca = a+c;
	int min = ab;
	if(min > bc){
		min = bc;
	}
	if(min > ca){
		min = ca;
	}
	cout << min << endl;
}

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


int main(){
    while(1)
    {
        int i;
        cin>>i;
        if(i==0)break;
        int remain = 1000-i;
        int count = 0;
        while(remain!=0)
        {
            if(remain>=500)
            {
                count++;
                remain -= 500;
            }
            else if(remain>=100)
            {
                count++;
                remain -= 100;
            }
            else if(remain>=50)
            {
                count++;
                remain -= 50;
            }
            else if(remain>=10)
            {
                count++;
                remain -= 10;
            }
            else if(remain>=5)
            {
                count++;
                remain -= 5;
            }
            else if(remain>=1)
            {
                count++;
                remain -= 1;
            }
        }
        cout<<count<<endl;
    }
    
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>

using namespace std;

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

    int n = static_cast<int>(s.size());

    long long res = 0;
    if (k == 1) {
        for (int i = 1, c = 1; i < n; i++) {
            if (s[i - 1] == s[i]) {
                c++;
            }

            if (s[i - 1] != s[i] || i == n - 1) {
                res += c / 2;
                c = 1;
            }
        }
    } else {
        int idx = 1;
        for (; idx < n && s[idx - 1] == s[idx]; idx++) {
        }

        if (idx == n) {
            res += k * idx / 2;
        } else {
            res += idx / 2;

            long long r = 0;
            for (int i = 1, c = 1; i < n; i++) {
                if (s[(idx + i - 1) % n] == s[(idx + i) % n]) {
                    c++;
                }

                if (s[(idx + i - 1) % n] != s[(idx + i) % n] || i == n - 1) {
                    r += c / 2;
                    c = 1;
                }
            }

            res += (k - 1) * r;

            for (int i = idx + 1, c = 1; i < n; i++) {
                if (s[i - 1] == s[i]) {
                    c++;
                }

                if (s[i - 1] != s[i] || i == n - 1) {
                    res += c / 2;
                    c = 1;
                }
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, M;

int root(int x, vector<int>& par) {
    if (par[x] == x) return x;
    return par[x] = root(par[x], par);
}

void unite(int x, int y, vector<int>& par, vector<int>& group) {
    x = root(x, par);
    y = root(y, par);
    if (x == y) return;
    par[x] = y;
    group[y] += group[x];
}

int main() {
    cin >> N >> M;
    vector<pair<int, int>> edge(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge[i] = make_pair(a - 1, b - 1);
    }
    int ans = M;
    for (int i = 0; i < M; i++) {
        vector<int> par(N), group(N, 1);
      	for (int j = 0; j < N; j++) par[j] = j;
        for (int j = 0; j < M; j++) {
            if (i == j) continue;
            unite(edge[j].first, edge[j].second, par, group);
        }
        if (group[root(0, par)] == N) --ans;
    }
    cout << ans << endl;
}





Measured memory_bytes: 256
import sys

S_ = list(sys.stdin.readline()[:-1])
T = list(sys.stdin.readline()[:-1])

start_right = -1
for i in range(len(S_)):
    if (S_[i] == "?") or (S_[i] == T[0]):
        for j in range(1, len(T)):
            if (i+j >= len(S_)):
                break
            if (S_[i+j] == "?") or (S_[i+j] == T[j]):
                continue
            else:
                break
        else:
            start_right = i
    
for i in range(len(T)):
    S_[start_right + i] = T[i]

if (start_right != -1):
    for s in S_:
        print(s if (s != "?") else "a", end="")
    print()
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <iostream>

int main(int argc, char const *argv[])
{
    int a, b;
    std::cin >> a >> b;

    if (a < b) {
        std::cout << "a < b" << std::endl;
    }
    else if (a > b)
    {
        std::cout << "a > b" << std::endl;
    }
    else
    {
        std::cout << "a == b" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif

int32_t main() 
{
	IAMSPEED
	ll a,b,n; cin >> a >> b >> n;
	ll x = min(b-1,n);
	cout << (a*x)/b;
}



Measured memory_bytes: 3640
#include<map>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
map<string,int>T;
int n,l,ans;string c;
string o[205];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>c;
		if(!T[c])o[++l]=c;
		T[c]++;
	}
	cin>>n;
	for(int i=1;i<=n;i++)
	{cin>>c;T[c]--;}
	for(int i=1;i<=l;i++)
		ans=max(ans,T[o[i]]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

csm = [0]
cnt = 0

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		cnt += 1
	csm.append(cnt)
	
for j in range(q):
	print(csm[ls[j][1] - 1] - csm[ls[j][0] - 1])

Measured memory_bytes: 24468
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = next();
  myout(s[0] + (s.length - 2) + s[s.length - 1]);
}

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	ll ans = 2147483647;
	for (int i = k - 1; i < n; i++) {
		ans = min(ans, (h[i] - h[i - k + 1]));
	}
	cout << ans << endl;
}

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

int main(){
    int k;
    cin>>k;

    queue<array<ll,2>> q;

    for(int i = 1; i <= 9; i++) q.push({i,i});

    ll cnt = 0;
    ll res = 0;
    while(cnt<k){
        auto t = q.front();
        res = t[0];
        q.pop();

        ll nt = t[0]*10;
        if(t[1]!=0)q.push({nt+(t[1]-1),t[1]-1});
        q.push({nt+(t[1]),t[1]});
        if(t[1]!=9)q.push({nt+(t[1]+1),t[1]+1});
        cnt++;
    }
    cout<<res;

}


Measured memory_bytes: 6636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S; cin >> S;
    string k = "keyence";
    int n = k.size(), m = k.size();
    for (int i = 0; i < k.size(); i++) {
        if (k[i] != S[i]) {
            n = i;
            break;
        }
    }
    for (int i = 0; i < k.size(); i++) {
        if (k[k.size() - 1 - i] != S[S.size() - 1 - i]) {
            m = i;
            break;
        }
    }
    cout << ((n + m >= k.size()) ? "YES" : "NO") << endl;
    return 0;
}

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

using namespace std;

const int LimitOfGridNumber = 300, NumberOfFaces = 6, MaxTurn = 3000;

enum EAction{
	Right = 1,
	Stay = 0,
	Left = -1,
};

typedef struct{
	int dice;
	EAction direction;
} memo_t;

typedef struct{
	bool dice[NumberOfFaces+1][2];
} check_t;

int move(int _position, int _a_dice, EAction _eaction, const int _N[]){
	_position += _a_dice * _eaction;
	return _position + _N[_position];
}

bool isConnected(int _position, int _f, int _lr, const int _a[], check_t _is_checked[], const int _N[], int _M, vector<memo_t> &_route, int _s){
	if(_is_checked[_position].dice[_f][_lr]) return false;
	_is_checked[_position].dice[_f][_lr] = true;

	EAction direction;
	if(_lr == 0) direction = Right;
	else direction = Left;

	_position -= _a[_f] * direction;
	if(_position < 1 || _position > _M) return false;
	if(_route.size() >= MaxTurn) return false;

	memo_t tmp;
	tmp.dice = _f;
	tmp.direction = direction;
	_route.push_back(tmp);
	
	if(_position == _s) return true;

	for(int m=1; m<=_M; m++){
		if(_position - m == _N[m]){
			for(int f=1; f<=NumberOfFaces; f++){
				for(int lr=0; lr<2; lr++){
					if(isConnected(m, f, lr, _a, _is_checked, _N, _M, _route, _s)) return true;
				}
			}
		}
	}

	_route.pop_back();
	
	return false;
}

void FindRoute(int _M, const int _a[], int _s, int _g, const int _N[], vector<memo_t> &_route){
	check_t is_checked[LimitOfGridNumber+1];
	for(int m=1; m<=_M; m++){
	for(int f=1; f<=NumberOfFaces; f++){
	for(int lr=0; lr<2; lr++){
		is_checked[m].dice[f][lr] = false;
	}}}

	int position = _g;
	
	for(int m=1; m<=_M; m++){
		if(position - m == _N[m]){
			for(int f=1; f<=NumberOfFaces; f++){
				for(int lr=0; lr<2; lr++){
					if(isConnected(m, f, lr, _a, is_checked, _N, _M, _route, _s)) return;
				}
			}
		}
	}

	for(int f=1; f<=NumberOfFaces; f++){
		for(int lr=0; lr<2; lr++){
			if(isConnected(position, f, lr, _a, is_checked, _N, _M, _route, _s)) return;
		}
	}
}

int main(){
	int M, a[NumberOfFaces+1], s, g, N[LimitOfGridNumber+1];
	cin >> M;
	for(int f=1; f<=NumberOfFaces; f++) cin >> a[f];
	cin >> s >> g;
	for(int m=1; m<=M; m++) cin >> N[m];

	vector<memo_t> route;

	FindRoute(M, a, s, g, N, route);
	int clear_turn = route.size();

	int test = s;
	vector<int> memo;
	memo.push_back(s);
	for(int i=route.size()-1; i>=0; i--){
		test = move(test, a[route[i].dice], route[i].direction, N);
		memo.push_back(test);
	}
	for(int turn=0; turn<=clear_turn; turn++){
		for(int t=0; t<turn; t++){
			if(memo[t] == memo[turn]){
				route.erase(route.end()-turn, route.end()-t);
				memo.erase(memo.begin()+t, memo.begin()+turn);
				turn=t;
				break;
			}
		}
		clear_turn = route.size();
	}

	int position = s;
	int index = clear_turn - 1;
	for(int turn=0; turn<MaxTurn; turn++){
		int dice;
		cin >> dice;

		memo_t tmp = route[index];
		EAction eaction = Stay;
		if(dice == tmp.dice){
			eaction = tmp.direction;
			index--;
		}

		cout << eaction << endl;
		cout.flush();

		// 移動の処理
		if(eaction != Stay) position = move(position, a[dice], eaction, N);
		
		// クリア判定 -> クリアなら break
		if(position == g) return 0;
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)


int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    vector<P> color(n,P(-1,-1));
    for (int i = 0;i < m;++i) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int q;
    cin >> q;
    vector<int> v(q),d(q),c(q);
    for (int i = 0;i < q;++i) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    for (int i = q-1;i >= 0;--i) {
        if (color[v[i]].second >= d[i]) continue;
        vector<P> que;
        que.push_back(P(v[i],d[i]));
        while (!que.empty()){
            P p = que.back();que.pop_back();
            if (color[p.first].first < 0) color[p.first] = P(i,p.second);
            if (p.second < 1) continue;
            for (int j : edges[p.first]) {
                if (color[j].second < p.second-1) {
                    que.push_back(P(j,p.second-1));
                    color[j].second = p.second-1;
                }
            }
        }
    }
    for (int i = 0;i < n;++i) {
        int j = color[i].first;
        cout << (j > -1 ? c[j] : 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 9924
from collections import defaultdict

N = int(input())
l = [int(input()) for _ in range(N)]
dp = [0] * (N+1)
pos = defaultdict(lambda: -1)
dp[0] = 1
MOD = 10**9+7

for i in  range(1, N+1):
    p = pos[l[i-1]]
    if i-p>1 and p!=-1:
        dp[i] += dp[p]
    pos[l[i-1]] = i
    dp[i] += dp[i-1]
    dp[i] %= MOD
    
print(dp[-1])

Measured memory_bytes: 36880
/**
  @file a.cpp
  @title A - B +/- A
  @url https://atcoder.jp/contests/abc118/tasks/abc118_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

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

  vector<int> memo(4, 0);
  for (int i = 0; i < S.length(); i++) {
    for (int j = 0; j < S.length(); j++) {
      if (S[j] == S[i]) {
        memo[j]++;
      }
    }
  }

  if ((*max_element(ALL(memo)) == 2) && (*min_element(ALL(memo)) == 2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

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


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

int main()
{
	char s[111];

	while(~scanf("%s", s)) {
		int cnt = 0;
		char p = 'A'; // p := previous
		for(int i = 0, l = strlen(s); i < l; i++) {
			if(p >= s[i]) cnt++;
			p = s[i];
		}

		printf("%d\n", cnt);
	}

	return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m = 1e9, mi;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i){
	cin >> a[i];
  }
  int minn = *min_element(a.begin(),a.end()), maxx = *max_element(a.begin(),a.end());
  for (int i = minn; i <= maxx; ++i){
	int t = 0;
	for (int j = 0; j < n; ++j){
		t += (a[j] - i)*(a[j] - i);
	}
	if (t < m){
		m = t;
		mi = i;
	}
  }
   m = 0;
 	for (int i = 0; i < n; ++i){
		m += (a[i] - mi)* (a[i] - mi);
	}
	cout << m << "\n";
return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import numpy as np

#input
#[H,W] = list(map(int,input().split()))
#[h,w] = list(map(int,input().split()))
#
#print((H-h)*(W-w))


#[N, M] = list(map(int,input().split()))
# s = str(input())

#[A, B, K] = list(map(int,input().split()))

s = str(input())

num_0 = 0

for i in range(len(s)):
    if s[i] == "1":
        num_0 += 1
    
num_1 = len(s) - num_0
print(len(s) - abs(num_0 - num_1))



Measured memory_bytes: 12620
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int m,f,b;
	cin >> m >> f >> b;

	if(b - m > f){
		cout << "NA" << endl;
	}
	else {
		if(b-m > 0){
			cout << b-m << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971
#define MAX 9223372036854775807
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	cout<<fixed<<setprecision(10);
	ll n,k;
	cin>>n>>k;
	set<ll> s;
	for(int a=0;a<k;a++)
	{
		ll x;
		cin>>x;
		for(int a=0;a<x;a++)
		{
			ll y;
			cin>>y;
			s.insert(y);
		}
	}
	cout<<n-s.size();
	return 0;
}

Measured memory_bytes: 3672
// Indrajeet Mishra
 
/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)
 
ll dp[101][101];
void dp_initialiser(){
    memset(dp,-1,sizeof(dp));
}

int main() {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    dp_initialiser();
    ll n=0;cin>>n;
    ll a[n]={0};
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    ll count=0;
    if(n<3){
        cout<<"0";
        return 0;
    }
    rep(i,0,n-2){
        rep(j,i+1,n-1){
            rep(k,j+1,n){
                if((a[i]!=a[j] && a[j]!=a[k]) && ((a[i]+a[j])>a[k]))
                count++;
            }
        }
    }
    cout<<count;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  vector<int> a(s.size()+1,0);
  int x=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='<'){
      x++;
      a.at(i+1)=x;
    }else{
      x=0;
      a.at(i+1)=x;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i)=='>'){
      x++;
      a.at(i)=max(a.at(i),x);
    }else{
      x=0;
      a.at(i)=max(x,a.at(i));
    }
  }
  
  long long int ans=0;
  for(int i=0;i<s.size()+1;i++){
    ans+=a.at(i);
  }
  cout << ans << endl;
}


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


int H, W;
int a[505][505];
vector<pair<pair<int, int>, pair<int, int> > > ans;


int main(){

  for(int i = 0; i < 505 ; i++){
    for(int j =0 ; j < 505; j++){
      a[i][j] = -1;
    }      
  }
  
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      int inp;
      cin >> inp;
      a[i+1][j+1] = inp;
    }
  }

  pair<int, int> now = make_pair(1,1);
  while(1){
    int i = now.first;
    int j = now.second;


    
    pair<int, int> nex ;
    if(a[i][j+1] != -1){
      nex = make_pair(i,j+1);
    }
    else if(a[i][j-1]!= -1){
      nex = make_pair(i,j-1);
    }
    else if(a[i+1][j] != -1){
      nex = make_pair(i+1,j);
    }
    else break;

    if(a[i][j] % 2){
      ans.push_back(make_pair(now, nex));
      a[nex.first][nex.second] += 1;
    }
    a[i][j] = -1;
    now.first = nex.first;
    now.second = nex.second;
  }

  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second.first << " " << ans[i].second.second << endl;
  }
    


  return 0;
}


Measured memory_bytes: 5232
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if (i*500+j*100+k*50) == X:
                count += 1
print(count)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	VI d(n);
	LL ans=0;
	rep(i,n){
		cin>>d.at(i);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=d.at(i)*d.at(j);
		}
	}
	cout<<ans<<endl;
	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();
        long[] arr = new long[n];
        for(int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
            if(arr[i] > i) {
                System.out.println(-1);
                return;
            }
        }
        long ans = 0L;
        if(arr[0]!=0) {
            System.out.println(-1);
            return;
        }
        for(int i = 1; i < n; i++) {
            long backNum = arr[i-1];
            long nowNum = arr[i];
            if(nowNum > backNum) {
                if(nowNum - backNum == 1) {
                    ans += nowNum - backNum;
                } else {
                    System.out.println(-1);
                    return;
                }
            } else {
                ans += nowNum;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 89164
#include<stdio.h>

int main(){
int a;
int b;
int x;
int keta=0;
int i;

while(scanf("%d %d",&a,&b) != EOF){

x=a+b;
for(keta=1;(x/10)!=0;keta++){x=x/10;}

printf("%d\n",keta);
}



return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  bool flag = false;
  rep(i,n) {
    cin >> a[i];
    if(a[i]==1) flag = true;
  }
  if(!flag) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 1;
  rep(i,n) {
    if(a[i] == ans) ans++;
  }
  cout << n-ans+1 << endl;
  return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
using namespace std;

int main() {FIN;
    string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int n;
    string s;
    cin>>n>>s;
    fore(i,0,s.length()){
        int j = (int)(s[i] - 'A');
        cout<<a[j+n];
    }
    cout<<"\n";
    return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
        cout << a + b << endl;
    else
        cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略
 
int main(){
  int ans=0;
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i,n){cin >> L[i];}
  sort(L.begin(),L.end());
  rep(b,n){
    rep(a,b){
      int ab =L[a]+L[b];
      int r = lower_bound(L.begin(),L.end(),ab)-L.begin();
      int l = b+1;
      ans += max(0,r-l);
    }
  }
  cout << ans <<endl;
  return 0;
}

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

struct Node {
    int color;
    bool done;
    vector<int> tos, costs;
};

void dfs(int pos, vector<Node>& nodes) {
    nodes[pos].done = true;
    for (int i = 0; i < nodes[pos].tos.size(); i++) {
        int npos = nodes[pos].tos[i], cost = nodes[pos].costs[i];
        if (nodes[npos].done == false) {
            if (cost % 2 == 0) {
                nodes[npos].color = nodes[pos].color;
            } else {
                nodes[npos].color = nodes[pos].color ^ 1; // 0 -> 1, 1 -> 0
            }
            dfs(npos, nodes);
        }
    }
}

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

    int n;
    cin >> n;
    vector<Node> nodes(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        nodes[a].tos.push_back(b);
        nodes[a].costs.push_back(c);
        nodes[b].tos.push_back(a);
        nodes[b].costs.push_back(c);
    }

    nodes[0].color = 0;
    dfs(0, nodes);
    for (int i = 0; i < n; i++) {
        cout << nodes[i].color << endl;
    }
    return 0;
}

Measured memory_bytes: 12928
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static List<int>[] li;
	static bool[] b;
	static int[] h;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I,m=n;
		li=new List<int>[n+1];
		b=new bool[n+1];
		h=new int[n+1];
		for(int i=1;i<=n;i++){li[i]=new List<int>();}
		for(int i=2;i<=n;i++){
			int e=sc.I;
			li[e].Add(i);
		}
		Fu(1);
		Console.WriteLine("{0}",h[1]);
	}
	static void Fu(int a){
		for(int i=0;i<li[a].Count;i++){
			if(!b[li[a][i]]){
				Fu(li[a][i]);
			}
		}
		li[a].Sort((u,v)=>h[v]-h[u]);
		for(int i=0;i<li[a].Count;i++){h[a]=Max(i+h[li[a][i]]+1,h[a]);}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 31392
#include<bits/stdc++.h>
#define ll long long
#define thekingisborn ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ld  long double
#define f first
#define se second
#define pb push_back
#define maxn 200005
#define mod 1000000007
#define pi 3.14159265359

using namespace std;

typedef pair<int,int>pii;
typedef pair<ll,ll>pll;

/*ll power(ll a,ll n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    a = a%mod;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n>>1))%mod)%mod;
    return power((a*a)%mod,n>>1)%mod;
}
ll gcd(ll a,ll b)
{
    if(a%b == 0)return b;
    return gcd(b,a%b);
}*/
/*int root(int x)
{
    while(par[x] != x)
    x = par[x];
    return x;
}
void dsu(int x,int y)
{
  if(root(x) == root(y))return;
  par[root(y)] = root(x);
  return;
}
void dfs(int x)
{
    done[x] = true;
    for(int i=0;i<int(adj[x].size());++i)
    {
        int y = adj[x][i];
        if(!done1[y])
        dfs(y);
    }
}*/
ll n;
vector<ll>v(3*maxn);

int main()
{
    thekingisborn;
    /*cin >> n;
    for(int i=0;i<(1<<n);++i)
    cin >> v[i];*/
    cin >> n;
    for(int i=0;i<n;++i)
    cin >> v[i];
    sort(v.begin(),v.begin()+n);
    cout << v[n-1]-v[0];
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
const int N=3e5+10;
using namespace std;
int n,m,c[N],ans;
struct Interval{
	int l,r;
	bool operator < (const Interval &x)const{return l>x.l;}
}a[N];
vector<int>G[N];
inline int lowbit(int x){return x&(-x);}
inline void add(int x,int val){for(int i=x;i<=m;i+=lowbit(i))c[i]+=val;}
inline int ask(int x){
	int ans=0;
	for(int i=x;i;i-=lowbit(i))ans+=c[i];
	return ans;
}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int main(){
	n=read();m=read();
	for(int i=1;i<=n;i++)a[i].l=read(),a[i].r=read(),G[a[i].r-a[i].l+1].push_back(a[i].l);
	int cur=n;
	for(int i=1;i<=m;i++){
		cur-=G[i-1].size();ans=cur;
		for(int j=0;j<G[i-1].size();j++)add(G[i-1][j],1),add(G[i-1][j]+i-1,-1);
		for(int j=i;j<=m;j+=i)ans+=ask(j);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 14336
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

string s;

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') cnt++;
  }
  if (cnt == 3) cout << 3 << E;
  else if (cnt == 1) cout << 1 << E;
  else if (cnt == 0) cout << 0 << E;
  else if (s[1] == 'R') cout << 2 << E;
  else cout << 1 << E;
  //system("pause");
  return 0;
}

Measured memory_bytes: 3648
from collections import deque
h,w,n = map(int,input().split())
factrys = [None] * (n + 1)
ss = ["X" * (w + 2)]
append = ss.append
for i in range(h):
  s = "X" + input() + "X"
  if "S" in s:
    factrys[0] = (i + 1, s.index("S"))
  for j in range(len(s)):
    if s[j] != 'S' and s[j] != '.' and s[j] != 'X':
      factrys[int(s[j])] = (i + 1, j)
  append(s)
append("X" * (w + 2))

def bfs(i):
  mp = [[None] * (w + 2) for j in range(h + 2)]
  x,y = factrys[i]
  mp[x][y] = 0
  que = deque()
  append = que.append
  popleft = que.popleft
  append((x, y))
  while True:
    (x,y) = popleft()
  #  print(i,x,y)
  #  print(mp[x][y])
    if (x,y) == factrys[i + 1]:
      return mp[x][y]
    count = mp[x][y]
    if ss[x + 1][y] != "X" and mp[x + 1][y] is None:
      mp[x + 1][y] = count + 1
      append((x + 1, y))
    if ss[x - 1][y] != "X" and mp[x - 1][y] is None:
      mp[x - 1][y] = count + 1
      append((x - 1, y))
    if ss[x][y + 1] != "X" and mp[x][y + 1] is None:
      mp[x][y + 1] = count + 1
      append((x, y + 1))
    if ss[x][y - 1] != "X" and mp[x][y - 1] is None:
      mp[x][y - 1] = count + 1
      append((x, y - 1))

ans = 0
for i in range(n):
  ret = bfs(i)
  if ret is None:
    ans += 0
  else:
    ans += (ret)
print(ans)


Measured memory_bytes: 28328
L,R=map(int,input().split())

min_val = 2019
flag = 1
for i in range(L, min(R,L+2019-1), 1):
  for j in range(i+1, min(R+1,L+2019), 1):
    tmp = (i*(j)) % 2019
    if tmp == 0:
      flag = 0
      break
    elif tmp < min_val:
      min_val = tmp
  if flag == 0:
    break
if flag == 0:
  print(0)
else:
  print(min_val)

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	ll a, b, diff, bn;
	cin >> a >> b;
	diff = b - a;
	bn = 0;
	for (int i = 1; i <= diff; i++) {
		bn += i;
	}
	cout << bn - b << endl;
}

Measured memory_bytes: 256
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  const int N = rint();
  const int K = rint();
  int a[N];
  dotimes(i, N)
    a[i] = rint();
  int r = 1e12;
  dotimes(k, 1 << (N - 1)) {
    int h = a[0];
    int c = 0, s = 0;
    dotimes(i, N - 1) {
      if ((k >> i) & 1) {
        c++;
        if (!maxs(h, a[i+1]))
          s += ++h - a[i+1];
      } else if (h < a[i+1])
        goto fail;
    }
    if (c >= K - 1)
      mins(r, s);
  fail:
    ;
  }
  wint(r);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  int dp[100001];
  REP(i, 100001) dp[i] = 1e9;
  REP(i, 100001) {
    if (i == 0) {
      dp[i] = 0;
    } else {
      dp[i] = min(dp[i], dp[i - 1] + 1);
    }
    for (int j = 6; i + j <= 100000; j *= 6) {
      dp[i + j] = min(dp[i + j], dp[i] + 1);
    }
    for (int j = 9; i + j <= 100000; j *= 9) {
      dp[i + j] = min(dp[i + j], dp[i] + 1);
    }
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void)


{


  int a,b,d=0,r=0;


  double f=0;


  scanf("%d %d",&a,&b);


  d=a/b;


  r=a%b;


  f=(double)a/(double)b;


  printf("%d %d %lf\n",d,r,f);


  return 0;


}

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

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    int * a = new int[n];
    int * b = new int[n];
    int * c = new int[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n - 1; i++)
        cin >> c[i];

    int ret = 0;
    for (int i = 0; i < n; i++)
    {
        ret += b[a[i] - 1];
        if (i > 0 && a[i] == a[i - 1] + 1)
        {
            ret += c[a[i - 1] - 1];
        }
    }
    cout << ret;

    delete[] a;
    delete[] b;
    delete[] c;
    return 0;
}


Measured memory_bytes: 3580
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
    int n,m,i,j,k,l,q,s=0;
   string s1;
   cin>>s1;
   if(s1=="Rainy")
    cout<<"Sunny";
   else if(s1=="Sunny")
    cout<<"Cloudy";
   else
   {
     cout<<"Rainy";
   }
  }

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            char[] date = in.next().toCharArray();
            date[3] = '8';
            out.println(String.valueOf(date));
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 21328
"use strict";

const fs = require("fs");

const input = fs.readFileSync(0).toString().trim().split("\n");
const a = input[0];
const b = input[1];
const result = [];
for (let i = 0, len = a.length; i < len; i++)
  result[i * 2] = a[i];
for (let i = 0, len = b.length; i < len; i++)
  result[i * 2 + 1] = b[i];
process.stdout.write(result.join("") + "\n");


Measured memory_bytes: 7244