akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector<int> G, G2;
  int p = -INF;
  for (int i = 0; i < N; i++){
    if (S[i] == 'o' && i > p + C){
      G.push_back(i);
      p = i;
    }
    if (G.size() == K){
      break;
    }
  }
  p = INF;
  for (int i = N - 1; i >= 0; i--){
    if (S[i] == 'o' && i < p - C){
      G2.push_back(i);
      p = i;
    }
    if (G2.size() == K){
      break;
    }
  }
  reverse(G2.begin(), G2.end());
  for (int i = 0; i < K; i++){
    if (G[i] == G2[i]){
      cout << G[i] + 1 << endl;
    }
  }
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	double d,t,s;
	cin>>d>>t>>s;
	if(d/s<=t){ cout<<"Yes"<<"\n"; }
	else{ cout<<"No"<<"\n"; }
	return 0;
}

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

int group[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};

int main() {

    int x,y;

    cin >> x >> y;

    if(group[x] != group[y]){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

isac = Array.new(n, false)
cntwa = Array.new(n, 0)
m.times do
  a, b = gets.chomp.split
  a = a.to_i - 1
  if !isac[a]
    if b == "AC"
      isac[a] = true
    else
      cntwa[a] += 1
    end
  end
end

ac = isac.count(true)
wa = 0
n.times do |i|
  if isac[i]
    wa += cntwa[i]
  end
end
puts [ac, wa] * " "


Measured memory_bytes: 3324
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 11/20/2018, 11:16:27 PM
# Powered by Visual Studio Code
#

s = gets.chomp.split(" ").map{|i| i.to_s}

ans = ""

s.each{|str|
  ans += str[0].upcase
}

puts ans



Measured memory_bytes: 1916
s = input()
for i in range(len(s)-1):
    s = s[::-1]        
    s = s.replace(s[0],'',1)
    s = s[::-1] 
    a = s[0]
    for j in range(1,int(len(s)/2)+1):
        a += s[j]
        if a * (int(len(s)/len(a))) == s and (int(len(s)/len(a)) % 2 == 0 or s.count(s[0]) == len(s)):
            print(len(a * (int(len(s)/len(a)))))
            exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=5e3+20;
ll n,m;
string s;
ll dp[N][N];
ll powmod(ll x,ll n) {
    ll s=1;
    while(n) {
        if(n&1)
            s=(s*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return s;
}
int main() {
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0; i<=5000; i++) {
        for(int j=0; j<=5000; j++) {
            if(dp[i][j]==0) continue;
            dp[i+1][j+1]=(dp[i+1][j+1]+(2ll*dp[i][j])%mod)%mod;
            (dp[i+1][max(0,j-1)]+=dp[i][j]%mod)%=mod;
        }
    }
    while(cin>>n>>s) {
        ll l=s.length();
        ll ans=dp[n][l];
        ll t=powmod(2ll,l);
        ans=(ans*powmod(t,mod-2))%mod;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 197248
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int X;
   cin>>X;
   for(int i=1;i<=X/100;i++){
      if(X>=100*i&&X<=100*i+5*i){cout<<1<<endl;return 0;}
   }
   cout<<0<<endl;
return 0;}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    string S=in<string>();
    int NumOfAlphabet_right[N+1][26]={0};
    REP(i,N){
        REP(j,i+1){
            NumOfAlphabet_right[i+1][S[j]-'a']++;
        }
    }

    int ans;ans=0;
    int ans_max;ans_max=0;
    int NumOfAlphabet_left[N+1][26]={0};
    REP(i,N){
        REP(j,i+1){
            NumOfAlphabet_left[N-i-1][S[N-j-1]-'a']++;
        }
    }

    REP(i,N){
        ans=0;
        REP(j,26){
            if(NumOfAlphabet_right[i][j]>0&&NumOfAlphabet_left[i][j]>0){
                ans++;
            }
        }
        ans_max=max(ans,ans_max);
    }
    print(ans_max);
    return 0;
}

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

const int N = 200000 + 7, C = 31;

int n;
char s[N];
int nxt[N][C], dp[N], frm[N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int j = 0; j < 26; ++j)
		nxt[n + 1][j] = n + 1;
		
	dp[n + 1] = 1;
	for (int i = n; i; --i) {
		dp[i] = 1 << 29;
		for (int j = 0; j < 26; ++j) {
			nxt[i][j] = s[i] == 'a' + j ? i : nxt[i + 1][j];
			if (dp[nxt[i][j] + 1] < dp[i])
				dp[i] = dp[nxt[i][j] + 1],
				frm[i] = j;
		}
		++dp[i];
	}
	
	for (int i = 1, j; i <= n; i = nxt[i][j] + 1)
		for (j = 0; j < 26; ++j)
			if (dp[i] == dp[nxt[i][j] + 1] + 1) {
				printf("%c", 'a' + j);
				break;
			}

	return 0;
}


Measured memory_bytes: 26240
//it was hard to write
//so it should be hard to read
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define last(x) (x).size() - 1
#define mp make_pair

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef double ld;

const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 7;
const int inf = 1e9 + 7;
const double EPS = 1e-9;

int a[55], b[55], n, res;

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] >= b[i]) res += (a[i] - b[i]);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ab(N);
    CINVEC(ab);
    vector<pair<int, int>> cd(M);
    CINVEC(cd);

    REP(i, N) {
        int len = INF;
        int p;
        REP(j, M) {
            int len2 = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
            if (len2 < len) {
                len = len2;
                p = j;
            }
        }
        cout << ++p << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
const int MOD = 1e9 + 7;
using ll = long long;
ll add(ll a, ll b) {
    a += b;
    a %= MOD;
    if (a < 0) a += MOD;
    a %= MOD;
    return a;
}
ll mul(ll a, ll b) {
    return a * b % MOD;
}

auto fastpow(ll a, ll b) -> ll {
    ll ret = 1;
    while (b) {
        if (b & 1) {
            ret = mul(ret, a);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return ret;
}


auto solve() -> void {
    int n; cin >> n;
    if (n == 1) {
        cout << 0 << '\n';
        return;
    }
    auto res = fastpow(8, n);
    auto s = add(fastpow(9, n), -fastpow(8, n));
    res = add(res, mul(2, s));
    res = add(fastpow(10, n), -res);
    cout << res << '\n';
}
auto main() -> int {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    while (tc--) {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

long eval(ll p, ll q) {
	if(!q) return 0;
	if(!p) return 1;
	ll m=1LL<<p;
	return (q<2*m-1) ? eval(p-1,q-1) : m+eval(p-1,q-2*m+1);
}

int main() {
	ll n,x; cin>>n>>x;
	cout<<eval(n,x)<<"\n";
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  cout << ((s == "AAA" || s == "BBB") ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int[] p = new int[A];
    int[] q = new int[B];
    int[] r = new int[C];
    for (int i = 0; i < A; i++) p[i] = sc.nextInt();
    for (int i = 0; i < B; i++) q[i] = sc.nextInt();
    for (int i = 0; i < C; i++) r[i] = sc.nextInt();
    sc.close();

    Arrays.sort(p);
    Arrays.sort(q);

    int[] xyc = new int[X + Y + C];
    System.arraycopy(p, A - X, xyc, 0, X);
    System.arraycopy(q, B - Y, xyc, X, Y);
    System.arraycopy(r, 0, xyc, X + Y, C);
    Arrays.sort(xyc);

    long ans = 0;
    for (int i = C; i < X + Y + C; i++) ans += xyc[i];

    System.out.println(ans);
  }
}

Measured memory_bytes: 92160
class BipartiteMatching:
    def __init__(self, v: int):
        self.v = v
        self.g = [[] for _ in range(v)]
        self.match = [-1] * v
        self.used = [False] * v

    def add_edge(self, u, v):
        self.g[u].append(v)
        self.g[v].append(u)

    def dfs(self, v):
        self.used[v] = True
        for i in range(len(self.g[v])):
            u = self.g[v][i]
            w = self.match[u]

            if w < 0 or (not self.used[w] and self.dfs(w)):
                self.match[u] = v
                self.match[v] = u
                return True

        return False

    def maximum_matching(self):
        res = 0
        self.match = [-1] * self.v
        for i in range(self.v):
            if self.match[i] < 0:
                self.used = [False] * self.v
                if self.dfs(i):
                    res += 1
        return res


if __name__ == '__main__':
    x_size, y_size, e = map(int, input().split())
    b = BipartiteMatching(x_size + y_size)
    for i in range(e):
        x, y = map(int, input().split())
        b.add_edge(x, y + x_size)
    print(b.maximum_matching())



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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int dfs(const vector<vector<int>>& G, vector<int>& d, int p, int v) {
   for (int j = 0; j < G[v].size(); j++) {
      int u = G[v][j];
      if (u == p) continue;
      d[u] = d[v] + 1;
      dfs(G, d, v, u);
   }
}
int diameter(const vector<vector<int>>& G) {
   // G: tree
   int N = G.size();
   vector<int> dist(N, 0), dista(N, 0);
   dfs(G, dist, -1, 0);
   int a = max_element(dist.begin(), dist.end()) - dist.begin();
   dfs(G, dista, -1, a);
   return *max_element(dista.begin(), dista.end());
}

int main()
{
   int n; cin >> n;
   vector<vector<int>> G(n);
   for (int i = 0; i < n-1; ++i) {
      int a, b; cin >> a >> b; --a; --b;
      G[a].push_back(b);
      G[b].push_back(a);
   }

   int di = diameter(G);
   if (di % 3 == 1) {
      cout << "Second" << endl;
   } else {
      cout << "First" << endl;
   }

   return 0;
}


Measured memory_bytes: 28416
package main

import (
	"fmt"
)

func main() {
	var b string
	fmt.Scan(&b)
	if b == "A" {
		fmt.Println("T")
	} else if b == "C" {
		fmt.Println("G")
	} else if b == "G" {
		fmt.Println("C")
	} else if b == "T" {
		fmt.Println("A")
	}
}


Measured memory_bytes: 512
use std::str::FromStr;

fn main() {
	let n = read_vec_i32()[0];
	let mut ss: Vec<String> = (0..n).map(|_| read_str().trim().to_owned()).collect();
	ss.sort();
	println!("{}", ss.concat());
}

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

fn read_vec_i32() -> Vec<i32> {
	let mut line = String::new();
	std::io::stdin().read_line(&mut line).unwrap();
	line.trim().split(' ').map(|str| i32::from_str(str).unwrap()).collect()
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

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



int main(){
    int k;
    cin >> k;
    vector<ll> a;


    for (int i = 1; i <= 9; ++i) a.push_back(i);

    while(1){
        if (k <= a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();  



        vector<ll> old;


        swap(old, a);
        for(ll x : old){
            for (int i = -1; i <= 1; ++i){
                int d = x%10 +i;

                if (d < 0 || d > 9) continue;

                ll nx = x * 10 + d;

                a.push_back(nx);
            }
        } 
    }


    return 0;
}




// ㅗ ^오^ ㅗ

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
  std::string s;
  int k;
  std::cin >> k;

  std::cin >> s;
  bool flag = false;
  while(SZ(s) > k) s.pop_back(), flag = true;
  std::cout << s;
  if(flag) std::cout << "...";


	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
int z[100],x[100][100],y[100],a,b,i,j;
scanf("%d %d",&a,&b);
for(i=0;i<a;i++){
for(j=0;j<b;j++){
scanf("%d",&x[i][j]);
}
}
for(i=0;i<b;i++){
z[i]=0;
scanf("%d",&y[i]);
}
for(i=0;i<a;i++){
for(j=0;j<b;j++){
z[i]+=y[j]*x[i][j];
}
}
for(i=0;i<a;i++){
printf("%d\n",z[i]);
}
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int flag=0;
	for(int i=1;i<10;i++){
	    for(int j=1;j<10;j++){
	        if(n==i*j){
	            flag=1;
	            break;
	        }
	    }
	}
	if(flag==0){
	    cout<<"No\n";
	}
	else
	cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define N 200010
using namespace std;

int n;
long long k;
int tree[N];

void set(int i) {
	while (i <= n) {
		tree[i]++;
		i += (i & -i);
	}
}

int get(int i) {
	int ret = 0;
	while (i) {
		ret += tree[i];
		i &= i - 1;
	}
	return ret;
}

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

	cin >> n >> k;
	long long sum[N] = {};
	pair<long long, int> value[N] = {};

	int t;
	for (int i = 1; i <= n; ++i) {
		cin >> t;
		sum[i] = sum[i - 1] + t;
		value[i].first = sum[i] - k * i;
		value[i].second = i;
	}

	sort(value, value + n + 1);
	int size_order[N];
	int num = 1;
	size_order[value[0].second] = num;
	for (int i = 1; i <= n; ++i) {
		if (value[i - 1].first == value[i].first) {
			size_order[value[i].second] = num;
		}
		else size_order[value[i].second] = ++num;
	}

	long long ans = 0;
	n++;
	for (int i = 0; i < n; ++i) {
		ans += get(size_order[i]);
		set(size_order[i]);
	}

	cout << ans;
}

Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int N = Integer.parseInt(tokenizer.nextToken());
		int R = Integer.parseInt(tokenizer.nextToken());
		int L = Integer.parseInt(tokenizer.nextToken());
		int[] po = new int[N];
		int[] c = new int[N];
		int now = 0;
		int index = 0;

		for (int i = 0; i < R; i++) {
			tokenizer = new StringTokenizer(reader.readLine());
			int d = Integer.parseInt(tokenizer.nextToken()) - 1;
			int t = Integer.parseInt(tokenizer.nextToken());
			int x = Integer.parseInt(tokenizer.nextToken());
			c[index] += t - now;
			po[d] += x;
			now = t;
			if (x > 0) {
				if (d == index)
					continue;
				if (po[index] < po[d])
					index = d;
				else if (po[index] == po[d] && index > d)
					index = d;
			}
			if (x < 0) {
				if (d != index)
					continue;
				int maxp = Integer.MIN_VALUE;
				for (int j = 0; j < N; j++) {
					if (maxp < po[j]) {
						maxp = po[j];
						index = j;
					}
				}
			}

		}
		c[index] += L - now;
		int ans = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			if (c[i] > max) {
				max = c[i];
				ans = i;
			}
		}
		System.out.println(ans + 1);

	}
}

Measured memory_bytes: 91084
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 200005

int main()
{
    _io
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int res = 0;
    REP(i, 0, n)
    {
        if(i > 0 && s[i] == s[i-1] && s[i] == 'R')
            res++;
        if(i < n-1 && s[i] == s[i+1] && s[i] == 'L')
            res++;
    }
    int a = 0, b = 0;
    REP(i, 0, n-1)
    {
        if(s[i] == 'R' && s[i+1] == 'L')
            b++;
        if(s[i] == 'L' && s[i+1] == 'R')
            a++;
    }
    res += min(min(a, b), k)*2;
    if(min(a, b) < k)
    {
        if(s[n-1] == 'L' && b > a)
            res++;
        if(s[n-1] == 'R' && a > b)
            res++;
    }
    cout << res;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

typedef std::pair<int, bool> P;//red:false blue:true

int n;
P p[200];
std::set<int> redlist;
int ans;

signed main(){
	scanf("%ld", &n);
	for(int i = 0; i < 2*n; i++){
		int a, b;
		scanf("%ld %ld", &a, &b);
		if(i < n){
			p[a] = P(b, false);
		}else{
			p[a] = P(b, true);
		}
	}
	for(int i = 0; i < 2*n; i++){
		if(p[i].second == false){
			redlist.insert(p[i].first);
		}else{
			auto it = redlist.lower_bound(p[i].first);
			if(redlist.size() && it != redlist.begin()){
				ans++;
				redlist.erase(--it);
			}
		}
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <string.h>

using namespace std;
static const int INF = 1e9;
static const int SIZE = 10001;
typedef pair<int, int> P;
struct edge
{
	int to;
	int cost;
};

bool isUsed[SIZE];
vector<edge> G[SIZE];

void solve()
{
	int V, E;
	cin >> V >> E;
	for (int i = 0; i < E; ++i)
	{
		int from, to, cost;
		cin >> from >> to >> cost;
		edge e1, e2;
		e1.to = to;
		e1.cost = cost;
		e2.to = from;
		e2.cost = cost;
		G[from].push_back(e1);
		G[to].push_back(e2);
	}
	memset(isUsed, 0, sizeof(isUsed));
	int ans = 0;
	priority_queue<P, vector<P>, greater<P> > pque;
	pque.push(P(0, 0));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.second;
		if (isUsed[v])
		{
			continue;
		}
		isUsed[v] = true;
		ans += p.first;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			pque.push(P(e.cost, e.to));
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 6072
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける


//   a/b mod c
ll moddiv(ll a,ll b){
	ll x0=MOD,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%MOD;
      if (x2==1){
        ans=(n2+MOD)%MOD;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%MOD)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1) ans=ans*aa%MOD;
    aa=aa*aa%MOD;
    beki/=2;
    if (beki==0)break;
  }
  return ans;
}


const ll HASH_P=2013265921;
const ll HASH_Wn=52278;
void makehash(vector<ll> &array,vector<ll> &outarray)
{
  ll asz=array.size();

  ll alast=0;
  ll wi=1;
  for(ll i=0;;i++){
    i%=asz;
    alast=(alast+array[(asz-1+i)%asz]%HASH_P*wi)%HASH_P;
    if (i==asz-1)break;
    wi*=HASH_Wn;
    wi%=HASH_P;
  }
  outarray[asz-1]=alast;

  for(ll i=asz-2;i>=0;i--){
    outarray[i]=(((outarray[i+1]-array[i]*wi)%HASH_P)*HASH_Wn%HASH_P+array[i]+HASH_P)%HASH_P;
  }
}




ll n;

int main(){
  ll ans=0;
  cin >> n;
  vi a(n),b(n);
  vi sa(n),sb(n);
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  
  REP(i,n){
    sa[i]=a[i]^a[(i+1)%n];
  }
  REP(i,n){
    sb[i]=b[i]^b[(i+1)%n];
  }

  vi hsa(n),hsb(n);
  makehash(sa,hsa);
  makehash(sb,hsb);

  REP(i,n){
    if (hsb[0]==hsa[i]){
      cout<<i<<" "<<(b[0]^a[i])<<endl;
    }
  }



  return 0;
}

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

int main(void) {
  int n, tmp;
  while (1) {
    cin >> n;
    if (n == 0) break;

    int age[7] = {0};
    while (n--) {
      cin >> tmp;
      if (tmp >= 60) {
	age[6]++;
      } else {
	age[tmp/10]++;
      }
    }

    for (int i = 0; i < 7; i++) {
      cout << age[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n;
    vector<int> v;
    cin >> n;
    int max_num = 0;
    int sum_num = 0;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;
        if (m > max_num) {
            max_num = m;
        }
        sum_num += m;
    }
    sum_num -= max_num;
    if (sum_num > max_num) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 3e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll fac[MAXN];
ll inver[MAXN];

ll mypow(ll n,ll m)
{
    ll res = 1;
    while(m){
        if(m&1)res = (res*n)%PMOD;
        n = (n*n)%PMOD;
        m>>=1;
    }
    return res;
}

ll ncr(ll n,ll m)
{
    ll res = fac[n];
    res*=inver[m];
    res%=PMOD;
    res*=inver[n-m];
    res%=PMOD;
    return res;
}

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>a>>b>>k;

    fac[0] = 1;

    for(ll i=1;i<=n;i++)fac[i] = (i*fac[i-1])%PMOD;

    inver[n] = mypow(fac[n],PMOD-2);

    for(ll i=n-1;i>=0;i--)
        inver[i] = (inver[i+1]*(i+1))%PMOD;

    ll j;

    ll res = 0;

    for(ll i=0;i<=n;i++){
        if(a*i>k)break;
        if(!((k-a*i)%b)){
            j = (k-a*i)/b;
            if(j>n)continue;
            x = ncr(n,i);
            y = ncr(n,j);
            res+=(x*y)%PMOD;
            res%=PMOD;
        }
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

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

		int n = scan.nextInt();
		int k = scan.nextInt();
		int problem = 0;
		String result;
		int count_AC = 0;
		int count_WA = 0;

		ArrayList<Integer> list_count = new ArrayList<Integer>(n);
		ArrayList<HashSet<String>> list_judge = new ArrayList<HashSet<String>>(n);

		for(int i = 0;i < n;i++) {
			list_judge.add(new HashSet<String>());
			list_count.add(0);
		}

		for(int i = 0;i < k;i++) {
			problem = scan.nextInt();
			result = scan.next();
			list_judge.get(problem - 1).add(result);

			if(result.equals("WA")) {
				if(list_judge.get(problem - 1).contains("AC")) {

				}else {
					list_count.set(problem - 1 , list_count.get(problem - 1) + 1);
				}
			}
		}

		for(int i = 0;i < n;i++) {
			if(list_judge.get(i).contains("AC")) {
				count_AC += 1;
				count_WA += list_count.get(i);
			}
		}

		System.out.println(count_AC + " " + count_WA);
	}
}

Measured memory_bytes: 82848
S = input()
N = len(S)
# print(S[0:N//2])
# print(S[N//2 + 1:N])
if S[0:N//2] == S[N//2 + 1:N]:
    front = S[0:(N-1)//2]
    rear = S[(N+3)//2 -1:N]
    if front == rear:
        print("Yes")
    else:
        print("No")

else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
F = [list(map(int,input().split())) for n in range(N)]
P = [list(map(int,input().split())) for n in range(N)]
ans = []

for i in range(1,1024):
  p = 0
  for j in range(N):
    c = 0
    for k in range(10):
      if (i>>k&1) & F[j][k]:
        c+=1
    p+=P[j][c]
  ans+=[p]
    
print(max(ans))

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI d(n);
  INPUT(d);
  int ans = 0;
  REP(i, n-1) REP2(j, i+1, n) ans += d[i]*d[j];
  cout << ans << endl;

  return 0;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    string s,t;
    cin >> s >> t;
    if(t.size()>s.size()){
        COUT("UNRESTORABLE");
        return 0;
    }
    string tes;
    int count = 0;
    bool flag;
    bool ans = false;
    int index;
    int num = s.size()-t.size();
    for(int i=0;i<=num;i++){
        flag = true;
        tes = s.substr(num-i,t.size());
        for(int j=0;j<t.size();j++){
            if(tes[j]!=t[j]&&tes[j]!='?')flag = false;
        }
        count++;
        if(flag){
            index = num-i;
            ans = true;
            break;
        }
    }
    if(!ans){
        COUT("UNRESTORABLE");
        return 0;
    }
    for(int i=0;i<s.size();){
        if(i==index){
            cout << t;
            i+=t.size();
        }
        else{
            if(s[i]=='?'){
                cout << 'a';
                i++;
            }
            else{
                cout << s[i];
                i++;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,i,a,b,c;

	scanf("%d",&n);

	for(i = 0;i < n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if((a*a + b*b == c*c) || (b*b + c*c == a*a) || (c*c + a*a == b*b)){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 580
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        t = a//2
        a = t
        b += t
    else:
        if b % 2 == 1:
            b -= 1
        t = b//2
        b = t
        a += t
print(a, b)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	if(__builtin_popcount(N) == 1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	auto ADD = [&](int x,int y){
		cout << x << " " << y << endl;
	};
	rep(t,(N-1)/2){
		int a = t*2+2, b = a+1;
		ADD(1,a);
		ADD(a,b);
		ADD(1,b+N);
		ADD(b+N,a+N);
	}
	ADD(3,1+N);
	if(N%2 == 0){
		ADD(N,N-1+N);
		ADD(N+N,(N-1)^1^N);
	}
}


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    int a, b, c, d;
    a = n / 1000 % 10;
    b = n / 100 % 10;
    c = n / 10 % 10;
    d = n % 10;
    
    if (a == b && b == c) {
        cout << "Yes" << endl;
    }
    else if (b == c && c == d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	x := nextInt()
	y := nextInt()
	groups := [][]int{
		{1, 3, 5, 7, 8, 10, 12},
		{4, 6, 9, 11},
		{2},
	}

	var isSameGroup bool
	for _, group := range groups {
		var isSameGroupX, isSameGroupY bool
		for _, v := range group {
			if x == v {
				isSameGroupX = true
			} else if y == v {
				isSameGroupY = true
			}
		}
		if isSameGroupX && isSameGroupY {
			isSameGroup = true
			break
		}
	}

	if isSameGroup {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define endl "\n"
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
          ll a,b,c,k;
          cin>>a>>b>>c>>k;
          ll ans = 0;
          if(a>=k)
          {
              ans+=k;
              cout<<ans<<endl;
              return 0;
          }
          else
          {
             ans+=a;
             k-=a;
          }
          if(b>=k)
          {
               cout<<ans<<endl;
               return 0;
          }
          else
          {
              k-=b;
          }
          if(c>=k)
          {
              ans-=k;
              cout<<ans<<endl;
              return 0;
          }
          else
          {
              ans-=c;
              k-=c;
          }
          cout<<ans<<endl;

         

      }
      






}



























Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int digitsum(ll x){
    return (int)to_string(x).size();
}

int main(){
    ll n;
    cin >> n;
    int ans = 10;

    for(int i = 1; i <= 100010; i++){
        if (n%i != 0) continue;
        ans = min(ans, max(digitsum(n/i), digitsum(i)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3756
s=input()
l=len(s)
k=int(input())
alp=[chr(i) for i in range(97, 97+26)]
ans=set()
for i in range(26):
    for j in range(l):
        if s[j]==alp[i]:
            for m in range(j,min(l,j+k)):
                ans.add(s[j:m+1])
    if len(ans)>=k:
        break
print(sorted(list(ans))[k-1])

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
def resolve():
    n=int(input())
    ans=0
    for i in range(n+1):
        if i%2==0: continue
        D=make_divisors(i)
        if len(D)==8: ans+=1
    print(ans)

resolve()

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	vector<long long int> v;
	for(int i=0;i<n;i++)
	{
		long long int x;
		cin>>x;
		v.push_back(x);
	}
	long long int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(v[i]!=v[j]&&v[i]!=v[k]&&v[j]!=v[k])
				{
					int m;
					m=max(v[i],max(v[j],v[k]));
					if(m==v[i])
					{
						if((v[j]+v[k])>v[i])
						{
							ans++;
						}
					}
					if(m==v[j])
					{
						if((v[i]+v[k])>v[j])
						{
							ans++;
						}
					}
					if(m==v[k])
					{
						if((v[j]+v[i])>v[k])
						{
							ans++;
						}
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

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

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

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


int main() {
    int M1,M2,D1,D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    if (M1!=M2) {
        cout << 1 << endl;
        exit(0);
    }
    cout << 0 << endl;
    exit(0);

    return 0;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


class UnionFind:
    def __init__(self, N):
        self.tree = list(range(N))

    def root(self, N):
        if self.tree[N] == N:
            return N
        else:
            self.tree[N] = self.root(self.tree[N])
            return self.tree[N]

    def same(self, x, y):
        return self.root(self.tree[x]) == self.root(self.tree[y])

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.tree[x] = y


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    uf = UnionFind(N)
    for _ in range(M):
        s, t = il()
        uf.unite(s, t)

    Q = ii()
    for _ in range(Q):
        s, t = il()
        if uf.same(s, t):
            print('yes')
        else:
            print('no')


if __name__ == '__main__':
    main()



Measured memory_bytes: 46144
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

void f(vector<vi> &data, vi &num, vll &ans, ll sum, int n) {
    sum += ll(num[n]);
    ans[n - 1] = sum;
    for (int x : data[n]) {
        if (ans[x - 1] != -1) {
            continue;
        }
        f(data, num, ans, sum, x);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vi> data(N + 1);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        data[a].push_back(b);
        data[b].push_back(a);
    }
    vi num(N + 1, 0);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        num[p] += x;
    }
    vll ans(N, -1);
    f(data, num, ans, 0, 1);
    for (int i = 0; i < N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 29060
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double T, X;
    cin >> T >> X;
    cout << T / X << "\n";
    return 0;
}


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

const long long mod=1000000007;

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin>>n>>s;
	if (s.at(0)=='W')
	{
		cout<<"0\n";
		return 0;
	}
	string memo="A";
	for (int i = 1; i < 2*n; ++i)
	{
		if (s.at(i-1)==s.at(i))
		{
			if (memo.at(i-1)=='A')
			{
				memo+="B";
			}
			else
			{
				memo+="A";
			}
		}
		else
		{
			if (memo.at(i-1)=='A')
			{
				memo+="A";
			}
			else
			{
				memo+="B";
			}
		}
	}
	long long ans=1LL,cnt=0LL;
	for (int i = 0; i < 2*n; ++i)
	{
		if (memo.at(i)=='A')
		{
			++cnt;
		}
		else
		{
			ans*=cnt;
			ans%=mod;
			--cnt;
		}
	}
	if (cnt>0LL)
	{
		cout<<"0\n";
	}
	else
	{
		for (int i = 1; i <= n; ++i)
		{
			ans*=(long long)i;
			ans%=mod;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 776
<?php
$stdin = trim(fgets(STDIN));
$len = strlen($stdin);

for ($i = 0; $i < $len; ++$i) {
    $arr[] = substr($stdin, $i, 1);
}

$vals = array_count_values($arr);

$cnt0 = (isset($vals[0])) ? $vals[0] : 0;
$cnt1 = (isset($vals[1])) ? $vals[1] : 0;

$cnt = ($cnt0 > $cnt1) ? $cnt1 * 2 : $cnt0 * 2;
echo $cnt;

Measured memory_bytes: 12920
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int a, b, c, x, cnt = 0;
  cin >> a >> b >> c >> x;
  rep(i, a+1)rep(j, b+1)rep(k, c+1) {
    if (500*i + 100*j + 50*k == x) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  } else if (A + B > C + D) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
x=int(input())
s=str(input())
flag=0
if len(s)%2==0:
  n=len(s)//2
  for i in range(n):
    if s[i]!=s[n+i]:
      flag=1
else:
  flag=1
if flag==0:
  print('Yes')
else:
  print("No")

Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n,a,x[300];
string s;
int main(){
    cin>>n>>a;
    x[3]=100000;
    x[2]=200000;
    x[1]=300000;
    cout<<x[n]+x[a]+(n+a==2?400000:0)<<endl;
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

a,op,b = input().split()
a = int(a)
b = int(b)
if op == "+":
    print(a+b)
else:
    print(a-b)

Measured memory_bytes: 3316