akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef print
#define print(...)
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//const int mod=998244353;
const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }
int powm(int a, int b) { int res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int a[300000];
int dp[300000];
int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	std::map<int, int> mp;
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		dp[i] = dp[i - 1];
		if (mp.find(a[i]) != mp.end() && mp[a[i]] != i - 1)
			dp[i] = (dp[mp[a[i]]] + dp[i]) % mod;
		mp[a[i]] = i;
	}
	cout << dp[n] << '\n';
}

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

using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans=0;
  for(int i=0; i<=9; i++){
    for(int j=0; j<=9; j++){
      for(int k=0; k<=9; k++){
        bool num[3];
        num[0]=false, num[1]=false, num[2]=false;
        for(int l=0; l<N; l++){
          if(S[l]-'0'==k&&num[0]==true&&num[1]==true) num[2]=true;
          if(S[l]-'0'==j&&num[0]==true) num[1]=true;
          if(S[l]-'0'==i) num[0]=true;
        }
        if(num[0]==true&&num[1]==true&&num[2]==true) ans++;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

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

string is_stable(map<ll, string> a, map<ll, string> b, vector<ll> d){
    for(ll n : d) if(a[n] != b[n]) return "Not stable";
    return "Stable";
}

void print(P a[], ll n){
    rep(k, n) cout << a[k].first << ' ' << a[k].second << endl;
    return;
}

ll partition(P a[], ll p, ll r){
    ll x = a[r].second;
    ll i = p - 1;
    for(ll j = p; j < r; j++)
        if(a[j].second <= x) swap(a[++i], a[j]);
    swap(a[++i], a[r]);
    return i;
}

void quick_sort(P a[], ll p, ll r){
    if(p < r){
        ll q = partition(a, p, r);
        quick_sort(a, p, q-1);
        quick_sort(a, q+1, r);
    }
    return;
}

int main(){
    ll n; cin >> n;
    P a[n];
    map<ll, string> def;
    vector<ll> d;
    rep(i, n){
        string c; ll num;
        cin >> c >> num;
        a[i] = make_pair(c, num);
        if(def.find(num) == def.end()) def[num] = c;
        else def[num] += c;
        d.push_back(num);
    }

    quick_sort(a, 0, n-1);

    map<ll, string> bmap;
    rep(i, n){
        if(bmap.find(a[i].second) == bmap.end()) bmap[a[i].second] = a[i].first;
        else bmap[a[i].second] += a[i].first;
    }

    cout << is_stable(def, bmap, d) << endl;
    print(a, n);
    return 0;
}



Measured memory_bytes: 19192
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  cin>>s;
  int n=s.size();
  int l=0,r=n-1;
  int ans=0;
  while(l<r){
    if(s[l]==s[r])l++,r--;
    else if(s[l]=='x')ans++,l++;
    else if(s[r]=='x')ans++,r--;
    else{
      cout<<-1<<endl;
      return 0;
    } 
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>

using namespace std;

typedef long long ll;

#define MAX 100000

int main() {
    int Q;
    vector<int> ls, rs;
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int l, r;
        cin >> l >> r;
        ls.push_back(l);
        rs.push_back(r);
    }

    
    bool is_prime[MAX];
    fill(is_prime, is_prime + MAX, true);
    is_prime[0] = false;
    is_prime[1] = false;
    
    for (int i = 2; i < MAX; ++i)
        if (is_prime[i])
            for (int j = 2; i * j < MAX; j++)
                is_prime[i * j] = false;
    
    
    int like_20l7s[MAX];
    like_20l7s[0] = 0;
    for (int i = 1; i < MAX; ++i) {
        if (is_prime[i] && is_prime[(i + 1) / 2])
            like_20l7s[i] = like_20l7s[i - 1] + 1;
        else
            like_20l7s[i] = like_20l7s[i - 1];
    }
    
    
    for (int i = 0; i < Q; ++i) {
        int l = ls[i] - 1, r = rs[i];
        int ans = like_20l7s[r] - like_20l7s[l];
        printf("%d\n", ans);
    }

    return 0;
}


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

int k, t;
int m = 0;

int main() {
	cin >> k >> t;
	for (int i = 0; i < t; ++i) {
		int x; cin >> x;
		m = max(m, x);
	}
	// cout << m << endl;
	cout << max(0, 2*m-k-1) << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args:Array[String]):Unit = {
    for (line <- scala.io.Source.stdin.getLines() if line != "0 0") {
      val Array(h, w) = line.split(" ").map(_.toInt)
      for (i <- 1 to h; j <- 1 to w) {
        if ((i + j) % 2 == 0) {
          print("#")
        } else {
          print(".")
        }
        if (j == w) {
          println()
        }
      }
      println()
    }
  }
}

Measured memory_bytes: 56756
# -*- coding: utf-8 -*-
from collections import Counter

def pri(x):
    if x == 1:
        return print("YES")
    else:
        return print("NO")

S = list(input())

S.sort()
c = list(Counter(S).values())
if len(c) <= 2:
    for _ in range(3-len(c)):
        c.append(0)
c.sort(reverse = True)

if c[0] >= c[1] - 1:
    if c[2] >= c[0] - 1:
        pri(1)
    else:
        pri(0)
else:
    pri(0)

Measured memory_bytes: 4516
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()	
	{
		string S = GetString();
		int len = S.Length;
		while(len > 0)
		{
			if((len >= 5) && S.Substring(len - 5, 5).Equals("dream"))
			{
				len -= 5;
				continue;
			}
			else if((len >= 7) && S.Substring(len - 7, 7).Equals("dreamer"))
			{
				len -= 7;
				continue;
			}
			else if((len >= 5) && S.Substring(len - 5, 5).Equals("erase"))
			{
				len -= 5;
				continue;
			}
			else if((len >= 6) && S.Substring(len - 6, 6).Equals("eraser"))
			{
				len -= 6;
				continue;
			}

			Console.WriteLine("NO");
			return;	
		}
		Console.WriteLine("YES");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11860
#include<bits/stdc++.h> 
#define Re register
#define fo(i, a, b) for (Re int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (Re int i = (a); i >= (b); --i)
#define edge(i, u) for (Re int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 1000000007
#define mp std::make_pair
#define lowbit(x) (x & -x)
#define eps 1e-4
#define itset std::set<node>::iterator
#define lb lower_bound
#define N 1000005
#define M 4000005
int n, f[N][2], a[N], tmp[2];
int main ()
{
    char c;
    while (c != '\n')
    {
        c = getchar();
        if (isdigit(c)) a[++n] = (c == '1');
    }
    if (!a[1] || a[n]) {printf("-1"); return 0;}
    fo (i, 1, n - 1) if (a[i] ^ a[n - i]) {printf("-1"); return 0;}
    int last = 1;
    fo (i, 2, n)
        if (a[i])
        {
            fo (j, last, i - 1)
                printf("%d %d\n", i, j);
            last = i;
        }
    printf("%d %d\n", last, n);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int n,T,t[max_n];
int main(){
    scanf("%d%d",&n,&T);
    for(int i=1;i<=n;i++)scanf("%d",t+i);
    int ans=t[n]+T;
    for(int i=2;i<=n;i++){
        ans-=max(0,t[i]-(t[i-1]+T));
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
w = str(raw_input())

dic = {"def":0}
for s in w:
    if s in dic.keys():
        dic[s] += 1
    else:
        dic.update({s:1})

flag = 0

for value in dic.values():
    if value%2 == 0:
        pass
    else:
        flag = 1

if flag == 0:
    print "Yes"
else:
    print "No"


Measured memory_bytes: 2568
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

int main() {
	ll x, y;
	cin >> x >> y;
	if (x - 1 <= y && x + 1 >= y) wrln("Brown");
	else wrln("Alice");
	return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using vpint = vector<pint>;
using vpll = vector<pll>;
using sint = set<int32_t>;
using sstr = set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size())
    {
        if (s[i] == '+')
            ++ans;
        else
            --ans;
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1'000'000'007;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  int n, i2 = (P + 1) / 2;;
  cin >> n;
  vector<vector<int>> graph(n+1);
  for (int i = 1, p; i <= n; ++i) {
    cin >> p;
    graph[p].push_back(i);
  }
  function<deque<array<int, 2>>(int)> dfs = [&](int u) {
    deque<array<int, 2>> res;
    int z = 0;
    for (int v : graph[u]) {
      auto rhs = dfs(v);
      if (rhs.size() > res.size())
        swap(rhs, res);
      z = max(z, (int) rhs.size());
      for (int depth = 0; depth < (int) rhs.size(); ++depth) {
        res[depth][1] = ((int64_t) res[depth][1] * rhs[depth][0] + (int64_t) res[depth][0] * rhs[depth][1]) % P;
        res[depth][0] = (int64_t) res[depth][0] * rhs[depth][0] % P;
      }
    }
    for (int depth = 0; depth < z; ++depth)
      res[depth][0] = (1 + P - res[depth][1]) % P;
    res.push_front({i2, i2});
    return res;
  };
  int p2 = 1;
  for (int i = 0; i <= n; ++i)
    (p2 *= 2) %= P;
  int ans = 0;
  auto dp = dfs(0);
  for (auto d : dp)
    (ans += d[1]) %= P;
  cout << (int64_t) ans * p2 % P << '\n';
  return 0;
}


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

int main() {

	string s; cin >> s;
	bool ans = true;
	for (int i = 0; i < s.length(); i++) {
		if (i % 2 == 0 && s[i] == 'L') {
			ans = false;
			break;
		} else if (i % 2 == 1 && s[i] == 'R'){
			ans = false;
			break;
		}
	}
	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 256
n,q= map(int,input().split())
s = [0]+list(input())+[0]
td = [input().split() for _ in range(q)]
l,r = 0,n+1
for i,j in td[::-1]:
  if s[l+1]==i and j=='L':
    l+=1
  elif s[l]==i and j=='R':
    l-=1
  if s[r-1]==i and j=='R':
    r-=1
  elif s[r]==i and j=='L':
    r+=1
print(max(0,r-l-1))

Measured memory_bytes: 42252
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 23 12:24:26 2018

@author: natsukiiwano
"""
import numpy as np

_in_ = input().split(" ")
H,W,D = int(_in_[0]),int(_in_[1]),int(_in_[2])

px,py= np.zeros(90001),np.zeros(90001)
d=np.zeros(90001)
for i in range(H):
    _in_ = list(map(int,input().split(" ")))
    for j in range(W):
        px[_in_[j]]=i
        py[_in_[j]]=j

for i in range(D+1,H*W+1):
    d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D])

Q = int(input())
for i in range(Q):
    _in_ = input().split(" ")
    L,R = int(_in_[0]),int(_in_[1])
    print(int(d[R]-d[L]))

Measured memory_bytes: 16072
#include <stdio.h>
#include <stdlib.h>
int main() {
  int n,i,a[100001],diff[100000],x[2];
  long long sum=0;
  a[0]=0;
  scanf("%d",&n);
  for (i = 1;i <= n;i++) {
    scanf("%d",&a[i]);
    x[0]=abs(a[i]-a[i-1]);
    sum+=x[0];
    if (i!=1) {
      diff[i-2]=abs(a[i]-a[i-2])-x[0]-x[1];
    }
    x[1]=x[0];
  }
  sum+=abs(a[n]);
  diff[n-1]=abs(a[n-1])-x[1]-abs(a[n]);
  for (i = 0; i < n; i++) {
    printf("%lld\n",sum+diff[i]);
  }
  return 0;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for(i=0; i<strlen(str); ++i){
        sum += p*getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key){
    return key % M;
}

int h2(int key){
    return 1 + (key % (M-1));
}

int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i=0; ; ++i){
        h = (h1(key) + i*h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for(i=0; ; ++i){
        h = (h1(key) + i*h2(key)) % M;
        if(strcmp(H[h], str) == 0) return 1;
        else if(strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for(i=0; i<M; ++i) H[i][0] = '\0';
    scanf("%d", &n);
    for(i=0; i<n; ++i){
        scanf("%s %s", com, str);

        if(com[0] == 'i'){
            insert(str);
        }else {
            if(find(str)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17064
import java.util.Scanner;

class Main{
	public static void main(String[] args){
	int[] a = {1,3,5,7,8,10,12};
	int[] b = {4,6,9,11};
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(MySearch(a,x)==1 && MySearch(a,y)==1){
			System.out.println("Yes");
			return;
		}
		if(MySearch(b,x)==1 && MySearch(b,y)==1){
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
	public static int MySearch(int[] list,int x){
		int ans = 0;
		for(int i=0;i<list.length;i++){	
if(x==list[i]){
				ans = 1;
				break;
			}
		}
		return ans;
	}
}

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

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

    long long  n, w, w_arr[100], v_arr[100], dp[101][100001];
    cin >> n >> w;
    for (int i = 0; i < n; i++) {
        cin >> w_arr[i] >> v_arr[i];
    }
    for (long long i = 0; i <= n; i++) {
        for (long long j = 0; j <= w; j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            }
            else if (w_arr[i-1] <= j) {
                dp[i][j] = max(dp[i-1][j-w_arr[i-1]] + v_arr[i-1], dp[i-1][j]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[n][w];
    return 0;
}


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

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

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

    if(n == k){
        cout << 1 << endl;
        return 0;
    }

    if(n < k * 2){
        cout << 2 << endl;
        return 0;
    }

    /*
    bool f = false;
    REP(i, k){
        if(A[i] == 1){
            f = true; 
            break;
        }
    }
    if(!f){
        for(int i = n - 1; i >= n - k; i--){
            if(A[i] == 1){
                f = true;
                break;
            }
        }
    }
    */

    if(k == 2){
        cout << n - 1 << endl;
        return 0;
    }

    if(true){
        n -= k;
        cout << (n + (k - 2)) / (k - 1) + 1 << endl;
        return 0;
    }

    int ans = (n + k + k - 1) / k;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
A = [list(map(int, input().split())) for _ in range(3)]
C = A.copy()
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                C[i][j] = -1
flag = False
# 縦
for i in range(3):
    if C[i][0] == C[i][1] == C[i][2] == -1:
        flag = True

# 横
for i in range(3):
    if C[0][i] == C[1][i] == C[2][i] == -1:
        flag = True

# 斜め
if C[0][0] == C[1][1] == C[2][2] == -1:
    flag = True
if C[0][2] == C[1][1] == C[2][0] == -1:
    flag = True

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n, m = map(int, input().split())
wa = [0] * (n+1)
ac = [0] * (n+1)

for _ in range(m):
    p, s = input().split()
    if (not ac[int(p)]) and s == 'WA':
        wa[int(p)] += 1
    elif s == 'AC':
        ac[int(p)] = 1
sw = 0
for i in range(n+1):
    sw += ac[i] * wa[i]
print(sum(ac), sw)


Measured memory_bytes: 4596
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


int f(int a){
	if(a==1) return 0;
	for(int i=2;i<=sqrt((double)a);i++){
		if(!(a%i)){
			return 0;
		}
	}
	return 1;
}
bool solve(){
	int n;
	int nmax=0;
	vector<int> k;
	while(cin>>n){
		k.push_back(n);
		if(nmax<n) nmax = n;
	}
	
	vector<int> res(nmax+1);
	int cnt=0;
	for(int j=2;j<=nmax;j++){
		cnt += f(j);
		res[j] = cnt;
	}	
	for(int i=0;i<k.size();i++){
		cout<< res[k[i]]<< endl;
	}
		
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

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

using namespace std;

int main(){
    int s;
    int hour ;
    int min ;
    int second;

    cin >> s;
    hour = s / 3600;
    s = s - (hour * 3600);
    min = s / 60;
    s = s -(min * 60);
    second = s;
    cout << hour << ":" << min << ":" << second << endl;    
    return 0;
}


Measured memory_bytes: 3088
//09
#include<iostream>

using namespace std;

int main(){
  for(int n,a,b,c,x;cin>>n>>a>>b>>c>>x,n|a|b|c|x;){
    int t=0;
    int y[10000];
    for(int i=0;i<n;i++){
      cin>>y[i];
    }
    for(int i=0;;){
      while(t<=10000&&x!=y[i]){
	x=(a*x+b)%c;
	t++;
      }
      i++;
      if(!(i<n))break;
      x=(a*x+b)%c;
      t++;
    }
    cout<<((t<=10000)?t:-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,taka,aoki;
    cin>>n>>taka>>aoki;
    taka--;
    aoki--;
    int a[n-1],b[n-1];
    vector<vector<int>>pas(n);
    for(int i=0;i<n-1;i++){
        cin>>a[i]>>b[i];
        pas[a[i]-1].push_back(b[i]-1);
        pas[b[i]-1].push_back(a[i]-1);
    }
    queue<int>q;
    q.push(aoki);
    int check[n]={};
    check[aoki]=1;
    int root[n];
    while(q.front()!=taka){
        int f=q.front();
        q.pop();
        for(int i=0;i<pas[f].size();i++){
            if(check[pas[f][i]]==0){
                check[pas[f][i]]=1;
                q.push(pas[f][i]);
                root[pas[f][i]]=f;
            }
        }
    }
    vector<int>l;
    int p=taka;
    for(int i=0;i<n;i++)check[i]=0;
    while(p!=aoki){
        l.push_back(p);
        check[p]=1;
        p=root[p];
    }
    check[aoki]=1;
    int dist=l.size();
    int m=dist/2;
    for(int i=0;dist>0;i++){
        int md;
        queue<pair<int,int>>qu;
        qu.push({l[i],i});
        while(qu.size()){
            int f=qu.front().first;
            int d=qu.front().second;
            md=d;
            for(int j=0;j<pas[f].size();j++){
                if(check[pas[f][j]]==0){
                    check[pas[f][j]]=1;
                    qu.push({pas[f][j],d+1});
                }
            }
            qu.pop();
        }
        m=max(m,md+dist-1);
        dist-=2;
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  string s;std::cin >> s;
  ll p = 998244353;
  set<ll> a, b, c;
  std::vector<ll> A, B, C;
  for(int i=0;i<3*n;i++){
    if(s[i]=='R') a.insert(i);
    if(s[i]=='G') b.insert(i);
    if(s[i]=='B') c.insert(i);
  }
  for(int i=0;i<n;i++){
    ll x = *a.begin(); a.erase(a.begin());
    ll y = *b.begin(); b.erase(b.begin());
    ll z = *c.begin(); c.erase(c.begin());
    vll v{x, y, z};
    sort(v.begin(), v.end());
    A.push_back(v[0]);B.push_back(v[1]);C.push_back(v[2]);
  }
  ll ans = 1;
  ll now = 0;
  for(int i=0;i<n;i++){
    ll t = upper_bound(A.begin(), A.end(), B[i]) - A.begin() - now;
    ans = (ans * t)%p;
    now++;
  }
  now = 0;
  for(int i=n-1;i>=0;i--){
    ll t = n - (upper_bound(C.begin(), C.end(), B[i]) - C.begin()) - now;
    ans = (ans * t)%p;
    now++;
  }
  for(int i=1;i<=n;i++) ans = (ans * i)%p;
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
	int N, K, X, Y;
	
	cin >> N >> K >> X >> Y;
	
	if(N <= K) {
		cout << X*N;
	}
	else if(N > K) {
		N = N - K;
		int sum = K*X + N*Y;
		cout << sum;
	}
	
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,m,p,q,l,r,a,b,ans=100001;
    vector<int>d;
    cin>>n>>m>>p;
    for(int i=0;i<m;i++){
        cin>>q;
        d.push_back(q);
    }
    d.push_back(p);
    sort(d.begin(),d.end());
    for(int i=0;i<=m;i++){
        q=d[i];
        a=(i-1+m+1)%(m+1);
        b=(i+1+m+1)%(m+1);
        l=(p-q+n)%n*2+(d[a]-p+n)%n;
        r=(q-p+n)%n*2+(p-d[b]+n)%n;
        ans=min(ans,min(l,r));
    }
    cout<<ans*100<<endl;
}

Measured memory_bytes: 1324
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
int main() {
    string s,t;
    cin >> s;
    cin >> t;
    if (s==t.substr(0,t.length()-1) && s.length()+1 == t.length()) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var prices = Enumerable.Range(0, 4).Select(i => int.Parse(Console.ReadLine())).ToArray();
            Console.WriteLine(Math.Min(prices[0], prices[1]) + Math.Min(prices[2], prices[3]));
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    ll M;
    cin >> N >> M;
    ll A[100001]={};
    A[0]=0;
    for(int i=1; i<=N; i++){
        cin >> A[i];
    }
    
    for(int i=1; i<=N; i++){
        A[i]+=A[i-1];
        A[i]%=M;
    }
    
    sort(A,A+N+1);
    
    ll ans=0;
    
    ll cnt=1;
    for(int i=1; i<=N; i++){
        if(A[i]==A[i-1]){
            cnt++;
        }else{
            ans +=  cnt*(cnt-1) / 2;
            cnt=1;
        }
    }
    
    ans += cnt*(cnt-1) / 2 ;
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let t, o = Array.fold_left (fun (t, o) a -> t * 3 , o * if a mod 2 = 0 then 2 else 1) (1, 1) a_s
let _ = t - o |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	vvl cnt(n+1,vl(3,0));
	map<char,int> mp;
	mp['R'] = 1; mp['G'] = 2; mp['B'] = 3;
	for(ll i=n-1; i>=0; i--){
		rep(j,3){
			cnt[i][j] += cnt[i+1][j];
			if(j==mp[s[i]]-1) cnt[i][j]++;
		}
	}
	ll ans = 0;
	rep(i,n-2){
		REP(j,i+1,n-1){
			if(s[i]==s[j]) continue;
			ans += cnt[j+1][(mp[s[i]]^mp[s[j]])-1];
			if(2*j-i < n && s[2*j-i] != s[j] && s[2*j-i] != s[i]) ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


void dfs(vvi g,int v, int &time,vb &seen,vi &first_time,vi &last_time) {
  first_time[v]=++time;
  seen[v]=true;
  for(auto next_v:g[v]) {
    if(seen[next_v]) continue;
    dfs(g,next_v,time,seen,first_time,last_time);
  }
  last_time[v]=++time;
}

int main() {
  int n;
  cin >> n;
  vvi G(n);
  REP(i,n) {
    int a;
    cin >> a;
    a--;
    int k;
    cin >> k;
    REP(j,k) {
      int b;
      cin >> b;
      b--;
      G[a].push_back(b);
    }
  }
  int time=0;
  vb seen(n,false);
  vi first_time(n,1);
  vi last_time(n,1);
  REP(i,n) {
    if(seen[i]) continue;
    dfs(G,i,time,seen,first_time,last_time);
  }
  REP(i,n) {
    cout << i+1 << " " << first_time[i] << " " << last_time[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    string a, b;
    cin >> a >> b;
    a += b[sz(b) - 1];
    cout << (a == b ? "Yes" : "No") << '\n';
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 3776
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    
    cout << ((abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  sort(a.rbegin(), a.rend());
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += a[i / 2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3980
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
s = S()
last = s[-1]
lis = [s]
for i in range(n-1):
    s = S()
    if s in lis or s[0] != last:
        print("No")
        exit()
    else:
        last = s[-1]
        lis.append(s)
print("Yes")

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int A[1000000], n;

int binary(int key){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main()
{
  int i, q, a=0, k;

  scanf("%d", &n);  
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }

   scanf("%d", &q);  
  for(i=0;i<q;i++){
    scanf("%d", &k);
    if(binary(k)) a++;
  }
  printf("%d\n", a);

  return 0;
}



Measured memory_bytes: 2188
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int maxn = 100001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


int main()
{
    fast;
    ll n,k;
    cin>>n>>k;
    ll a[k];
    for(ll i=0;i<k;i++)
    {
        cin>>a[i];
    }
    
    ll mx = a[k-1]-a[0];
    
    for(int i=1;i<k;i++)
    {
        ll x = n-(a[i]-a[i-1]);
        mx = min(mx,x);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 1792
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
LL a[202020];
int cnt[21][202020];

int main() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		REP(j, 21) {
			cnt[j][i + 1] += cnt[j][i];
			if (1 << j&a[i])cnt[j][i + 1]++;
		}
	}
	LL ans = 0;
	REP(i, n) {
		LL num = n;
		REP(j, 21) {
			num = min(lower_bound(cnt[j] + i, cnt[j] + n + 1, cnt[j][i] + 2) - cnt[j] - i - 1, num);
		}
		ans += num;
	}
	cout << ans << endl;
}

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

struct Node{
  int key;
  struct Node *next,*pre;
};

struct Node *n;

struct Node* lserch(int key){
  struct Node *cur=n->next;
  while(cur != n && cur->key != key){
    cur=cur->next;
  }
  return cur;
}

void init() {
  n=(struct Node *)malloc(sizeof(struct Node));
  n->next=n;
  n->pre=n;
}

void list() {
  struct Node *cur = n->next;
  int is=0;
  while (1) {
    if(cur==n) break;
    if(is++ > 0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void delete(struct Node *t){
  if(t==n) return;
  t->pre->next = t->next;
  t->next->pre = t->pre;
}

void delete2(){
  delete(n->next);
}

void delete3(){
  delete(n->pre);
}

void deletekey(int key){
  delete(lserch(key));
}

void insert(int key){
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->key=key;
  x->next=n->next;
  n->next->pre=x;
  n->next=x;
  x->pre=n;
}

int main(int argc, char const *argv[]) {
  int key,n,i;
  int size=0;
  char s[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for (i = 0; i < n; i++) {
    scanf("%s%d",s,&key);
    if(s[0]=='i'){
      insert(key);
      np++;
      size++;
    }else if(s[0]=='d'){
      if(strlen(s)>6){
        if(s[6]=='F') delete2();
        else if(s[6]=='L')delete3();
      }else{
        deletekey(key);
        nd++;
      }
      size--;
    }
  }
  list();
  return 0;
}

Measured memory_bytes: 34976
#include <iostream>
#include<string>
#include<stdio.h>
using namespace std;
int main()
{
	long long int s,c;
	
	cin >> s>> c;
	if (s >= c / 2)cout << c / 2;
	else {
		cout << (c - s * 2) / 4 + s;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
        String s="";
        while(in.hasNext()) s+=in.nextLine();
        s=s.toLowerCase();
		char[] a={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
        for(char c:a){
        	int r=0;
        	for(int i=0;i<s.length();i++){
            	if(s.charAt(i)==c) r+=1; 
        	}
        	System.out.println(c+" : "+r);
        }
	}
}

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

int main(){
    long N,T;
    cin >> N >> T;
    vector<long> t(N);
    vector<long> t2(N-1);
    long ans = 0;
    for(long i = 0; i < N;i++){
        cin >> t.at(i);
    }
    for(long i = 0;i<N-1;i++){
        t2.at(i) = t.at(i+1)-t.at(i);
        if(t2.at(i) < T){
            ans = ans + T - t2.at(i);
        }
    }
    cout << N*T - ans << endl;
    
}


Measured memory_bytes: 3328
import java.io.*;
import java.util.*;

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


  int a = scan.nextInt();
  int b = scan.nextInt();

  if(a < b){
    System.out.println("a < b");
  }else if(a > b) {
    System.out.println("a > b");
  }else if(a == b){
    System.out.println("a == b");
  }
}
}

Measured memory_bytes: 26296
import java.util.Scanner;

public class Main {
	
	static boolean[] primes;
	static int call=0;
	
	static void primeSet(final int MAX){
		if(call>=MAX){
			return;
		}
		primes = new boolean[MAX+1];
		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

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

		while(true){

			int n = stdIn.nextInt();
			
			if(n==0)
				return;
			
			primeSet(n+100);

			int a=0;
			for(int i=n;;i--){
				if(primes[i]){
					a=i;
					break;
				}
			}
			for(int i=n;;i++){
				if(primes[i]){
					System.out.println(i-a);
					break;
				}
			}
		}
	}
}

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

int INF = 1'000'000'000;

int n, m;
vector<vector<int>> edge(1000);

vector<int> dfs(int u){
    vector<int> dist(n, INF);
    vector<int> pre(n, - 1);
    queue<int> q;
    q.push(u); dist[u] = 0;
    while (q.size()){
        int x = q.front(); q.pop();
        for (int i = 0; i < edge[x].size(); i++){
            if (dist[edge[x][i]] != INF) continue;
            dist[edge[x][i]] = dist[x] + 1;
            pre[edge[x][i]] = x;
            q.push(edge[x][i]);
        }
    }
    pair<int, int> x = {INF, - 1};
    for (int i = 0; i < n; i++){
        if (i == u) continue;
        for (int j = 0; j < edge[i].size(); j++){
            if (edge[i][j] == u){
                x = min(x, {dist[i], i});
            }
        }
    }
    if (x.first == INF) {
        vector<int> ans(n + 1);
        return ans;
    }
    vector<int> ans;
    int y = x.second;
    while (1){
        ans.push_back(y);
        y = pre[y];
        if (y == - 1) break;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

int main(){
    cin >> n >> m;
    int a, b;
    for (int i = 0; i < m; i++){
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
    }
    vector<int> ans(n + 1);
    vector<int> tmp;
    for (int i = 0; i < n; i++){
        tmp = dfs(i);
        if (tmp.size() < ans.size()) ans = tmp;
    }
    if (ans.size() == n + 1) cout << - 1 << endl, exit(0);
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << endl;
}

Measured memory_bytes: 384
number, base = map(int, input().split())
devision = number
list = []
while(devision>=base):
    surplus = devision % base
    devision = int(devision / base)
    #print(devision, surplus)
    list.insert(0,surplus)
    #print(list)
list += [devision]
#print(list)
print(len(list))

Measured memory_bytes: 3060
import java.util.*;


public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	class Pair{
		int a;
		int b;
		Pair(int a,int b){
			this.a=a;
			this.b=b;
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();

		long abit[] = new long[40];
		long bbit[] = new long[40];
		long ansb[] = new long[40];
		setbit(abit, Math.max(0, a-1));
		setbit(bbit, Math.max(0, b));

		for(int i=0; i<40; i++) {
			ansb[i]=(bbit[i]-abit[i])%2;
		}
		long ans = 0;
		for(int i=0; i<40; i++) {
			ans += ansb[i]<<i;
		}
		System.out.println(ans);
		sc.close();
	}


	private void setbit(long bit[], long x) {

		long wk = x;
		for(int i=39; i>=0; i--) {
			if(((x>>i) & 1) == 1) {
				bit[i]++;
				bit[i] += wk-(1L<<i);

				for(int j=0; j<i; j++) {
					bit[j] += 1L<<i-1;
				}

				wk &= ~(1L<<i);
			}

		}
	}
}


Measured memory_bytes: 21844
#include <iostream>

int main(){
    double x,y,r,W,H;
    double a,b,c,d;
    std::cin >> W >> H >> x >> y >> r;

    a=x-r;
    b=x+r;
    c=y-r;
    d=y+r;

    if(a>=0 && b<=W && c>=0 &&d<=H) {
      std::cout << "Yes" << std::endl; 
    } 
    else{
      std::cout << "No" << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3224
import sys
from bisect import bisect_left,bisect,bisect_right

icase=0
if icase==0:
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    d=[]
    cb=[[0]*2 for i in range(m)]
    for i in range(m):
        bi,ci=map(int,input().split())
        cb[i]=[ci,bi]
elif icase==2:
    n,m=10,3
    a=[1, 4, 5, 5, 7, 8, 13, 33, 52, 100]
    cb=[[30, 4], [10, 3], [4, 1]]

a.sort()
cb.sort(reverse=True)
    
asum=0
isum=0
isumm=0
for i in range(m):
    isum+=cb[i][1]
    if isum>n:
        if a[n-1]<=cb[i][0]:
            asum+=cb[i][0]*(n-isumm)
            print(asum)
            sys.exit()
        else:
            ii=bisect_right(a,cb[i][0])
            asum+=cb[i][0]*(ii-isumm)
            asum+=sum(a[ii:])
            print(asum)
            sys.exit()
    if a[isum-1]<=cb[i][0]:
        asum+=cb[i][0]*cb[i][1]
        isumm=isum
        continue
    else:
        ii=bisect_right(a,cb[i][0])
        asum+=cb[i][0]*(ii-isumm)
        asum+=sum(a[ii:])
        print(asum)
        sys.exit()
    
asum+=sum(a[isum:])
        
print(asum)


Measured memory_bytes: 28404
#include<stdio.h>
#define NIL -1
int rec(int,int);

typedef struct{
  int p,l,r;/* 親、左、右 */
}N;
N T[100000];
int n,D[100000];

int main()
{
  int i,j,d,v,c,l,r;
  int children; /* 子 */
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) T[v].l = c;
      else T[l].r = c;
      l=c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p == NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("depth = %d, ",D[i]);

    if(T[i].p == NIL) printf("root, ");
    else if(T[i].l == NIL) printf("leaf, ");
    else printf("internal node, ");
  
    printf("[");
    for(j=0,children=T[i].l  ;   children!=NIL   ; j++,children=T[children].r){
      if(j!=0) printf(",");
      if(j>0) printf(" ");
      printf("%d",children);
    }
    printf("]");
    printf("\n");
  }
  return 0;
}

/* 再帰 */
int rec(int u,int p){
  D[u]=p;
  if(T[u].r != NIL) rec(T[u].r,p); /* 右の兄弟に同じ深さを設定 */
  if(T[u].l != NIL) rec(T[u].l,p+1); /* 最も左の子に自分の深さ＋１を設定 */
}

		
       
  



Measured memory_bytes: 6372
import sys

l, r = [ int(x) for x in sys.stdin.readline().split() ]

lm = l % 2019

if lm + (r-l)>=2019:
    print(0)
    exit(0)
#
ans= 2019
rm= r % 2019 + 1
for i in range(lm,rm):
    for j in range(i+1,rm):
        ij = ( i * j ) % 2019
        if ij<ans: ans= ij
#
print( ans )

Measured memory_bytes: 3064
#include <stdio.h>

int solve(int,int);

int A[2000],n;

int main(){
  int i,m;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&m);
  int M[m];
  for(i=0;i<m;i++){
    scanf("%d",&M[i]);
    if(solve(0,M[i]))printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


int solve(int i,int m){
  int a;

  if(m == 0) return 1;
  if(i >= n) return 0;

 a = solve(i+1,m) || solve(i+1,m-A[i]);
  
  return a;
}

  
  

Measured memory_bytes: 580