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

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

  int ans = 0;

  for (int i = 0; i < 1000; i++) {
    string A = S;
    string B = to_string(i);
    while (B.size() < 3) B = '0' + B;

    int j = (int)A.find(B.at(0));
    if (j == -1) continue;
    A = A.substr(j + 1);

    j = (int)A.find(B.at(1));
    if (j == -1) continue;
    A = A.substr(j + 1);

    j = (int)A.find(B.at(2));
    if (j > -1) ans++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 384
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M) = nextIntList()
    val G = Graph(N)
    repeat(M) {
        val (a, b) = nextIntList()
        G.addEdge(a, b)
        G.addEdge(b, a)
    }
    val ans = G.countBridge()
    println(ans)
}

class Graph(private val v: Int) {
    private val vec = Array(v + 1) { mutableListOf<E>() }

    fun addEdge(a: Int, b: Int, c: Long = 0L) {
        vec[a].add(E(b, c))
    }

    fun neighborsOf(v: Int) = vec[v].map(E::v).toTypedArray()

    fun countBridge(): Int {
        val ord = IntArray(v + 1) { 0 }
        val low = IntArray(v + 1) { Int.MAX_VALUE }
        countBridge(0, 1, 1, ord, low)
        return (1..v).count { ord[it] == low[it] } - 1
    }

    private fun countBridge(pre: Int, cur: Int, step: Int, ord: IntArray, low: IntArray): Int {
        ord[cur] = step
        low[cur] = step
        neighborsOf(cur).forEach { next ->
            if (next == pre) return@forEach
            if (ord[next] != 0) {
                low[cur] = Math.min(low[cur], low[next])
            } else {
                low[cur] = Math.min(low[cur], countBridge(cur, next, step + 1, ord, low))
            }
        }
        return low[cur]
    }

    data class E(val v: Int, val c: Long)
}

Measured memory_bytes: 37860
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Enu = System.Linq.Enumerable;

class Program
{
    const int MaxN = (int)1e6;
    bool[] isPrime = new bool[MaxN + 1];
    int[] count = new int[MaxN + 1];

    void Sieve()
    {
        for (int i = 2; i <= MaxN; i++) isPrime[i] = true;
        for (int i = 2; i * i <= MaxN; i++)
        {
            if (!isPrime[i]) continue;
            for (int j = i + i; j <= MaxN; j += i) isPrime[j] = false;
        }
        for (int i = 2; i <= MaxN; i++) count[i] = count[i - 1] + (isPrime[i] ? 1 : 0);
    }

    void Solve()
    {
        Sieve();
        while (reader.HasNext())
        {
            int N = reader.Int();
            Console.WriteLine(count[N]);
        }
    }

    static void Main() { new Program().Solve(); }
    static Reader reader = new Reader(Console.In);
    class Reader
    {
        private readonly TextReader reader;
        private readonly char[] splitter = new char[] { ' ' };
        private string[] s = new string[0];
        private int i;
        public Reader(TextReader r) { reader = r; }
        public bool HasNext() { return Enqueue(); }
        public string String() { return Dequeue(); }
        public int Int() { return int.Parse(Dequeue()); }
        public long Long() { return long.Parse(Dequeue()); }
        public double Double() { return double.Parse(Dequeue()); }
        public int[] IntArray() { return Array.ConvertAll(Line().Split(), int.Parse); }
        public int[][] IntGrid(int H) { return Enumerable.Range(0, H).Select(i => IntArray()).ToArray(); }
        public string[] StringArray(int N) { return Enumerable.Range(0, N).Select(i => Line()).ToArray(); }
        public string Line() { return reader.ReadLine().Trim(); }
        private bool Enqueue()
        {
            if (i < s.Length) return true;
            string line = reader.ReadLine();
            if (string.IsNullOrEmpty(line)) return false;
            s = line.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return true;
        }
        private string Dequeue() { Enqueue(); return s[i++]; }
    }
}

Measured memory_bytes: 10444
antenna = [int(input()) for i in range(5)]
k = int(input())

for i in range (5):
    for j in range (5):
        if i == j:
            pass
        else:
            if abs(antenna[i] - antenna[j]) > k:
                print (":(")
                exit()
            else:
                pass

print ("Yay!")

Measured memory_bytes: 3060
from collections import defaultdict

def dfs(res, depth, path, adj_list, visited):
    if path in visited:
        return
    elif depth == 1:
        res[0]+=1
        return
    for node in adj_list[path]:
        dfs(res, depth-1, node, adj_list, visited+[path])  

N, M = map(int, input().split())
adj_list = defaultdict(list)
for i in range(M):
    a, b = map(int, input().split())
    adj_list[a].append(b)
    adj_list[b].append(a)

res = [0]
for node in adj_list[1]:
    dfs(res, N-1, node, adj_list, [1])
