akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def bisect(l,r,f,discrete=True,left=True):
    """
    l,r: l<r int if discrete else float
    f: function defined on [l,...,r] to {False,True}
    if discrete: f defined on Z; else: R
    if left: f satisfies that there uniquely exists d such that iff i<=d then f(i)
    else: iff i>=d then f(i) is True
    return d such as those above
    """
    assert r>l
    if discrete: assert isinstance(l,int) and isinstance(r,int)
    eps=1 if discrete else 10**-12
    if (not left)^f(r): return r if left else r+1
    elif left^f(l): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if (not left)^f(h): l=h
        else: r=h
    return h if not discrete else l if left else r

class RollingHash(object):
    """
    construct: O(N)
    get_hash: O(1)
    LCP: O(logN)
    """
    def __init__(self,S,m1=10**9+9,b1=1007,m2=10**9+7,b2=2009):
        """
        S: string
        m1>m2: prime sufficiently large
        b1,b2: base 0<bi<mi
        """
        assert m1>m2 and 0<b1<m1 and 0<b2<m2
        n=len(S)
        self.__n=n
        self.__m1=m1
        self.__m2=m2
        self.__H1,self.__H2=[0]*(n+1),[0]*(n+1)
        self.__P1,self.__P2=[1]*(n+1),[1]*(n+1)
        for i,s in enumerate(S):
            self.__H1[i+1]=(self.__H1[i]*b1+ord(s))%m1
            self.__H2[i+1]=(self.__H2[i]*b2+ord(s))%m2
            self.__P1[i+1]=self.__P1[i]*b1%m1
            self.__P2[i+1]=self.__P2[i]*b2%m2
        self.__d=0
        while(m1):
            m1//=10
            self.__d+=1

    @property
    def len(self):
        return self.__n

    def hash(self,l,r=None):
        """
        l,r: int (0<=l<=r<=n)
        return hash of S[l:r]
        """
        if r is None: r=self.len
        assert 0<=l<=r<=self.len
        return (self.__H1[r]-self.__P1[r-l]*self.__H1[l]%self.__m1)%self.__m1*(10**self.__d)+(self.__H2[r]-self.__P2[r-l]*self.__H2[l]%self.__m2)%self.__m2

    def LCP(self,l1,r1=None,rh2=None,l2=0,r2=None):
        if r1 is None: r1=self.len
        if rh2 is None: rh2=self
        if r2 is None: r2=rh2.len
        assert 0<=l1<=r1<=self.len and 0<=l2<=r2<=rh2.len
        L=0
        R=min(r1-l1,r2-l2)
        if self.hash(l1,l1+R)==rh2.hash(l2,l2+R): return R
        while(R-L>1):
            H=(L+R)//2
            if self.hash(l1,l1+H)==rh2.hash(l2,l2+H): L=H
            else: R=H
        return L

def resolve():
    n=int(input())
    S=input()
    # d=0ではtrue,d=nではfalseなので、そこでbisectする
    rh=RollingHash(S)
    def judge(d):
        # S[0:d],...,S[n-d:n]に重複があり、かつd離れているか判定
        # initialize
        J={rh.hash(i,i+d):-1 for i in range(n-d+1)}
        for i in range(n-d+1):
            h=rh.hash(i,i+d)
            if J[h]!=-1:
                if i-J[h]>=d: return True
            else: J[h]=i
        return False
    print(bisect(0,n,judge))
resolve()

Measured memory_bytes: 45296
#include <stdio.h>

int main(void)
{
	int a,b,x,y;
	
	scanf("%d %d\n",&x,&y);
	
	if(x<y)
	{
		printf("a < b\n");
	}
	else if(x>y)
	{
		printf("a > b\n");
	}
	else if(x==y)
	{
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dp[110000];
int main(){
    int N; cin >> N;
    dp[0] = 0;
    for (int i = 1; i <=N; i++) {
        dp[i] = INF;
        for(int a=1;a<=i;a*=6){
            chmin(dp[i], dp[i - a] + 1);
             
        }
        for(int b=1;b<=i;b*=9){
            chmin(dp[i], dp[i - b] + 1);
   
        }
    }
    
    cout << dp[N] << endl;
}



   

    
    



    
                

 













































































































































Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    int a,b,c,temp;
    scanf("%d %d %d",&a,&b,&c);
    
    while (!(a <= b && b <= c))
    {
        if (a > b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        if (b > c)
        {
            temp = b;
            b = c;
            c = temp;
        }
    }
    printf("%d %d %d\n", a, b, c);

}


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

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define RESET(x) memset((x), 0, sizeof(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define ALL(x) (x).begin(), (x).end()
#define ALLSIZE(x,n) (x), (x)+(n)
#define SQR(x) ((x)*(x))
#define CUBE(x) (SQR(x)*(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main(){
	int D, N;
	cin >> D >> N;
	for (ll i = 1; ; ++i){
		ll cnt = 0;
		ll tmp = i;
		while (tmp % 100 == 0){
			++cnt;
			tmp /= 100;
		}
		if (D == cnt){
			--N;
		}
		if (N == 0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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


int h,n;
cin >> h >> n;
int a;
int sum=0;
rep(i,n){
    cin >> a;
    sum += a;
}
sum >= h ? fin("Yes") : fin("No");

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int K, S;
    cin >> K >> S;

    int ans = 0;

    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            if((S-i-j)>=0 && (S-i-j)<=K) ans++;
        }
    }

    cout << ans << endl;
}

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

public class Main {
    public static void main (String[] args ) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String data = reader.readLine();
        String[] number = data.split(" ");
        int count = 0;
        for (int i = Integer.parseInt(number[0]) ; i <= Integer.parseInt(number[1]) ; i++) {
            if ( (Integer.parseInt(number[2]) % i ) == 0) {
                count++;
            }
        }
        System.out.println (count);
    }
}

Measured memory_bytes: 26128
import itertools

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

li = [i+1 for i in range(N)]

a = 0
b = 0
for v in itertools.permutations(li, N):
    a += 1
    b += 1
    aaa = 1
    bbb = 1
    for i in range(N):
        if v[i] != P[i]:
            aaa = 0
            break
    if aaa == 1:
        ansa = a
    for i in range(N):
        if v[i] != Q[i]:
            bbb = 0
            break
    if bbb == 1:
        ansb = b
print(abs(ansa-ansb))


Measured memory_bytes: 3188
n, k = map(int, input().split())
p = 10**9 +7
"""
1の時、1グループのbをn-kのどこにおくか選ぶ、(n-k+1)C1
2の時、2つのグループのbをn-kのどこにおくか、(n-k+1)C2
        かつ、2つのbのグループの作り方は、k-1ある隙間のどこにに仕切りをおくか(k-1)C(i-1)
iの時、(n-k+1)Ci × (k-1)C(i-1)
"""
kaijou = [1, 1]
kaijou_inv = [1, 1]
inv = [0, 1]
for i in range(2, 2005):
    kaijou.append((kaijou[i-1]*i)%p)
    inv.append(p-inv[p%i]*(p//i)%p)
    kaijou_inv.append((kaijou_inv[i-1]*inv[i])%p)

def comb(n, k):
    if n < k:
        return 0
    if n < 0 and k < 0:
        return 0
    a = kaijou[n]
    b = kaijou_inv[n-k]
    c = kaijou_inv[k]
    return (a * ((b * c)%p) )%p

for i in range(1, k+1):
    print((comb(n-k+1, i) * comb(k-1, i-1))%p)

Measured memory_bytes: 3572
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);

        int X = scanner.nextInt();
        int N = scanner.nextInt();

        int p[] = new int[N];
        for(int loop=0; loop<N; loop++) {
            p[loop] = scanner.nextInt();
        }

        int sol = X;
        int dis = 0;
        while(true) {

            int ans = sol - dis;

            boolean exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            ans = sol + dis;

            exist = false;
            for(int loop=0; loop<N; loop++) {
                if( ans == p[loop] ){
                    exist = true;
                    break;
                }
            }
            if( exist == false ) {
                sol = ans;
                break;
            }

            dis++;
        }

        System.out.println( sol );

    }
}

Measured memory_bytes: 35804
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> v((n+1)/2);
        vector<int> a;
        for (int i = 1; i < n; ++i) {
            a.emplace_back(i*i%n);
        }
        sort(a.begin(), a.end());
        a.erase(unique(a.begin(), a.end()), a.end());
        for (int i = 0; i < a.size(); ++i) {
            for (int j = 0; j < a.size(); ++j) {
                if(i == j) continue;
                int val = (a[i]-a[j]+n)%n;
                if(val > (n-1)/2) val = n-val;
                v[val]++;
            }
        }
        for (int i = 1; i < v.size(); ++i) {
            printf("%d\n", v[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 3292
X, Y = map(int, input().split())

max_Y = 4 * X
min_Y = 2 * X
if max_Y < Y:
    print("No")
    exit()

y = max_Y
while y >= min_Y:
    if y == Y:
        print("Yes")
        exit()
    else:
        y -= 2
print("No")


Measured memory_bytes: 61896
import java.util.*;

public class Main {
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
	  int N = Integer.parseInt(sc.next());
	  int D = Integer.parseInt(sc.next());
	  
	  int temp = D * 2 + 1;
	  int a = N / temp;
	  int b = N % temp;
	  
	  if(b == 0) {
		  System.out.println(a);
	  }
	  else {
		  System.out.println(a + 1);
	  }
	  sc.close();
	  
  }
}


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

int main(){
    int sums[100001]={},sumt[100001]={},n,m,a,b,c,d,q;
    char s[100010],t[100010];
    scanf("%s",s);
    scanf("%s",t);
    n=strlen(s);
    m=strlen(t);
    for(int i=0;i<n;i++){
        sums[i+1]=sums[i]+s[i]-'A'+1;
    }
    for(int i=0;i<m;i++){
        sumt[i+1]=sumt[i]+t[i]-'A'+1;
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d %d %d %d",&a,&b,&c,&d);
        if((sums[b]-sums[a-1])%3==(sumt[d]-sumt[c-1])%3){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
}

Measured memory_bytes: 1408
#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 s;
  cin >> s;
  int l;
  cin >> l;
  if(s*4 < l || s*2 > l || l%2 != 0) {
    cout << "No" <<endl;
    return 0;
  }else{
    cout << "Yes" <<endl;
  }
  
}


Measured memory_bytes: 3636
#ifndef _BLESS_MCLAREN_MCL32_
#define _BLESS_MCLAREN_MCL32_ true
#endif

#ifndef _BLESS_FERNANDO_ALONSO_14_
#define _BLESS_FERNANDO_ALONSO_14_ true
#endif

#ifndef _FERNANDO_ALONSO_WILL_WIN_ANOTHER_CHAMPIONSHIP_
#define _FERNANDO_ALONSO_WILL_WIN_ANOTHER_CHAMPIONSHIP_ true
#endif

#ifndef _1731_TRUE_LOVE_
#define _1731_TRUE_LOVE_ true
#endif

#ifndef _CIVILIZATION_
#define _CIVILIZATION_ true
#endif

#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstdarg>
#include <climits>
#include <cassert>
#include <cstring>
#include <cmath>
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <string>
using namespace std;

const int MAX_N = (int)2e5 + 5;

int n, a[MAX_N];

bool even(const string& str) {
    if (str.size() & 1) return false;
    return str.substr(0, str.size() / 2) == str.substr(str.size() / 2);
}
int main() {
    {
        assert(_BLESS_MCLAREN_MCL32_);
        assert(_BLESS_FERNANDO_ALONSO_14_);
        assert(_FERNANDO_ALONSO_WILL_WIN_ANOTHER_CHAMPIONSHIP_);
        assert(_1731_TRUE_LOVE_);
        assert(_CIVILIZATION_);
    }

    string str;
    cin >> str;
    do {
        str = str.substr(0, str.size() - 1);
        if (even(str)) return printf("%d", str.size()), 0;;
    } while (true);
    return 0;;
}


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

int main() {
  vector<int> a(3);
  int K;
  for (int i = 0; i < 3; ++i) {
    cin >> a.at(i);
  }
  cin >> K;
  sort(a.begin(), a.end());
  cout << a.at(0) + a.at(1) + (a.at(2) << K) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll
#define INF (1LL<<60)
#define mod 1000000007

int c[3][3], a[3], b[3];

signed main(){

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			cin >> c[i][j];

	// a0+b0 a0+b1 a0+b2
	// a1+b0 a1+b1 a1+b2
	// a2+b0 a2+b1 a2+b2

	a[0] = 0;
	b[0] = c[0][0];
	b[1] = c[0][1];
	b[2] = c[0][2];
	a[1] = c[1][0] - b[0];
	a[2] = c[2][0] - b[0];

	if (c[1][1] != a[1] + b[1] ||
		c[1][2] != a[1] + b[2] ||
		c[2][1] != a[2] + b[1] ||
		c[2][2] != a[2] + b[2])
		cout << "No" << endl;
	else
		cout << "Yes" << endl;


	return 0;
}


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

using namespace std;

const int N = 1000;

typedef long long LL;



int main(){

	int m , a , b , c , sum = 0;

	int aa , bb , cc;

	cin>>a>>b>>c>>m;

	for(aa = 0 ; aa <= a ; aa++)

		for(bb = 0 ; bb <= b ; bb++)

			for(cc = 0 ; cc <= c ; cc++){

				if(aa * 500 + bb * 100 + cc * 50 == m) sum++;

				}

	cout<<sum<<endl;

	return 0;

	}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        
        Integer[] a = new Integer[N];
        
        Map<Integer, Integer> map = new HashMap<>();
        for(int i=0; i<N; i++) {
            a[i] = Integer.parseInt(sc.next());
            if(map.containsKey(a[i])) {
                map.put(a[i], map.get(a[i])+1);
            }else {
                map.put(a[i], 1);
            }
        }
        
        Object[] mapkey = map.keySet().toArray();
        Arrays.sort(mapkey, Collections.reverseOrder());
        long hen1 = 0;
        long hen2 = 0;
        for(Object ob : mapkey) {
            int x = Integer.parseInt(String.valueOf(ob)); 
            if(map.get(x) >= 4) {
                if(hen1 == 0) {
                    hen1 = x;
                    hen2 = x;
                }else {
                    hen2 = x;
                }
                break;
            }else if(map.get(x) >= 2) {
                if(hen1 == 0) {
                    hen1 = x;
                }else {
                    hen2 = x;
                    break;
                }
            }
        }
        
        System.out.println(hen1*hen2);
    }
}


Measured memory_bytes: 54140
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <assert.h>

int main(void)
{
    uint32_t A, B, C;
    uint32_t cnt = 0;
    scanf("%" PRIu32 "%" PRIu32 "%" PRIu32, &A, &B, &C);
    while (A != B || B != C) {
        if (A > B && A > C) {
            B++; C++;
        } else if (B > A && B > C) {
            A++; C++;
        } else if (C > A && C > B) {
            A++; B++;
        } else if (A == B) {
            C += 2;
        } else if (B == C) {
            A += 2;
        } else if (C == A) {
            B += 2;
        } else {
            assert(0);
        }
        cnt++;
    }
    printf("%" PRIu32 "\n", cnt);
    return 0;
}



Measured memory_bytes: 128
import java.util.Scanner


object Main {


  def read() = {
    val sc = new Scanner(System.in)
    val n, x = sc.nextInt()
    val l = IndexedSeq.fill(n)(sc.nextInt())
    (n, x,l)
  }

  def solve(n:Int, x:Int, l: IndexedSeq[Int]): Long = {
    var d = 0
    var cnt = 1
    for(li <- l){
      d += li
      if(d <= x){
        cnt += 1
      }else{
        return cnt
      }
    }
    cnt
  }

  def main(args: Array[String]): Unit = {
    val (n, x,l) = read()
    println(solve(n,x,l))
  }
}

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

int main(){
  int a,b,array[101],c,i=0,d;
  cin>>a>>b>>c;
  a-=c;
  while(a>=0){
    a-=b+c;
    i++;
  }
  cout<<i-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int fn(long long int b[],int m,long long int val)
{
	if(b[m-1]<=val) return m-1;
	if(b[0]>val) return -1;

	int l=0;
	int u=m-2;
	while(l<=u)
	{
		int mid=(l+u)/2;
		if(b[mid]<=val && b[mid+1]>val)
		 return mid;
		else if(b[mid]>val)
		 u=mid-1;
		else l=mid+1; 
	}
}
int main()
{
  int n,m;long long int kk;
  cin>>n>>m>>kk;
  long long int a[n];
  long long int b[m];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<m;i++)
    cin>>b[i];
  long long int sum=0;
  int taken=0;
  for(int i=1;i<n;i++)
   a[i]+=a[i-1];
  for(int i=1;i<m;i++)
   b[i]+=b[i-1];
  for(int i=0;i<n;i++)
   {
   	if(a[i]<=kk) taken=max(taken,i+2+fn(b,m,kk-a[i]));
   }
   taken=max(taken,fn(b,m,kk)+1);
     cout<<taken<<endl;
  return 0;
} 

Measured memory_bytes: 6748
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
int par[100002];
int rk[100002];
ll w[100002];
int n, m;
vector<int> g[300002];
int num[100002];
int ec[100002];
int c;
int mx[300002];
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i; rk[i]=0; num[i]=i;
	}
}
 
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
 
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		g[c].push_back(num[x]);
		g[c].push_back(num[y]);
		par[x]=y;
		num[y]=c;
		c++;
		w[y]+=w[x];
		ec[y]+=ec[x];
	}else{
		g[c].push_back(num[x]);
		g[c].push_back(num[y]);
		par[y]=x;
		num[x]=c;
		c++;
		w[x]+=w[y];
		ec[x]+=ec[y];
		if(rk[x]==rk[y]) rk[x]++;
	}
}
 