print(res[0])


Measured memory_bytes: 3316
s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]

if a==b==c==d:
  print("No")
elif a==b and c==d:
  print("Yes")
elif a==c and b==d:
  print("Yes")
elif a==d and b==c:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int n;
    cin >> n;
    vector<LL> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vector<LL> ans(n, 0);

    ans[0] = a[0];
    for (int j = 1; j < n; j++) {
        if (j % 2 == 0) {
            // plus
            ans[0] += a[(0 + j) % n];
        } else {
            // minus
            ans[0] -= a[(0 + j) % n];
        }
    }
    a[0] -= ans[0] / 2;
    for (int i = 1; i < n; i++) {
        ans[i] = 2 * (a[i - 1]);
        a[i] -= ans[i] / 2;
    }
    rep(i, n) {
        if (i == n - 1) {
            cout << ans[i] << endl;
        } else {
            cout << ans[i] << " ";
        }
    }
    return 0;
}


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

int main(){
	
	int n;
	double m;
	
	cin >> n >> m;
	
	double ans = 0;
	
	int a[n];
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		ans+=a[i];
	}
	
	sort(a, a + n, greater<int>());
	
	bool ok = true;
	
	for (int i = 0; i < m; i++){
	//	cout << a[i] << " ";
	//	cout << (1/(4*m)) * ans;
		if (a[i] < 1/(4*m) * ans){
			ok = false;
		}
	}
	
	if (ok){
		cout << "Yes";
	} else {
		cout << "No";
	}
}

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

int main() {
	// your code goes here
	string s = "";
	cin>>s; int count = 1; int tount = 0;
for(int i = 0;i<2;i++)
{
    if(s[i] == 'R'&&s[i+1]=='R')
       count++;
    else if(s[i]=='S')
      tount++;
}  if(s[2]=='S')
    tount++;
if(tount==2)
 cout<<1<<endl;
 else if(tount == 3)
 {
     cout<<0<<endl;
 }
 else
 {
     cout<<count<<endl;
 }
	return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

int main(){
	int n,m;sc(n),sc(m);
	int ans=n*3+m;
	pr(ans/2,'\n');
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

ll dp[100010];

int main(){
    int k;
    cin >> k;
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
    pq.push(MP(1,1));
    while(!pq.empty()){
        auto xxx = pq.top();
        pq.pop();
        int x = xxx.first;
        int y = xxx.second;
        if(dp[y]==0){
            dp[y] = x;
            if(dp[10*y%k]==0){
                pq.push(MP(x,10*y%k));
            }
            if(dp[(y+1)%k]==0){
                pq.push(MP(x+1,(y+1)%k));
            }
        }
    }
    cout <<dp[0] << endl;
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<stdio.h>

int main(){
    using namespace std;
    int n;
    cin >> n;
    long  sum=0;
    int Min,Max;
    int num;
    for(int i=0; i<n; i++){
        if (i==0){
            cin>>num;
            Max = num;
            Min = num;
            

        }
        else{
            cin>>num;
            Max = max(Max,num);
            Min = min(Min,num);
        }

        sum += num;
    }
    cout<<Min<<" "<<Max<<" "<<sum<<"\n";
}


Measured memory_bytes: 3116
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    S = input()[:-1]
    N = len(S)
    C = Counter(S)
    ans = 0
    for v in C.values():
        ans += v*(v-1)//2
    print(N*(N-1)//2-ans+1)


solve()


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

int main(){
  int a, b;
  char op;
  while(cin >> a >> op >> b){
  //;
  if(op == '+'){
    cout << a+b << "\n";
  }else if(op == '-'){
    cout << a-b << "\n";
    }else if(op == '*'){
    cout << a*b << "\n";
    }else if(op == '/'){
    cout << a/b << '\n';
  }else{
      break;
  }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	if(s[s.size() - 1] == 's')
		s += "es";
	else
		s += 's';
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int main(){
	ll n;
	cin >> n;
	cout << n*(n-1)/2 << endl;
 	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    ll h,w,k;cin>>h>>w>>k;
    vvll dp(h+1,vll(w));
    dp[0][0]=1;
    bool can;ll x,y,z;
    rep(i,h)rep(j,w){
        x=0;y=0;z=0;
        rep(k,1<<(w-1)){
            bitset<8> tmp(k);
            can=true;
            rep(l,w-1){
                if(tmp[l]&&tmp[l+1]){
                    can=false;
                    break;
                }
            }
            if(can){
                if((j==0||(j>0&&!tmp[j-1]))&&(j==w-1||(j<w-1&&!tmp[j])))x++;
                if(j>0&&tmp[j-1])y++;
                if(j<w-1&&tmp[j])z++;
            }
        }
        dp[i+1][j]+=dp[i][j]*x;dp[i+1][j]%=inf;
        if(j>0){
            dp[i+1][j-1]+=dp[i][j]*y;dp[i+1][j-1]%=inf;
        }
        if(j<w-1){
            dp[i+1][j+1]+=dp[i][j]*z;dp[i+1][j+1]%=inf;
        }
    }
    cout<<dp[h][k-1]<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a==k)
    {
        cout<<a<<endl;
    }
    else if(a>k)
    {
        cout<<k<<endl;
    }
    else if(a+b>=k)
    {
        cout<<a<<endl;
    }
    else if(a+b<k)
    {
        cout<<a+(k-(a+b))*(-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int gcd = gcd(a, b);
            int lcm = a / gcd * b / gcd * gcd;
            System.out.println(gcd + " " + lcm);
        }
        
    }
    public static int gcd(int a, int b){
       if(a % b == 0){
           return b;
       }else{
           return gcd(b, a % b);
       }
    }
}


Measured memory_bytes: 25920
Mod = 10**9 + 7

n,m,k = map(int,input().split())

inv = [0]*(k+3)
inv[1] = 1
for i in range(2,k+2):
  # print(i)
  inv[i] = ((Mod-Mod//i) * inv[Mod%i]) % Mod


s = (n*n*(m+1)*m*(m-1) + m*m*(n+1)*n*(n-1))//6
for i in range(k-2):
   s = (s*(n*m-2-i)*inv[i+1])%Mod
print(s)

Measured memory_bytes: 12944
count_num = int(input())
a = map(int, input().split())
num_list = list(a)

num_list.sort(reverse=True)
max_num = num_list.pop(0)

sum_left_num = 0

for i in num_list:
    sum_left_num += i

if max_num < sum_left_num:
    print('Yes')
else:
    print('No')

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

const ll INF = 1LL << 62;

int main() {
  int H, N;
  std::cin >> H >> N;

  std::vector<int> A(N), B(N);
  rep(i, N) {
    std::cin >> A[i] >> B[i];
  }

  std::vector<std::vector<ll>> dp(N + 1, std::vector<ll>(H + 1, INF));
  rep(i, N + 1) {
    dp[i][0] = 0;
  }

  rep(i, N) {
    for(int j = 1; j <= H; ++j) {
      dp[i + 1][j] = std::min(dp[i][j], dp[i + 1][std::max(0, j - A[i])] + B[i]);
    }
  }

  std::cout << dp[N][H] << '\n';
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    sort(a.begin(), a.end());
    int n = a[a.size() - 1];
    a.pop_back();
    int r = a[0];
    rep(i, a.size()) if (abs((n + 1) / 2 - r) > abs((n + 1) / 2 - a[i])) r = a[i];

    cout << n << " " << r << endl;
}


Measured memory_bytes: 640
if __name__ == '__main__':
    a = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
    k = int(input())
    s = a.split(",")
    print(int(s[k-1]))




Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double dis;
    dis = sqrt(pow((x1-x2), 2.0) + pow((y1-y2), 2.0));
    cout << fixed << setprecision(10) << dis << endl;
}


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

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

	vector<int> vec(N + 1);

	for (int i = 0; i < N; i++) {
		if (S.at(i) == 'I')
			vec.at(i + 1) = vec.at(i) + 1;
		else
			vec.at(i + 1) = vec.at(i) - 1;
        
	}

	sort(vec.begin(), vec.end());
  
	cout << vec.at(N) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var s = ReadText().ToList();
            return s.Sum(x => int.Parse(x.ToString()));
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28228
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const ll max_co = 3234600000;
vl ans;
int mod =1000000007;
int main(){
   int n,X;
   cin>>n>>X;
   vi x(n);
   rep(i,n){
       int y;
       cin>>y;
       x[i]=abs(y-X);
   }
   int v = x[0];
   rep(i,n){
       v = __gcd(v,x[i]);
   }
   cout<<v<<endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i= 0; i <b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int Sugar(int Maxsugar, int C, int D) {
	int s = Maxsugar;

	int ans = 0;
	for (int i = 0; i <= s / C; i++) {
		int tmp = (s - C * i) / D * D;
		tmp += C * i;
		ans = max(ans, tmp);
	}
	return ans;
}

int main() {
	int i, j, k;

	int N, M, K;

	int dp[3001] = { 0 };

	int A, B, C, D;
	int a, b, c, d;
	int E, F;

	cin >> A >> B >> C >> D;
	cin >> E >> F;
	double best=0;
	pairII bestPair = make_pair(100*A,0);
	rep(i, 0, 31) {
		rep(j, 0, 31) {
			int W = 100 * A* i +100 *  B * j;
			if (W == 0 || W > F)continue;

			int MaxSugar = min(W * E / 100, F - W);
			int S = Sugar(MaxSugar, C, D);
			if ((double)S / (S + W) > (double)bestPair.second / bestPair.first)
				bestPair = make_pair(S + W, S);
		}
	}
	cout << bestPair.first << " " << bestPair.second;
	return 0;
}

Measured memory_bytes: 256
import heapq
class HeapDict:
    def __init__(self):
        self.h = []
        self.d = {}

    def insert(self,x):
        if x not in self.d or self.d[x] == 0:
            heapq.heappush(self.h, x)
        self.d.setdefault(x,0)
        self.d[x] += 1


    def erase(self,x):
        if x not in self.d or self.d[x] == 0:
            return
        else:
            self.d[x] -= 1

        while self.h:
            if self.d[self.h[0]] == 0:
                heapq.heappop(self.h)
            else:
                break


    def get_min(self):
        if not self.h:
            return None
        else:
            return self.h[0]


    def pop(self):
        poped_val = self.h[0]
        self.erase(poped_val)
        return poped_val


    def exist(self, x):
        return (x in self.d and self.d[x] > 0)


    def show_h(self):
        elems = [v for v in self.h if self.d[v] > 0]
        print(elems)


    def show_d(self):
        print(self.d)



def main():
    n,q = map(int, input().split())
    eventl = []

    for _ in range(n):
        s,t,x = map(int, input().split())
        eventl.append((s-x, 'a-stop', x)) 
        eventl.append((t-x, 'b-start', x))

    for i in range(q):
        d = int(input())
        eventl.append((d,'c-go', i))

    eventl.sort()

    ans = [0]*q
    hd = HeapDict()
    for e in eventl:
        if e[1] == 'a-stop':
            hd.insert(e[2])
        elif e[1] == 'b-start':
            hd.erase(e[2])
        else:
            min_x = hd.get_min()
            if min_x is not None:
                ans[e[2]] = min_x
            else:
                ans[e[2]] = -1

    for a in ans:
        print(a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 102776
import numpy as np

N = int(input())
l = [int(i) for i in input().split()]

if N%2 == 0:
    N_half = N//2
    arr = np.sort(np.array(l))
    arr_low = arr[:N_half]
    arr_high = arr[N_half:]
    if arr_low[N_half-1] != arr_high[0]:
        print(arr_high[0]-arr_low[N_half-1])
    else:
        print(0)
else:
    print(0)
    

Measured memory_bytes: 23504
n, t = (int(x) for x in input().split())
t_l = [int(x) for x in input().split()]
ans = s = 0
for t_i in t_l:
    if s <= t_i:
        ans += t
    else:
        ans += (t_i - s) + t
    s = t_i + t
print(ans)

Measured memory_bytes: 25196
#include <stdio.h>

int main(void){

    int a, b;

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

    if(a == b){
       printf("a == b\n");
    } else if(a > b){
       printf("a > b\n");
    } else {
       printf("a < b\n");
    }

    return 0;

}



    


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vll A(X), B(Y), C(Z);
    for(auto &x:A) cin >> x;
    for(auto &x:B) cin >> x;
    for(auto &x:C) cin >> x;
    DESC(A);
    DESC(B);
    DESC(C);
    vll ans;
    for (int x = 1; x <= X; x++)
    {
        for (int y = 1; y <= Y; y++)
        {
            for(int z = 1; z <= Z; z++) {
                if(x * y * z > K) {
                    break;
                }else {
                    ans.push_back(A[x - 1] + B[y - 1] + C[z - 1]);
                }
            }
        }
    }
    DESC(ans);
    for (int i = 0; i < K; i++)
    {
        cout << ans[i] << endl;
    }
    
}

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


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

int main() {
    int N;
    cin >> N;
    vector<int> A(100010, 0);
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A[a]++;
        res += a;
    }

    int Q;
    cin >> Q;
    while (Q--) {
        long long b, c;
        cin >> b >> c;
        res += (long long)(c - b) * A[b];
        A[c] += A[b];
        A[b] = 0;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

vector< pair<ll, ll> >  primeFactorization(ll n) {
    // 平方根を保存
    double s = floor(sqrt(n));
    
    ll r = 0;
    
    vector< pair<ll, ll> > result;
    
    // 2から平方根までの素因数を求める
    for (int i = 2;i <= s;i++) {
        if ((n % i) == 0) {
            r = 0; // 指数カウンタクリア
            do {
                
                r++; // 指数カウンタプラス
                
                n = n / i;
                
            } while ((n % i) == 0);
            
            // 素因数iを指数とともに保存
            result.emplace_back(make_pair(i, r));
        }
        
    }
    
    // 残った素数を追加
    if (n > s) {
        result.emplace_back(make_pair(n, r));
    }
    
    return result;
}

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

    // input
    ll N, P;
    cin >> N >> P;
    
    // calculation
    if (P == 1) {
        cout << 1 << "\n";
    } else if (N == 1) {
        cout << P << "\n";
    } else {
        vector< pair<ll, ll> > vec;
        vec = primeFactorization(P);
        ll len = (ll)vec.size();
        
        ll ans = 1;
        vector<ll> res;
        for (ll i = 0; i < len; ++i) {
            ll ex = vec[i].second;
            if (ex >= N) {
                ans *= pow(vec[i].first, ex/N);
            }
        }
        
        cout << ans << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
ll kai(ll n,ll k){
  ll cnt=0;
  while(1){
    if(n%k!=0) return cnt;
    n/=k;
    cnt++;
  }
}
int main(){
  ll n;
  cin >>n;
  ll a[n];
  ll cnt=0;
  for(ll i=0;i<n;i++) {
    cin >>a[i];
    if(a[i]%2==0) {
      cnt+=kai(a[i],2);
    }
  }
  cout <<cnt<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
   int x;
   cin >> x;
   if(x%10==3){
       cout << "bon";
   }else if(x%10==0 ||x%10==1 ||x%10==6 || x%10==8){
       cout << "pon";
   }else{
       cout << "hon";
   }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
N=N-N/100*100;
N=N-N/10*10;
if(N==3){
cout<<"bon"<<endl;
}
else if(N==0||N==1||N==6||N==8){
cout<<"pon"<<endl;
}
else
cout<<"hon"<<endl;
}

Measured memory_bytes: 3624
from operator import xor
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

sums = reduce(xor, a)

blu = set()
remain = set(range(n))

for i in range(61)[::-1]:
    if (sums >> i) & 1 == 0:
        di = -1
        for j in remain:
            if (a[j] >> i) & 1 == 1:
                di = j
                break
        if di != -1:
            blu.add(di)
            remain.remove(di)
            for j in range(n):
                if j != di and (a[j] >> i) & 1 == 1:
                    a[j] = a[j] ^ a[di]
bsum = 0
for i in blu:
    bsum = bsum ^ a[i]
print(bsum + (sums ^ bsum))


Measured memory_bytes: 84384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
// T have +-*/ and 0
template <class T> class BIT {
public:
  vector<T> dat;
  int N;

  BIT() {}
  BIT(int N) : N(N) { dat.assign(N, 0); }
  // sum [0,i)
  T sum(int i) {
    int ret = 0;
    for (--i; i >= 0; i = (i & (i + 1)) - 1)
      ret += dat[i];
    return ret;
  }
  // sum [i,j)
  T sum(int i, int j) { return sum(j) - sum(i); }
  // add x to i
  void add(int i, T x) {
    for (; i < N; i |= i + 1)
      dat[i] += x;
  }
};
const int MAX_N = 100010;
int N,M;
vector<int> D[MAX_N];
int main() {
  cin >> N >> M;
  BIT<int> bit(M + 810);
  for (int i = 0; i < N; i++){
    int l,r;
    cin >> l >> r;
    D[r - l + 1].push_back(l);
  }
  vector<int> result;
  result.push_back(N);
  int tmp = N;
  for (int d = 2; d <= M; d++){
    for (const int &l : D[d - 1]){
      int left = l;
      int right = l + d - 1;
      bit.add(left, 1);
      bit.add(right, -1);
    }
    tmp -= D[d - 1].size();
    int res = tmp;
    for (int i = 0; i <= M; i += d){
      res += bit.sum(i + 1);
    }
    result.push_back(res);
  }
  for (const auto &val : result){
    cout << val << endl;
  }
  return 0;
}


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

int base_8(int c){
  int base;
  if(c % 2 == 0){
    base = c/2*25;
  }else{
    base = (int)(c*12.5) + 1;
  }
  return base;
}
int base_10(int c){
  int base = c*10;
  return base;
}

int main()
{
  int a,b;
  cin >> a >> b;
  int mina, maxa;
  int minb, maxb;
  mina = base_8(a);
  maxa = base_8(a+1)-1;
  minb = base_10(b);
  maxb = base_10(b+1)-1;
  vector<int> lista, listb;
  for(int i=mina; i<=maxa;++i){
    lista.push_back(i);
  }
  for(int i=minb; i<=maxb;++i){
    listb.push_back(i);
  }
  std::vector<unsigned int> list_inter;
  std::set_intersection(lista.begin(), lista.end(), listb.begin(), listb.end(), std::back_inserter(list_inter));
  int ans = -1;
  if(!list_inter.empty()){
    ans = list_inter[0];
  }
  cout << ans << endl;

  
}

Measured memory_bytes: 256
// C++11
#include "bits/stdc++.h"
#include <sys/time.h>
#include <emmintrin.h>
#include <string>
#include <sstream>
#include <fstream>
#include <random>
#include <bitset>

using namespace std;

inline long long GetTSC() {
  long long lo, hi;
  asm volatile ("rdtsc": "=a"(lo), "=d"(hi));
  return lo + (hi << 32);
}
inline double GetSeconds() {
  return GetTSC() / 2.8e9;
}

const long inf = pow(10,15);
int di[] = {-1,0,1,0};
int dj[] = {0,1,0,-1};
tuple<int, int>q[50*50*50*50];

void solve(){
  double starttime = GetSeconds();
  while(1){
    int w,h;
    cin >> w >> h;
    // cerr << w << ", " << h << endl;
    if(w==0 && h==0) break;
    int lp,ls,rp,rs;
    bool lb[2500] = {};
    bool rb[2500] = {};
    bool f[2500][2500] = {};
    for(int i=0; i<h; i++){
      string s;
      cin >> s;
      for(int j=0; j<w; j++){
        if(s[j]=='#') lb[i*w+j] = 1;
        if(s[j]=='%') lp = i*w+j;
        if(s[j]=='L') ls = i*w+j;
      }
      cin >> s;
      for(int j=0; j<w; j++){
        if(s[j]=='#') rb[i*w+j] = 1;
        if(s[j]=='%') rp = i*w+j;
        if(s[j]=='R') rs = i*w+j;
      }
    }
    f[ls][rs] = 1;
    int qi = 0;
    int qe = 1;
    q[0] = make_tuple(ls,rs);
    bool ff = 0;
    while(qi<qe){
      int lt = get<0>(q[qi]);
      int rt = get<1>(q[qi]);
      int li = lt / w;
      int lj = lt % w;
      int ri = rt / w;
      int rj = rt % w;
      qi++;
      // cerr << "qie: " << qi << ", " << qe << ", lij: " << li << ", " << lj << ", rij: " << ri << ", " << rj << endl;
      for(int i=0; i<4; i++){
        int nli = li + di[i];
        int nlj = lj + dj[i];
        int nri = ri + di[i];
        int nrj = rj - dj[i];
        if(nli < 0 || nli >= h || nlj < 0 || nlj >= w || lb[nli*w+nlj]){
          nli = li;
          nlj = lj;
        }
        if(nri < 0 || nri >= h || nrj < 0 || nrj >= w || rb[nri*w+nrj]){
          nri = ri;
          nrj = rj;
        }
        int nlt = nli*w+nlj;
        int nrt = nri*w+nrj;
        if(nlt == lp && nrt == rp){
          ff = 1;
          break;
        }
        if(nlt == lp || nrt == rp) continue;
        if(f[nlt][nrt]) continue;
        f[nlt][nrt] = 1;
        q[qe++] = make_tuple(nlt,nrt);
      }
      if(ff) break;
    }
    if(ff){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  // cerr << "time: " << GetSeconds() - starttime << endl;

  return;
}

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




Measured memory_bytes: 22376
package main

import "fmt"

func main() {

	mainA()
	// mainB()
}

func mainA() {
	var n int
	fmt.Scan(&n)
	var res = solveA(n)
	fmt.Println(res)
}

func solveA(n int) int {

	var odd = 0
	var even = 0
	for i := 1; i <= n; i++ {
		if i%2 == 0 {
			even++
		} else {
			odd++
		}
	}

	return even * odd
}

func mainB() {
	var n, m int
	fmt.Scan(&n, &m)

	var kA []int
	var aA [][]int

	kA = make([]int, n)
	aA = make([][]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&kA[i])
		aA[i] = make([]int, 0)
		for j := 0; j < kA[i]; j++ {
			fmt.Scan(&aA[i][j])
		}
	}

	var res = solveB(n, m, kA, aA)

	fmt.Println(res)
}

func solveB(n int, m int, kA []int, aA [][]int) int {
	var mA = make([]int, m)
	for i := 0; i < n; i++ {
		for j := 0; j < kA[i]; j++ {
			var num = aA[i][j]
			mA[num-1]++
		}
	}
	var res = 0
	for i := 0; i < m; i++ {
		if mA[i] >= n {
			res++
		}
	}
	return res
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import groupby
def resolve():
    n,k,l=map(int,input().split())
    K=[[] for _ in range(n)]
    L=[[] for _ in range(n)]
    for _ in range(k):
        p,q=map(int,input().split())
        p-=1; q-=1
        K[p].append(q)
        K[q].append(p)
    for _ in range(l):
        r,s=map(int,input().split())
        r-=1; s-=1
        L[r].append(s)
        L[s].append(r)

    # KについてのDFS
    C1=[-1]*n
    col=[0]
    def dfs1(v)->bool:
        if(C1[v]!=-1): return False
        C1[v]=col[0]
        Q=[v]
        while(Q):
            v=Q.pop()
            for nv in K[v]:
                if(C1[nv]!=-1): continue
                C1[nv]=col[0]
                Q.append(nv)
        return True

    for v in range(n):
        col[0]+=dfs1(v)

    # LについてのDFS
    C2=[-1]*n
    col=[0]
    def dfs2(v)->bool:
        if(C2[v]!=-1): return False
        C2[v]=col[0]
        Q=[v]
        while(Q):
            v=Q.pop()
            for nv in L[v]:
                if(C2[nv]!=-1): continue
                C2[nv]=col[0]
                Q.append(nv)
        return True

    for v in range(n):
        col[0]+=dfs2(v)

    ans=[None]*n
    X=[(C1[v],C2[v],v) for v in range(n)]
    X.sort()
    for key,iter in groupby(X,key=lambda x:(x[0],x[1])):
        s=list(iter)
        for a,b,c in s:
            ans[c]=len(s)
    print(*ans)
resolve()

Measured memory_bytes: 121148
import sys
from collections import Counter

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    S = input().rstrip()

    c = Counter(S)
    ans = 1
    for v in c.values():
        ans = (ans * (v + 1)) % P

    ans = (ans - 1) % P
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9496
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	string N;
	int K;
	cin >> N >> K;
	vector<char> D(K);
	REP(i, K) cin >> D[i];
	char mn = '0', mx = '9';
	while (binary_search(D.begin(), D.end(), mn)) mn++;
	while (binary_search(D.begin(), D.end(), mx)) mx--;
	int i = 0;
	int n = N.size();
	while (i < n && !binary_search(D.begin(), D.end(), N[i])) i++;
	if (i == n) {
		cout << N << "\n";
		return 0;
	}
	if (N[i] < mx) {
		while (binary_search(D.begin(), D.end(), N[i])) N[i]++;
		FOR(j, i + 1, n) N[j] = mn;
		cout << N << "\n";
		return 0;
	}
	FOR(j, i, n) N[j] = mn;
	i--;
	while (i >= 0) {
		N[i]++;
		while (binary_search(D.begin(), D.end(), N[i])) N[i]++;
		if (N[i] > mx) {
			if (i == 0) {
				N[i] = mn;
				break;
			}
			N[i--] = mn;
		}
		else {
			cout << N << "\n";
			return 0;
		}
	}
	char c = mn;
	if (c == '0') while (binary_search(D.begin(), D.end(), ++c));
	cout << c << N << "\n";

	return 0;
}

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

typedef long long ll;
typedef long double ld;

map <int, ll> br;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        ll x;
        cin >> x;
        br[x]++;
        sum += x;
    }
    int q;
    cin >> q;
    while(q--){
        ll a, b;
        cin >> a >> b;
        sum -= br[a]*a;
        sum += br[a]*b;
        br[b] += br[a];
        br[a] = 0;
        cout << sum << "\n";
    }
    return 0;
}


Measured memory_bytes: 9500
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int frog1(int arr[],int n){
	int a[n]={0};
	a[1]=0;
	a[2]=abs(arr[2]-arr[1]);
	for(int i=3;i<=n;i++){
		int  c=a[i-2]+abs(arr[i]-arr[i-2]);
		int d=a[i-1]+abs(arr[i]-arr[i-1]);
		a[i]=min(c,d);
	}
	return a[n];
}	
int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	int k=frog1(arr,n);
	cout<<k;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int sum[100010];
int main() {
	int n; cin>>n;
	rep(i,n){
		int d; cin>>d;
		sum[d]++;
	}
	for(int i=1;i<100010;i++){
		sum[i]+=sum[i-1];
	}
	int cnt=0;
	for(int i=1;i<100010;i++){
		if(sum[i-1]==n-sum[i-1]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
int main()
{
	int n,i,k;
	scanf("%d",&n);
	a.resize(n+1);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	while(n!=1)
	{
		sort(a.begin()+1,a.end());
		k=n;
		for(i=2;i<=n&&i<=k;i++)
		{
			a[i]=a[i]%a[1];
			if(a[i]==0)
			{
				a.erase(a.begin()+i);
				n--;
			}
		}
	}
	printf("%d",a[1]);
	return 0;
}

Measured memory_bytes: 640
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}

// header
ll n,a,b;
void input(){
    cin>>n>>a>>b;
}
void src(){
    if(a==b){
        cout<<1;
    }else{
        if(b<a){
            cout<<0;
        }else{
            if(n==1){cout<<0;}
            else{
                cout<<((b*(n-1)+a)-(a*(n-1)+b)+1);
            }
        }
    }
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let S: Vec<char> = read_line().chars().collect();
    let mut count = 0;
    for i in 0..S.len() {
        if (i % 2 == 0) ^ (S[i] == '0') {
            count += 1
        }
    }
    println!("{}", std::cmp::min(count, S.len()-count));
}


Measured memory_bytes: 4352
# imos 法
from operator import itemgetter

N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]
stc.sort(key=itemgetter(2, 0))

cs = [0] * (10 ** 5 + 1)
pt, pc = -1, -1
for s, t, c in stc:
    if pt == s and pc == c:
        cs[s] += 1
    else:
        cs[s - 1] += 1
    cs[t] -= 1
    pt, pc = t, c

for i in range(1, 10 ** 5 + 1):
    cs[i] += cs[i - 1]

print(max(cs))


Measured memory_bytes: 36564
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,T;
  cin >>N>>T;
  vector<int> c(N),t(N);
  for(int i=0;i<N;i++){
   cin>> c.at(i)>>t.at(i);
  }
  int min=1000;
  bool flag=false;
  for(int i=0;i<N;i++){
    if(t.at(i)>T){continue;}
    else{
      flag=true;
      min=(min<c.at(i))?min:c.at(i);} 
  }
  if(flag)cout<<min<<endl;
  else cout <<"TLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
using namespace std;
typedef pair< double, int > P;
const int inf = 1LL << 20;
int x[200],y[200];
int pre[200];
double d[200];
main()
{
    int n;
    while( cin >> n, n )
    {
        /// key is b;distance of b
        for( int i = 0; i < n; i++ ) 
        {
            int b,X,Y;
            cin >> b >> X >> Y;
            b--;
            x[b] = X;y[b] = Y;
        }
        vector< P > E[200];
        for( int i = 0; i< n; i++ ) 
        {
            for( int j = i + 1; j < n; j++ )
            {
                double f = sqrt( ( double )( x[i] - x[j] ) * ( x[i] - x[j] ) + ( y[i] - y[j] ) * ( y[i] - y[j] ) );
                if( f <= 50. )
                {
                    E[i].emplace_back( P(f, j) );E[j].emplace_back( P(f, i) ) ;
                }
            }
        }
        int m;
        cin >> m;
        for( int k = 0; k < m; k++ )
        {
            int s, g;
            cin >> s >> g;
            s--,g--;
            for( int l = 0; l < 200; l++ ) d[l] = inf;
            memset( pre, -1, sizeof( pre ) );
            priority_queue< P, vector< P >, greater<P> > q;
            d[s] = 0;
            q.push( P(0, s) );
            while( !q.empty() )
            {
                P p = q.top();
                q.pop();
                if( d[p.second] != p.first )continue;
                if( p.second == g )break;
                for( P u : E[p.second] )
                {
                    if( d[u.second] > p.first + u.first )
                    {
                        d[u.second] = p.first + u.first;
                        pre[u.second] = p.second;
                        q.push( P( d[u.second], u.second ) );

                    }
                }
            }
            if( d[g] == inf )puts("NA");
            else
            {
                vector< int > v;
                for( int u = g; ~u; v.emplace_back( u ), u = pre[u] );
                for( int i = v.size() - 1; i >= 0; i-- )
                {
                    printf( "%d", v[i] + 1);
                    if( i ) printf( " ");
                    else printf("\n");
                }
            }
        }
        
    }
    return 0;
}


Measured memory_bytes: 3204
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

	N := nextInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = nextInt()
	}
	ans := 0
	for i := 0; i < N; i++ {

		for a[i]%2 == 0 {
			ans++
			a[i] /= 2
		}

	}

	fmt.Println(ans)
}


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

signed main () {
	int n, m;
	cin >> n >> m;
	int sum = 0;
	for (int i = 0; i < m; ++i) {
		int x;
		cin >> x;
		sum += x;
	}
	if (sum > n)
		cout << "-1\n";
	else
		cout << n - sum << '\n';
}


Measured memory_bytes: 3676
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string S;
    cin >> S;
    print(S.substr(0, 4) << " " << S.substr(4, 8));
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		ArrayList<Integer> lines = new ArrayList<Integer>();

		try {
			while (null != (s = br.readLine())) {
				lines.add(Integer.valueOf(s));
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		for (Integer n : lines) {
			if (n < 0) {
				continue;
			} else if (n > 36) {
				System.out.println(0);
			} else {
				try {
					int count = 0;
					for (int a = 0; a <= 9; a++) {
						if (n - a > 9 * 3)
							continue;
						for (int b = 0; b <= (n - a) && b <= 9; b++) {
							if (n - a - b > 9 * 2)
								continue;
							for (int c = 0; c <= (n - a - b) && c <= 9; c++) {
								if (n - a - b - c > 9)
									continue;
								count++;
							}
						}
					}
					System.out.println(count);
				} catch (NumberFormatException e) {
					e.printStackTrace();
				}
			}

		}
	}
}

Measured memory_bytes: 17852
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	ll a, b, k;
	cin >> k >> a >> b;
	if (b/k*k >= a) cout << "OK\n";
	else cout << "NG\n";
}



Measured memory_bytes: 3648