bool same(int x, int y){
	return find(x)==find(y);
}

int ans;

void dfs(int x){
	if(mx[x]>=0){
		ans+=mx[x];
		return;
	}
	for(auto y:g[x]){
		dfs(y);
	}
}

int main()
{
	cin>>n>>m;
	for(int i=0; i<n; i++) cin>>w[i];
	init(n);
	P e[100001];
	int a[100001], b[100001];
	for(int i=0; i<m; i++){
		ll y; cin>>a[i]>>b[i]>>y; a[i]--; b[i]--;
		e[i]=P(y, i);
	}
	c=n;
	sort(e, e+m);
	fill(mx, mx+300000, -1);
	for(int i=0; i<n; i++) mx[i]=0;
	for(int i=0; i<m; i++){
		int j=e[i].second;
		if(!same(a[j], b[j])){
			unite(a[j], b[j]);
		}
		int p=find(a[j]);
		ec[p]++;
		if(w[p]>=e[i].first){
			mx[num[p]]=max(ec[p], mx[num[p]]);
		}
	}
	dfs(c-1);
	cout<<m-ans<<endl;
	return 0;
}

Measured memory_bytes: 18944
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template <class T>
inline void read(T &x)
{
    x=0; char c=getchar();  int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
    while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2010,mod=998244353;
ll Pow(ll x,ll y){ll res=1; while(y){if(y&1) res=res*x%mod; x=x*x%mod,y>>=1;} return res;}
char str[N];
int sum[N][2],n;
ll dp[N][N],frac[N],inv[N];
int main()
{
	scanf("%s",str+1); n=strlen(str+1);
	for(int i=1;i<=n;++i)
	{
		sum[i][0]=sum[i-1][0]+(str[i]-'0');
		sum[i][1]=sum[i-1][1]+2-(str[i]-'0');
	}
	frac[0]=1;
	for(int i=1;i<=n;++i) frac[i]=frac[i-1]*i%mod;
	inv[n]=Pow(frac[n],mod-2);
	for(int i=n-1;i>=0;--i) inv[i]=inv[i+1]*(i+1)%mod;
	
	dp[0][0]=1;
	for(int i=0;i<n;++i)
	for(int j=0;j<=i;++j)
	if(dp[i][j])
	{
		if(sum[i+1][0]>=j+1) dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
		if(sum[i+1][1]>=i+1-j) dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
	}
//	for(int j=0;j<=n;++j) printf("%0lld\n",dp[n][j]); 
	ll ans=0;
	for(int i=0;i<=n;++i) if(sum[n][0]>=i&&sum[n][1]>=(n-i)) ans=(ans+dp[n][i]*inv[sum[n][0]-i]%mod*inv[sum[n][1]-(n-i)]%mod)%mod;
	ans=ans*frac[n]%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 30336
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 110000
ll MOD=1e9+7;

template< typename T >
vector< T > slide_min(const vector< T > &v, int k)
{
  deque< int > deq;
  vector< T > ret;
  for(int i = 0; i < v.size(); i++) {
    while(!deq.empty() && v[deq.back()] >= v[i]) {
      deq.pop_back();
    }
    deq.push_back(i);
    if(i - k + 1 >= 0) {
      ret.emplace_back(v[deq.front()]);
      if(deq.front() == i - k + 1) deq.pop_front();
    }
  }
  return ret;
}
template< typename T >
vector< T > slide_max(const vector< T > &v, int k)
{
  deque< int > deq;
  vector< T > ret;
  for(int i = 0; i < v.size(); i++) {
    while(!deq.empty() && v[deq.back()] <= v[i]) {
      deq.pop_back();
    }
    deq.push_back(i);
    if(i - k + 1 >= 0) {
      ret.emplace_back(v[deq.front()]);
      if(deq.front() == i - k + 1) deq.pop_front();
    }
  }
  return ret;
}

main(){
  int n=in();
  int k=in();
  vector<int> v;
  rep(i,n)v.pb(in());
  vector<int> left=slide_min(v,k),right=slide_max(v,k);
  int ans=n-k+1;
  bool unchange=false;
  vector<int> check(n);
  int cnt=0;
  int c=0;
  rep2(i,1,n-1){
    if(v[i]>v[i-1])cnt++;
    else cnt=0;

    if(cnt>=k-1){
      check[i-k+1]=1;
      c++;
    }
  }
  if(c)ans-=c-1;
  rep2(i,1,n-k){
    if(!check[i]&&left[i]>v[i-1]&&right[i]<=v[i+k-1]){
      ans--;
    }
  }

  cout<<ans;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

struct union_find{
    vector<ll> par;
    vector<ll> size;

    union_find(ll n){
        par.resize(n);
        size.assign(n, 1);
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    ll root(ll x){
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y){
        x = root(x), y = root(y);
        if(x != y){
            if(size[x] > size[y]) swap(x, y);
            par[y] = x;
            size[x] += size[y];
        }
    }

    ll getSize(ll x){
        return size[root(x)];
    }

    bool same(ll x, ll y){
        return root(x) == root(y);
    }
};

int main(void){
    ll n, q;
    cin >> n >> q;
    union_find uf(n);
    while(q--){
        ll t, u, v;
        cin >> t >> u >> v;
        if (t == 0) uf.unite(u, v);
        else
            co(uf.same(u, v));
    }

    return 0;
}


Measured memory_bytes: 5960
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	solve();
    }

    static void solve(){
	int[] left = new int[4];
	int[] right = new int[4];

	while(kbd.hasNext()){
	    double l = kbd.nextDouble();
	    double r = kbd.nextDouble();
	    set(left, l);
	    set(right, r);
	}

	for(int i=0; i<left.length; i++){
	    System.out.println(left[i]+" "+right[i]);
	}
    }

    static void set(int[] side, double n){
	if(n >= 1.1) side[0]++;
	else if(n >= 0.6) side[1]++;
	else if(n >= 0.2) side[2]++;
	else side[3]++;
    }
}

Measured memory_bytes: 20288
#include <stdio.h>
#include <string.h>
int main(void){
    char s[100],p[100];
    int ls,lp,i,j,k,count;
    scanf("%s %s",s,p);
    ls=strlen(s);
    lp=strlen(p);
    i=0;
    for(;;){
        count=0;
        j=0;
        for(;;){
            k=i+j;
            if(k>=ls) k=k-ls;
            if(s[k]==p[j]) count++;
            if(count==lp||j>=lp) break; 
            j++;
        }
        i++;
        if(i>=ls||count==lp) break; 
    }
    if(count==lp) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli c, h, k, m, n, w, ans = 0, count = 0;
  string s, t;
  cin >> n >> m >> c;
  vi a(m), b(m);
  rep(i, 0, m)
  {
    cin >> b[i];
  }
  rep(i, 0, n)
  {
    ans = 0;
    rep(j, 0, m)
    {
      cin >> a[j];
      ans += a[j] * b[j];
    }
    if (ans + c > 0)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

root = None
def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z[2] < x[2]:
            x = x[0]
        else:
            x = x[1]
    z[3] = y

    if y is None:
        root = z
    elif z[2] < y[2]:
        y[0] = z
    else:
        y[1] = z

def debug():
    s0 = [""]
    s1 = [""]

    def dfs(nd):
        v = str(nd[2])
        s0.append(v)
        if nd[0] is not None:
            dfs(nd[0])
        s1.append(v)
        if nd[1] is not None:
            dfs(nd[1])
    dfs(root)
    return " ".join(s1), " ".join(s0)


M = int(readline())
ans = []
for m in range(M):
    cmd, *V, = readline().split()
    if cmd == "print":
        ans.extend(debug())
    else:
        insert([None, None, int(V[0]), None])
write("\n".join(ans))
write("\n")



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

int main()
{
 	int n;
  priority_queue<double,vector<double>,greater<double>> pq;
  
  cin >> n;
  
  for (int i = 0;i < n;i++)
  {
double tmp;
    cin >> tmp;
    pq.push(tmp);
  }
  
  double ans = 0;
  while (pq.size() >= 2)
  {
double t1 = pq.top();
    pq.pop();
    double t2 = pq.top();
    pq.pop();
 	pq.push((t1+t2)/2);
  }
  cout << pq.top() << endl;
}

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

int main() {
  int a, p, j;
  p = j = 1<<29;
  for(int i = 0; i < 3; ++i) {
    cin >> a;
    p = min(p,a);
  }
  for(int i = 0; i < 2; ++i) {
    cin >> a;
    j = min(j,a);
  }
  cout << p+j-50 << endl;
  return 0;
}

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

using namespace std;

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

	int ssz = s.size();
	int tsz = t.size();

	vector<int> ss(ssz+1, 0);
	vector<int> tt(tsz+1, 0);

	for (int i = 1; i <= ssz; i++) {
		if (s[i-1] == 'A') {
			ss[i] = 2;
		}
		else {
			ss[i] = 1;
		}
		if (i > 0) {
			ss[i] += ss[i - 1];
		}
		//cout << ss[i] << endl;
	}

	for (int i = 1; i <= tsz; i++) {
		if (t[i-1] == 'A') {
			tt[i] = 2;
		}
		else {
			tt[i] = 1;
		}
		if (i > 0) {
			tt[i] += tt[i - 1];
		}
	}

	int q;
	cin >> q;
	int a, b, c, d;
	for (int i = 0; i < q; i++) {
		cin >> a >> b >> c >> d;
		int aa = ss[b] - ss[a - 1];
		//cout << ss[a-1] << ' ' << ss[b] << endl;
		int cc = tt[d] - tt[c - 1];
		//cout << aa << ' ' << cc << endl;
		if (aa % 3 == cc % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
	long long N;
	cin >> N;

	long long div = 1000000000 + 7;
	long long ans = 1;
	long long diff = 1;
	long long diff2 = 1; 

	for (long long i = 0; i < N; i++) {
		ans *= 10;
		ans = ans % div;
	}

	for (long long i = 0; i < N; i++) {
		diff *= 8;
		diff = diff % div;
	}

	for (long long i = 0; i < N; i++) {
		diff2 *= 9;
		diff2 = diff2 % div;
	}	

	diff2 *= 2;
	diff2 = diff2 % div;

	ans = ans - diff2 + diff;
	if (ans < 0) {
		ans += div;
	}
	ans = ans % div;
	cout << ans << "\n";
	return 0;
}

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

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")

#define F first
#define S second
#define MT make_tuple
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LBS 20
#define MOD ((long long)1e9+7) //1e9+9
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)

using namespace std;

typedef long long ll;
typedef double rat;
typedef long long bi;
typedef pair<int, int> ii;
typedef std::vector<ii> vii;
typedef std::map<int, int> mii;
typedef bitset<LBS> bis;
typedef std::vector<bis> vbs;

template<class T>
void vin(std::vector<T> &a){
  for(auto &x: a)
    cin >> x;
}

template<class T>
void vout(std::vector<T> &a){
  for(auto x: a)
    cout << x << " ";
  cout << endl;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n; cin >> n;
  std::vector<ll> a(n), b(n), c(n-1);
  vin(a); vin(b); vin(c);
  ll s=b[a[0]-1];
  for(int i=1; i<n; i++){
    s+=b[a[i]-1];
    if(a[i]==a[i-1]+1)
      s+=c[a[i-1]-1];
  }
  cout << s <<"\n";
}


Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))
c = 0
for ti in t:
    l = -1
    u = n
    while u - l > 1:
        m = (u + l) // 2
        if s[m] <= ti:
            if s[m] == ti:
                c += 1
                break
            l = m
        else:
            u = m
print(c)


Measured memory_bytes: 16704
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	string S;
	cin>>S;
	cout<<S.substr(0,3)<<endl;
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>

int cross(int x1,int y1,int x2,int y2,
		int x3,int y3,int x4,int y4) {
	long long b12x,b12y,b34x,b34y;
	long long b24x,b24y;
	long long b13x,b13y,b14x,b14y,b32x,b32y;
	long long g1213,g1214,g3431,g3432;
	long long n1213,n1214,n3431,n3432;
	long long n2123,n2124,n4341,n4342;

	b12x=x2-x1;b12y=y2-y1;
	b34x=x4-x3;b34y=y4-y3;
	b13x=x3-x1;b13y=y3-y1;
	b14x=x4-x1;b14y=y4-y1;
	b32x=x2-x3;b32y=y2-y3;
	b24x=x4-x2;b24y=y4-y2;

	g1213=b12x*b13y-b13x*b12y;
	g1214=b12x*b14y-b14x*b12y;
	g3431=b34x*(-b13y)-(-b13x)*b34y;
	g3432=b34x*b32y-b32x*b34y;

	n1213=b12x*b13x+b12y*b13y;
	n1214=b12x*b14x+b12y*b14y;
	n3431=b34x*(-b13x)+b34y*(-b13y);
	n3432=b34x*b32x+b34y*b32y;
	n2123=(-b12x)*(-b32x)+(-b12y)*(-b32y);
	n2124=(-b12x)*b24x+(-b12y)*b24y;
	n4341=(-b34x)*(-b14x)+(-b34y)*(-b14y);
	n4342=(-b34x)*(-b24x)+(-b34y)*(-b24y);

	if(
		((g1213<0 && g1214>0) || (g1213>0 && g1214<0)) &&
		((g3431<0 && g3432>0) || (g3431>0 && g3432<0))
	) return 1;
	if(
		(g1213==0 && n1213>=0 && n2123>=0) ||
		(g1214==0 && n1214>=0 && n2124>=0) ||
		(g3431==0 && n3431>=0 && n4341>=0) ||
		(g3432==0 && n3432>=0 && n4342>=0)
	) return 1;

	return 0;
}

/*
a1x+b1y=c1
a2x+b2y=c2
*/
int solve_houteisiki(double* x,double* y,
		double a1,double b1,double c1,
		double a2,double b2,double c2) {
	double d;
	d=a1*b2-b1*a2;
	if(-1e-8<d && d<1e-8)return 0;
	*x=(b2*c1-b1*c2)/d;
	*y=(-a2*c1+a1*c2)/d;
	return 1;
}

int main(void) {
	int x[6],y[6];
	int no_triangle;
	double x1,y1,t1,x2,y2,t2,x3,y3,t3;
	double tx1,ty1,tx2,ty2,tx3,ty3;
	double s;
	while(1) {
		scanf("%d%d%d%d",&x[0],&y[0],&x[1],&y[1]);
		if((x[0]|y[0]|x[1]|y[1])==0)break;
		scanf("%d%d%d%d",&x[2],&y[2],&x[3],&y[3]);
		scanf("%d%d%d%d",&x[4],&y[4],&x[5],&y[5]);
		no_triangle=0;
		no_triangle=no_triangle ||
			!cross(x[0],y[0],x[1],y[1],x[2],y[2],x[3],y[3]);
		no_triangle=no_triangle ||
			!cross(x[2],y[2],x[3],y[3],x[4],y[4],x[5],y[5]);
		no_triangle=no_triangle ||
			!cross(x[4],y[4],x[5],y[5],x[0],y[0],x[1],y[1]);
		if(!no_triangle) {
			x1=y[1]-y[0];
			y1=-(x[1]-x[0]);
			t1=x[0]*(y[1]-y[0])-y[0]*(x[1]-x[0]);
			x2=y[3]-y[2];
			y2=-(x[3]-x[2]);
			t2=x[2]*(y[3]-y[2])-y[2]*(x[3]-x[2]);
			x3=y[5]-y[4];
			y3=-(x[5]-x[4]);
			t3=x[4]*(y[5]-y[4])-y[4]*(x[5]-x[4]);
			no_triangle=no_triangle ||
				!solve_houteisiki(&tx1,&ty1,
					x1,y1,t1,x2,y2,t2);
			no_triangle=no_triangle ||
				!solve_houteisiki(&tx2,&ty2,
					x2,y2,t2,x3,y3,t3);
			no_triangle=no_triangle ||
				!solve_houteisiki(&tx3,&ty3,
					x3,y3,t3,x1,y1,t1);
		}
		if(!no_triangle) {
			s=((tx2-tx1)*(ty3-ty1)-(tx3-tx1)*(ty2-ty1))/2;
			if(s<0)s=-s;
			if(s<1e-8)puts("kyo");
			else if(s<100000+1e-8)puts("syo-kichi");
			else if(s<1000000+1e-8)puts("kichi");
			else if(s<1900000+1e-8)puts("chu-kichi");
			else puts("dai-kichi");
		} else puts("kyo");
	}
	return 0;
}

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


def judge(leet_num):
    leet_list = []
    for num in range(leet_num):
        leet_list.append(input())
    
    leet_dict = {}
    
    for leet in leet_list:
        if not leet in leet_dict:
            leet_dict[leet] = 1
        else:
            leet_dict[leet] = leet_dict[leet] + 1
    
    max_leet = max(leet_dict.values())
    result_list = []
    
    for num in leet_dict:
        if leet_dict[num] == max_leet:
            result_list.append(num)
    result_list = sorted(result_list)
    
    return result_list
    
    
    
def main():
    num = int(input())
    answear = judge(num)
    for num in answear:
        print(num)
    

if __name__ == "__main__":
    main()
    

Measured memory_bytes: 35344
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll H,W,K;
    cin >> H >> W >> K;
    vector<string> S(H);
    vector<vector<ll>> v(H+1,vector<ll>(W));
    rep(i,H){
        cin >> S[i];
    }
    rep(i,W){
        v[0][i] = -1;
    }
    ll cur = 1;
    rep(i,H){
        ll nst=0;
        rep(j,W){
            if(S[i][j] == '#'){
                nst++;
            }
        }
        if(nst == 0){
            rep(j,W){
                v[i+1][j] = v[i][j];
            }
        }else if(nst == 1){
            rep(j,W){
                v[i+1][j] = cur;
            }
            cur++;
        }else{
            rep(j,W){
                if(S[i][j] == '#'){
                    v[i+1][j] = cur;
                    nst--;
                    if(nst != 0){
                        cur++;
                    }
                }else{
                    v[i+1][j] = cur;
                }
            }
            cur++;
        }
    }
    for(int i=H; i>0;i--){
        rep(j,W){
            if(v[i-1][j] == -1){
                v[i-1][j] = v[i][j];
            }
        }
    }
    rep(i,H){
        PR(v[i+1], W);
    }
}


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

int main()
{
  int N;
  string S;
  cin >> N >> S;
  long long r = 0, g = 0, b = 0;
  for (auto c : S)
  {
    if (c == 'R')
      ++r;
    else if (c == 'G')
      ++g;
    else
      ++b;
  }
  long long all = r * g * b;
  long long sub = 0;
  for (int i = 0; i < N; ++i)
  {
    for (int j = i + 1; j < N; ++j)
    {
      if (S[i] == S[j])
        continue;
      int k = j * 2 - i;
      if (k >= N || S[k] == S[i] || S[k] == S[j])
        continue;
      ++sub;
    }
  }
  cout << all - sub << endl;
}

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

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

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

const int MAX_M = 1e3 + 5;
const int MAX_N = 1 << 12;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, M, a[MAX_M], b[MAX_M], key[MAX_M];
int dp[MAX_N];

int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            int c;
            cin >> c;
            c--;
            key[i] |= 1 << c;
        }
    }

    rep(i, 1 << N) dp[i] = INF;
    dp[0] = 0;
    
    rep(i, 1 << N) {
        rep(j, M) {
            int next = i | key[j];
            dp[next] = min(dp[next], dp[i] + a[j]);
        }
    }

    if (dp[(1 << N) - 1] == INF) {
        cout << "-1" << endl;
        return 0;
    }

    cout << dp[(1 << N) - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int K, q;
    scanf("%d%d", &K, &q);
    lint d[K];
    rep(i, K) scanf("%lld", &d[i]);
    rep(_, q){
        lint n, x, m;
        scanf("%lld%lld%lld", &n, &x, &m);
        x %= m;
        lint td[K], sum = 0, zero = 0, zero_sum = 0;
        rep(i, K){
            td[i] = d[i] % m;
            sum += td[i];
            if(td[i] == 0) ++zero;
        }

        lint a = x + (n-1)/K * sum;
        zero_sum += (n-1)/K * zero;
        for(int i=0; i<=(n-1)%K-1; ++i){
            a += td[i];
            if(td[i] == 0) ++zero_sum;
        }

        printf("%lld\n", n-1 - (a/m - x/m) - zero_sum);
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define f first
#define s second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)
#define mll map<ll,ll>
#define mint map<int,int>
#define mll_it map<ll,ll>::iterator
#define mint_it map<int,int>::iterator

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"

#define mem(a,n) memset(a, n, sizeof(a)); // n = 0 OR -1 only

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD1 1000000007
#define MOD2 998244353

#define BOOST ios_base::sync_with_stdio(false); cin.tie(NULL)



// CUSTOM HASH FUNCTION - O(1)
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


//gp_hash_table - Open Address Hash Table

//gp_hash_table<int, int> table;

const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
};
//gp_hash_table<key, int, chash> table;


// Indexed Set
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indSet;

/* FUNCTIONS:
1. The function "find_by_order" returns an iterator to the element at a given position:
2. The function "order_of_key" returns the position of a given element
	-> If the element does not appear in the set, we get the position that the element
	   would have in the set
	-> O(log n)*/

void swap(multimap<char, int>& mp1, multimap<char, int>&mp2, char c1, char c2)
{
    auto it1 = mp1.find(c1);
    auto it2 = mp2.find(c2);

    //p1(it1->s << " " << it2->s);
    mp1.erase(it1);
    mp2.erase(it2);

    mp1.insert(mp(c2, it2->s));
    mp2.insert(mp(c1, it1->s));
}


int main()
{
  BOOST;
  ll w, a, b;
  cin >> w >> a >> b;
  
  if((w+a > b) && (w + b > a))
    p1(0);
  else 
    p1(min(abs(b-w-a), abs(a-w-b)));
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, countABC;
	char s[51];
	int i;
	
	scanf("%d", &n);
	scanf("%s", s);
	
	/* d */
	for (i = 0; i < n - 2; i++)
	{
		if ((s[i] == 'A') && (s[i + 1] == 'B') && (s[i + 2] == 'C'))
		{
			countABC++;
		}
	}

	printf("%d", countABC);

	return 0;
}

Measured memory_bytes: 128