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

#define NIL -1
#define INF 1000000001

using namespace std;
void bfs(const vector<vector<int> > &adj, vector<int> &d, queue<int> node_visit){
    int current_node;
    while(!node_visit.empty()){
        current_node = node_visit.front();
        node_visit.pop();
        for(int i = 1;i < d.size();i++){
            if(adj[current_node][i] == 1 && d[i] == -1){
                d[i] = d[current_node]+1;
                node_visit.push(i);
            }
        }
    }
    
}
int main(){
    int num_node;
    int node_ind,node_deg,adj_node;
    scanf("%d",&num_node);

    vector<vector<int> > adj(num_node+1,vector<int>(num_node+1,0));
    queue<int> node_visit;
    vector<int> d(num_node+1,NIL);

    for(int i = 0; i < num_node;i++ ){
        scanf("%d %d",&node_ind,&node_deg);
        for(int j = 0;j < node_deg;j++){
            scanf("%d",&adj_node);
            adj[node_ind][adj_node] = 1;
        }
    }
   
    node_visit.push(1);
    d[1] = 0;
    bfs(adj,d,node_visit);
    for(int i = 1; i < num_node+1;i++){
        printf("%d %d\n",i,d[i]);
    }

    return 0;   
}



Measured memory_bytes: 3284
s = input()
r = 0
o = [x for x in s]

l = 1
j = []
a, b = 0, 1
for y in range(len(o)):
    for x in range(10):
        j.append([a, b])
        a += 1
        b += 1
    l += 1
    a, b = 0, l

for x in j:
    for y in o[x[0]:x[1]]:
        if not y in ["A", "C", "G", "T"]:
            break
    else:
        if len("".join(o[x[0]:x[1]])) > r:
            r = len("".join(o[x[0]:x[1]]))

print(r)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;
long long a,b,v,w,t;
int main()
{
    cin>>a>>v;
    cin>>b>>w;
    cin>>t;
    if(a>b)
    {
        a=-a;
        b=-b;
    }

    if(a+v*t>=b+w*t)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int a[]=new int[4],ns=0,we=0;
        String s=new String();
        s=sc.next();
        sc.close();
        for(int i=0;i<s.length();++i){
            if(s.charAt(i)=='N')++a[0];
            else if(s.charAt(i)=='W')++a[1];
            else if(s.charAt(i)=='S')++a[2];
            else ++a[3];
        }
        for(int i=0;i<4;i+=2)if(a[i]>0)++ns;
        for(int i=1;i<4;i+=2)if(a[i]>0)++we;
        System.out.print(ns%2>0||we%2>0?"No":"Yes");
    }
}

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<int> v(10000);
    rep(i, 1, 100) rep(j, 1, 100) rep(k, 1, 100)
    {
        int tmp = i * i + j * j + k * k + i * j + j * k + k * i - 1;
        if (tmp < 10000)
            v[tmp]++;
    }
    rep(i, 0, n) cout << v[i] << endl;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

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

struct Edge {
  Edge(int _to, int _cost)
    : to(_to), cost(_cost) {}
  int to;
  int cost;
};

vector< Edge > e[MAX_N];
ll d[MAX_N];

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

  CIN(N);
  REP(i, N - 1) {
    CIN(a, b, c);
    a--; b--;
    e[a].emplace_back(Edge(b, c));
    e[b].emplace_back(Edge(a, c));
  }

  CIN(Q, K);

  fill_n(d, MAX_N, LINF);
  d[K - 1] = 0;
  queue< int > q;
  q.push(K - 1);
  while (!q.empty()) {
    int from = q.front(); q.pop();
    EACH(to, e[from]) {
      if (d[to.to] > d[from] + to.cost) {
	d[to.to] = d[from] + to.cost;
	q.push(to.to);
      }
    }
  }

  REP(qi, Q) {
    CIN(x, y);
    ll ans = d[x - 1] + d[y - 1];
    cout << ans << endl;
  }
  
  
  

  return 0;
}



Measured memory_bytes: 8820
path=[]
while(True):
    try:
        temp=list(map(int,input().split(',')))
        path.append(temp)
    except:
        break
path[0][0]
for i in range(1,len(path)):
    for j in range(len(path[i])):
        if len(path[i])>len(path[i-1]):
            start=0 if j<1 else j-1
            path[i][j]+=max(path[i-1][start:j+1])
        else:
            path[i][j]+=max(path[i-1][j:j+2])
print(path[-1][-1])


Measured memory_bytes: 5604
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		StringBuilder x = new StringBuilder(sc.next());
		sc.close();
		int p=0;
		while((p=x.indexOf("ST",p))>=0) {
			int d=2;
			while(p>0&&p+d<x.length()&&x.charAt(p-1)=='S'&&x.charAt(p+d)=='T') {
				p--;
				d+=2;
			}
			x.delete(p, p+d);
			if(p!=0)p--;
		}
		out.println(x.length());
	}
}


Measured memory_bytes: 26816
#include <iostream>
#include <string>
#include <sstream>

void split(int* arr, const std::string& str) {
    std::stringstream stream;
    stream << str;
    std::string buf;
    for (int i = 0; std::getline(stream, buf, ' '); ++i) {
        arr[i] = std::stoi(buf);
    }
}

void get_array(int* arr, std::istream& stream) {
    std::string buf;
    std::getline(stream, buf);
    split(arr, buf);
    return;
}

int count(int const* s, const int n, int const* t, const int q) {
    int counter = 0;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < n; ++j) {
            if (s[j] == t[i]) {
                ++counter;
                break;
            }
        }
    }
    return counter;
}

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

    int n;
    std::cin >> n;
    std::cin.ignore();

    int s[10000];
    get_array(s, std::cin);

    int q;
    std::cin >> q;
    std::cin.ignore();

    int t[500];
    get_array(t, std::cin);

    std::cout << count(s, n, t, q) << std::endl;

    return 0;
}

Measured memory_bytes: 3248
n=int(input())
a=list(map(int,input().split()))
if n==1:
    print(0)
    exit()
for i in range(n):
    a[i]=a[i]-i-1
a.sort()
b1=a[n//2]
b2=a[n//2+1]
ans1=[]
ans2=[]
for i in range(n):
    ans1.append(abs(a[i]-b1))
for i in range(n):
    ans2.append(abs(a[i]-b2))
print(min(sum(ans1),sum(ans2)))


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repe(i, n) for (ll i = 0; i <= (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
bool boo = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n, m = 1000000;
int x = 0, y = 0;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    int k;
    cin >> a >> b >> c >> k;
    m = max(max(a, b), c);
    sum = a + b + c - m;
    rep(i, k)
    {
        m *= 2;
    }
    pr(sum + m);
    return 0;
}


Measured memory_bytes: 3540
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void)
{	
	string s;
	int k;
	cin >> s >> k;
	rep(i, k) {
		if (s[i] != '1') {
			print(s[i]);
			return 0;
		}
	}
	print(1);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
a = "APPROVED"
for i in range(N):
    if(A[i] % 2 == 0 ):
        if(A[i] % 3 != 0 and A[i] % 5 != 0):
            a = "DENIED"
print(a)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
inline int popcount(const int x) { return __builtin_popcount(x);}
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

template<typename T> struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    assert(i < n);
    for (i++; i <= n; i += i&-i) d[i] += x; //LSB:i&(-i)
  }
  T sum(int i) {
    assert(i < n);
    T x = 0;
    for (i++; i; i -= i&-i) x += d[i];
    return x;
  }
  T sum(int l, int r) { //[l,r)
    assert(l < n and r <= n);
    return sum(r-1) - sum(l-1);
  }
  T operator[](const int &i) const{
    assert(i < n);
    return sum(i,i+1);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> c(n);
  rep(i, n) {
    cin >> c[i];
    c[i]--;
  }
  using P = pair<pair<int,int>, int>;
  vector<P> query(q);
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    l--; r--;
    query[i].second = i;
    query[i].first.first = r;
    query[i].first.second = l;
  }
  sort(all(query));

  BIT<int> bit(n);
  vector<int> last(n, -1);
  
  auto update = [&](int i) {
    if (last[c[i]] != -1) bit.add(last[c[i]], -1);
    last[c[i]] = i;
    bit.add(i);
  };

  int r = query[0].first.first;
  vector<int> ans(q);
  rep(i, r+1) update(i);
  ans[query[0].second] = bit.sum(query[0].first.second, query[0].first.first+1);
  rep2(i, 1, q) {
    int nr = query[i].first.first;
    rep2(i, r+1, nr+1) update(i);
    ans[query[i].second] = bit.sum(query[i].first.second, query[i].first.first+1);
    r = nr;
  }

  rep(i,q) cout << ans[i] << "\n";
  return 0;
}

Measured memory_bytes: 17448
#include <iostream>

using namespace std;

int partition(int A[], int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

int main() {
    int n;
    scanf("%d", &n);

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

    int q = partition(A, 0, n - 1);

    for (int i = 0; i < n; i++) {
        if (i > 0) {
            printf(" ");
        }
        if (i == q) {
            printf("[");
        }
        printf("%d", A[i]);
        if (i == q) {
            printf("]");
        }
    }
    printf("\n");

    return 0;
}

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

using namespace std;

int main()
{
  int a,b;
  cin >> a >> b;
  string s[100];
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(i<50) s[i].push_back('.');
      else s[i].push_back('#');
    }
  }
  int cnt = 0;
  for(int i = 0; i < 50; i += 2){
    if(cnt == b-1) break;
    for(int j = 0; j < 100; j += 2){
      if(cnt == b-1) break;
      s[i][j] = '#';
      cnt++;
    }
  }
  cnt = 0;
  for(int i = 51; i < 100; i += 2){
    if(cnt == a-1) break;
    for(int j = 0; j < 100; j += 2){
      if(cnt == a-1) break;
      s[i][j] = '.';
      cnt++;
    }
  }
  cout << 100 << " " <<  100 << endl;
  for(int i = 0; i < 100; i++){
    cout << s[i] << endl;
  }

  return 0;
}

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

template <class T>
struct BIT{
    int size;
    T ide;
    vector<T> bit;
    BIT(int n, T ide){
        size = n;
        bit.assign(size+1, this->ide = ide);
    }

    T sum(int x){
        T res = ide;
        while(x > 0){
            res += bit[x];
            x -= (x & -x);
        }
        return res;
    }

    void add(int x, T y){
        while(x <= size){
            bit[x] += y;
            x += (x & -x);
        }
    }
};

struct P{
    long long x, h;
    P(long long x, long long h) : x(x), h(h){}
    bool operator<(const P &p)const{
        return x < p.x;
    }
};

int n, a;
long long d;
vector<P> p;

int main(void){
    cin >> n >> d >> a;
    for(int i=0;i<n;i++){
        int x, h;
        cin >> x >> h;
        h = (h+a-1) / a;
        p.push_back(P(x, h));
    }
    p.push_back(P(-1, 0));
    sort(p.begin(), p.end());
    BIT<long long> bit(n, 0);
    long long ans = 0;
    for(int i=n;i>0;i--){
        long long x = p[i].x;
        long long h = p[i].h - bit.sum(i);
        if(h <= 0) continue;
        int ng = 0, ok = i;
        while(ng + 1 < ok){
            int mid = (ok + ng) / 2;
            if(p[mid].x >= x - d*2) ok = mid;
            else ng = mid;
        }
        bit.add(ok, h);
        ans += h;
    }
    cout << ans << endl;
}


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

typedef long long ll;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    deque<ll> D;
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        ll v;
        cin >> v;
        D.push_back(v);
    }

    ll ans = 0;
    for (int i = 0; i <= min(N, K); i++)
    {
        ll sum_r = 0;
        for (int l = 0; l <= i; l++)
        {

            int r = i - l;

            v<ll> hand;
            ll sum = 0;

            for (int j = 0; j < l; j++)
            {
                hand.push_back(D[j]);
            }
            for (int j = 0; j < r; j++)
            {
                hand.push_back(D[D.size() - 1 - j]);
            }
            if (hand.size() > 0)
            {
                sort(ALL(hand), greater<int>());

                for (int j = 0; j < K - i; j++)
                {
                    if (hand[hand.size() - 1] < 0)
                        hand.pop_back();
                }

                for (int j = 0; j < hand.size(); j++)
                {
                    sum += hand[j];
                }
                sum_r = max(sum, sum_r);
            }
        }
        ans = max(sum_r, ans);
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n),b(n-1);
	rep(i, n - 1) cin >> b[i];
	ll ans = 0;
	rep(i, n) {
		if (i == 0) {
			a[i] = b[i];
			continue;
		}
		if (i == n - 1) {
			a[i] = b[i - 1];
			continue;
		}
		a[i] = min(b[i], b[i - 1]);
	}
	rep(i, n) ans += a[i];
	cout << ans << endl;
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]==b:
                A[j][k] = -1

aa = False

while(1):
    #縦
    for i in range(3):
        for j in range(3):
            if A[i][j] != -1:
                break
        else:
            print("Yes")
            aa = True
            break
    if aa:
        break

    #yoko
    for i in range(3):
        for j in range(3):
            if A[j][i] != -1:
                break
        else:
            print("Yes")
            aa = True
            break
    if aa:
        break
    
    #斜め
    if A[0][0]==-1 and A[1][1]==-1 and A[2][2]==-1:
        print("Yes")
        break
    if A[2][0]==-1 and A[1][1]==-1 and A[0][2]==-1:
        print("Yes")
        break

    print("No")
    break

    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int main()  
{     
    ll n,k,x,y;
    cin>>n>>k;
    cin>>x>>y;
    if(n<=k)
        cout<<x*n;
    else
    cout<<x*k+y*(n-k);
}   

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


class BIT(object):
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        #  ?????????????????????????????¢?????????????¶?????????????
        while i > 0:
            s += self.bit[i]
#            i &= (i - 1)
            i -= (i & -i)

        return s

    def add(self, i, x):
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def find(self, s, t):
        t_sum = self.sum(t)
        s_sum = self.sum(s - 1)
        return t_sum - s_sum


def main(args):
    n, q = map(int, input().split(' '))

    rq = BIT(n+1)
    for _ in range(q):
        com, x, y = map(int, input().split(' '))
        if com == 0:
            rq.add(x, y)
        elif com == 1:
            res = rq.find(x, y)
            print(res)


if __name__ == '__main__':
    main(sys.argv[1:])

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

int main(){
  int N;
  cin >> N;
  int ans=0,ten=10;
  while(N/ten){
    ans+=ten*9/10;
    ten=ten*100;
  }
  ten=ten/10;
  if(N/ten){
    ans+=N-ten+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> prime;
void setPrime(int x)
{
  for (int i=2; i<x; i++) {
    bool ok = true;
    for (int e:prime) {
      if (i%e==0) {
        ok = false;
        break;
      }
      if (e*e>i) break;
    }
    if (ok) prime.push_back(i);
  }
}

bool isPrime(int x)
{
  for(int e:prime) {
    if (x%e==0) return false;
    if (e*e>x) break;
  }
  return true;
}

int main()
{
  int x;
  cin >> x;
  setPrime(x);
  while(!isPrime(x)) {
    x++;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 384
/* ex5-4
    toshiwaka */

#include <stdio.h>
#include <string.h>

//最長部分文字列の長さを取得
int get_max_len(char *ptr);

int main(void) {
  //入力は10文字以内なのでstrの最大要素数は\0を含めて11
  char str[11];

  //入力
  scanf("%s", str);

  //結果を出力
  printf("%d\n", get_max_len(str));

  return 0;
}

//最長部分文字列の長さを取得
int get_max_len(char *ptr){
  int len = 0, max_len = 0;
  while(*ptr){
    switch(*ptr){
      //要素が'A''G''C''T'の時
      case 'A':
      case 'G':
      case 'C':
      case 'T':
        //lenの値を更新
        //lenがmax_lenより大きければlen_maxの値を更新
        len++;
        if(len > max_len) max_len = len;
        break;
      //それ以外の時
      default:
        //lenの値を初期化
        len = 0;
        break;
    }
    ptr++;
  }
  //最長部分文字列の長さを返す
  return max_len;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    unordered_set<char> appeared;
    for (const char c : S) {
        if (appeared.find(c) != appeared.end()) {
            cout << "no" << "\n";
            return 0;
        }
        appeared.emplace(c);
    }
    cout << "yes" << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);
        var RSP = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (R, S, P) = (RSP[0], RSP[1], RSP[2]);
        var T = ReadLine();

        var Hand2Point = new Dictionary<char, int>() { { 'r', R }, { 's', S }, { 'p', P } };
        var WinHand = new Dictionary<char, char>() { { 'r', 'p' }, { 's', 'r' }, { 'p', 's' } };

        IEnumerable<char> GetSkipT(int n)
        {
            for (int i = n; i < T.Length; i += K)
                yield return T[i];
        }

        var skipT = Enumerable.Range(0, K).Select(x => GetSkipT(x).ToArray()).ToArray();

        var ans = 0;

        for (int i = 0; i < K; i++)
        {
            var point = 0;
            var _point = 0;

            var prevWinHand = ' ';

            for (int j = 0; j < skipT[i].Length; j++)
            {
                var enemyHand = skipT[i][j];
                var winHand = WinHand[enemyHand];

                var prevPoint = point;

                if (winHand == prevWinHand)
                {
                    point = _point + Hand2Point[winHand];
                }
                else
                {
                    point += Hand2Point[winHand];
                }

                _point = prevPoint;

                prevWinHand = winHand;
            }

            ans += point;
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 38812
import sys
def input():
    return sys.stdin.readline()
def scoring(ans, d, t, C, S, L, replace = False):
    ans += S[d][t]
    penalty = sum([c * (d - l) for i, (c, l) in enumerate(zip(C, L)) if i != t])
    ans -= penalty
    if replace:
        return ans, [l if i != t else d for i, l in enumerate(L) ], penalty
    else:
        return ans
def scoring_2(ans, d, t, C, S, L, replace = False):
    ans += S[d][t]
    ans -= sum([c * pow(d - l, 2) for i, (c, l) in enumerate(zip(C, L)) if i != t])
    return ans

def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]
    L = [-1] * 26
    ans = 0
    for d in range(D):
        SCORE = [scoring_2(ans, d, t, C, S, L) for t in range(26)]
        t_max = SCORE.index(max(SCORE))
        ans, L, p = scoring(ans, d, t_max, C, S, L, replace = True)
        print(t_max + 1)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 9512
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	vi d(n);
	rep(i,0,n) cin>>d[i];
	sort(all(d));
	reverse(all(d));
	int ans=c/a,sum=c;
	rep(i,0,n){
		sum+=d[i];
		int tmp=sum/(a+b*(i+1));
		ans=max(ans,tmp);
	}
	o(ans);
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  bool b=1;
  sort(a.begin(),a.end());
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      b=0;
    }
  }
  if(b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    for(int i=a; i<=min(b,a+k-1);i++)
        cout << i << endl;
    for(int i= max(b-k+1,a+k); i<=b; i++)
        cout << i << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  ll ans = 1;
  int now = 0;
  for (int i = 0; i < n; i++) {
    now += l[i];
    if (now <= x) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
Marked Ancestor(https://onlinejudge.u-aizu.ac.jp/#/problems/2170)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<char, ll> query;

ll N, Q, ans;

//parent, nearest marked ancestor, ismarked
vector <ll> par, nma, ism;
vector <query> q;

//find nearest marked ancestor (経路圧縮 at the same time)
ll find_nma(ll x){
	if (nma[x] == x) return x;
	else return nma[x] = find_nma(par[x]);
}

void solve(void){
	ENJYU;
	while (cin >> N >> Q) {
		if (N == 0 && Q == 0) break;
		//init
		par.clear(), ism.clear(), nma.clear(), q.clear();
		par.resize(N), ism.resize(N), nma.resize(N), q.resize(Q);
		par[0] = 0, ism[0] = 1, nma[0] = 0;
		ans = 0LL;
		rep(N-1, i) {
			cin >> par[i+1];
			par[i+1]--;
		}
		nma = par;

		//クエリ受け取り
		rep(Q, i) {
			cin >> q[i].fst >> q[i].snd;
			q[i].snd--;
			//先にMARKしておく
			if (q[i].fst == 'M') {
				ism[q[i].snd]++;
				nma[q[i].snd] = q[i].snd;
			}
		}

		//クエリを逆から見ていくと、頂点の更新は根の方向にのみ行われるので、前回の結果を使える
		repr(Q, i) {
			if (q[i].fst == 'M') {
				ism[q[i].snd]--;
				if (!ism[q[i].snd]) nma[q[i].snd] = find_nma(par[q[i].snd]);
				continue;
			}
			ans += find_nma(q[i].snd) + 1;
		}
		cout << ans << endl;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 7532
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main()
{
    string s;
    cin >> s;
    set<char> st;
    for (auto c : s) {
        st.insert(c);
    }
    if (s.size() == st.size()) {
        cout << "yes";
    } else {
        cout << "no";
    }
    return 0;
}

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

using namespace std;

#define AC return 0

typedef long long ll;

const int inf = 0x3f3f3f3f;

int n, k;
int arr[100010];

bool pd(int mid) {
	int now = 0;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (mid < arr[i]) return false;
		if (now + arr[i] <= mid) now += arr[i];
		else {
			now = arr[i];
			++ans;
		}
	}
	if (now) ++ans;
	return ans <= k;
}

int main() {
	int l = 0, r = inf;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &arr[i]);
	}
	while (l < r) {
		int mid = l + r >> 1;
		if (pd(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", l);
	AC;
}


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



using namespace std;



using ll = long long;



int main(){

  ll a, b, k;

  cin >> a >> b >> k;

  cin.ignore();



  ll cnt = 0;

  if(a < k){

    k -= a;



    if(b < k){

      cout << 0 << " " << 0 << endl;

      return 0;

    } else { // b >= k

      

      cout << 0 << " " << (b - k) << endl;

      return 0;

    }

  } else { // a >= k

    a -= k;

    cout << a << " " << b << endl;

  }

  return 0;

}

      



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  cout << (k > 1 ? n - k : 0) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)	
const int INF = 1e9;

int n, m;
int main(void){
	cin >> n >> m;
	vector<pair<int, int> > p;
	rep(i, m){
		int x, y; cin >> x >> y;
		y--;
		p.push_back(make_pair(x, y));
	}
	sort(p.begin(), p.end());

	vector<pair<int, int> > seg(n);
	rep(i, n){
		seg[i] = make_pair(i, i);
	}

	rep(i, p.size()){
		int nx = p[i].first, ny = p[i].second;
		// printf("ny %d\n", ny);
		int l = seg[ny].first;
		int r = seg[ny + 1].second;
		// printf("%d %d \n", l, r);
		seg[ny] = make_pair(l, r);
		seg[ny + 1] = make_pair(l, r);
	}

	rep(i, n){
		if(i != n - 1)printf("%d ", seg[i].second - seg[i].first + 1);
		else printf("%d\n", seg[i].second - seg[i].first + 1);
	}
	return 0;
}

Measured memory_bytes: 5156
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split(" ");
  var N = Number(input[0]);
  var K = Number(input[1]);

  var result = N.toString(K);

  console.log(result.length);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const long long MOD = 1000000007;
long long x[200010] ;

ll fst(ll a, ll b){
    if (!b) {
        return 1;
    }

    ll sq=fst(a, (b>>1LL));
    sq*=sq;

    if (b&1) {
        sq%=MOD;
        sq*=a;
    }

    return sq%MOD;
}

long long inv (long long n){
    return fst (n,MOD-2) ;
}

long long c(long long n, long long k) {
    return x[n]*inv(x[k])%MOD *inv(x[n-k])%MOD;
}

int main ()
{
int n , k ;
cin >> n >> k ;
x[0]=1;
for (int i = 1 ; i <= n ; i ++)
    x[i]= (i*x[i-1])%MOD ;
int l;
if (k>n) l = n;
else l=k+1;
long long ans =0 ;
for (int i = 0 ; i < l ; i++){
    ans += c(n,i)*c(n-i+(i-1),i)%MOD ;
    ans %=MOD;
}
cout << ans ;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int a,b,c; cin >> a >> b >> c;
    int x = max({a,b,c});
    cout << (a+b+c)-x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,k;
        string s;
        cin>>n>>k>>s;
        vl V;
        if(s[0]=='0')V.pb(0);
        for(ll i=0;i<Size(s);){
            ll x=i;
            while(x<Size(s)&&s[x]==s[i])x++;
            V.pb(x-i);
            i=x;
        }
        if(s[Size(s)]=='0')V.pb(0);
        vl S(Size(V)+1,0);
        rep(i,Size(V))S[i+1]=S[i]+V[i];
        ll ans=0;
        for(ll i=0;i<Size(S);i+=2){
            ll r=i+k*2+1;
            if(r>=Size(S))r=Size(S)-1;
            chmax(ans,S[r]-S[i]);
        }
        cout<<ans<<endl;
    }

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

int main(){
  int a,b;cin>>a>>b;
  if(a <= 0 && 0 <= b) cout << "Zero";
  else if(a > 0) cout << "Positive";
  else {
    int num = b - a + 1;
    if(num&1) cout << "Negative";
    else cout << "Positive";
  }
  cout << endl;
  return 0;
}

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

class Node{
public:
	vector< int > e_to;
	vector< int > e_cost;
	
	bool def;
	int min_cost;
	
	Node(){
		def = false;
		min_cost = -1;
	}
};
bool operator==(const Node& ot1, const Node& ot2){
	return ot1.min_cost == ot2.min_cost;
}
bool operator!=(const Node& ot1, const Node& ot2){
	return !(ot1 == ot2);
}
bool operator<(const Node& ot1, const Node& ot2){
	return ot1.min_cost < ot2.min_cost;
}
bool operator>(const Node& ot1, const Node& ot2){
	return ot1.min_cost > ot2.min_cost;
}
bool operator<=(const Node& ot1, const Node& ot2){
	return !(ot1 > ot2);
}
bool operator>=(const Node& ot1, const Node& ot2){
	return !(ot1 < ot2);
}

class Dijkstra{
	priority_queue< Node, vector< Node >, greater< Node > > que;
	vector< Node > nodes;
	
public:
	void Init(int node_num){
		nodes.resize(node_num);
		for(int i = 0; i < node_num; ++i){
			nodes[i] = Node();
		}
	}
	
	void Put(int id, int to, int cost){
		nodes[id].e_to.push_back(to);
		nodes[id].e_cost.push_back(cost);
	}
	
	int Run(int s){
		int sum = 0;
		
		for(vector< Node >::iterator it = nodes.begin(); it != nodes.end(); ++it){
			it->min_cost = -1;
			it->def = false;
		}
		
		nodes[s].min_cost = 0;
		que.push(nodes[s]);
		
		while(!que.empty()){
			Node def_node = que.top();
			que.pop();
		
			if(def_node.def)continue;
		
			def_node.def = true;
		
			for(int i = 0; i < def_node.e_to.size(); ++i){
				int to = def_node.e_to[i];
				int cost = def_node.min_cost + def_node.e_cost[i];
				
				if(nodes[to].min_cost == -1 || cost < nodes[to].min_cost){
					nodes[to].min_cost = cost;
					que.push(nodes[to]);
				}
			}
		}
		
		for(vector< Node >::iterator it = nodes.begin(); it != nodes.end(); ++it){
			if(it -> min_cost != -1){
				sum += it->min_cost;
			}
		}
		
		return sum;
	}
};

int main(){
	int n, s, t, w;
	Dijkstra dijk;
	
	while(cin >> n, n){
		dijk.Init(10);
		int m = 0;
		int min = ~(1 << 31);
		int mint;
		
		for(int i = 0; i < n; ++i){
			cin >> s >> t >> w;
			dijk.Put(s, t, w);
			dijk.Put(t, s, w);
			m = max(max(m, s), t);
		}
		
		for(int i = 0; i < m + 1; ++i){
			int r = dijk.Run(i);
			
			if(r < min){
				min = r;
				mint = i;
			}
		}
		cout << mint << " " << min << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){

  int N,L,i,j;
  scanf("%d",&N);
  scanf("%d",&L);
  int taste_N = 0;
  int taste[N];
  int small;

  for(i=0;i<N;i++){
    taste_N = taste_N + L + i;
  }

  for(i=0;i<N;i++){
    taste[i] = 0;
    for(j=0;j<N;j++){
      if(i != j)
        taste[i] = taste[i] + L + j;
    }
  }

  small = taste[0];


  for(i=0;i<N-1;i++){
    if(abs(taste_N - taste[i]) > abs(taste_N - taste[i+1]))
      small = taste[i+1];
  }

  printf("%d\n",small);

  return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    print('YES' if N==5 or N==7 or N==3 else 'NO')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;    // Allowable Error
typedef complex<double> P;  // Point
#define X real()
#define Y imag()
double norm(P& p1,P& p2){
    return (p1.X-p2.X)*(p1.X-p2.X)+(p1.Y-p2.Y)*(p1.Y-p2.Y);
}
namespace std{
    bool operator < (const P p1, const P p2){
        return p1.X != p2.X ? p1.X <p2.X : p1.Y < p2.Y;
    }
    P operator + (const P p1,const P p2) {return P(p1.X+p2.X,p1.Y+p2.Y);}
    P operator - (const P p1,const P p2) {return P(p1.X-p2.X,p1.Y-p2.Y);}
    P operator * (const P p,double k) {return P(p.X*k,p.Y*k);}
    P operator / (const P p,double k) {return P(p.X/k,p.Y/k);}
}
//Line
struct Segment{
    P p1,p2;
    Segment(){}
    Segment(P p1,P p2):p1(p1),p2(p2){}
};
typedef Segment Line;
//Inner Product dot(a,b) = |a||b|cosÃŽÂ¸
double dot(const P& a, const P& b) {
  return (conj(a)*b).X;
}
P Projection(Line l,P p){
    P base=l.p2-l.p1;
    double r=dot(p-l.p1,base)/norm(base);
    return l.p1+base*r;
}

//Verify
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A
int main(){
    double x1,x2,y1,y2,x,y;
    cin>>x1>>y1>>x2>>y2;
    Line l=Line(P(x1,y1),P(x2,y2));
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>x>>y;
        P p=Projection(l,P(x,y));
        printf("%.10f %.10f\n",p.X,p.Y);
    }

    return 0;
}



Measured memory_bytes: 3348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_119
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            double val = 0;
            for (int i = 0; i < n; i++)
            {
                string[] str = Read().Split();

                if (str[1][0] == 'J')
                {
                    val += double.Parse(str[0]);
                }
                else
                {
                    val += double.Parse(str[0]) * 380000;
                }
            }
            WriteLine(val);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

struct node{
  int co=-1;
  vector<node*> l;
};

int main(void){
  int n,i,j,a,b;
  node nl[100005];
  cin >> n;
  for (i=0;i<n-1;i++){
    cin >> a >> b;
    nl[a-1].l.push_back(&nl[b-1]);
    nl[b-1].l.push_back(&nl[a-1]);
  }
  queue<node*> nq[2];
  node *k;
  nq[0].push(&nl[0]);
  nq[1].push(&nl[n-1]);
  int e=0,s;
  while (1){
    s=nq[e].size();
    for (i=0;i<s;i++){
      k=nq[e].front();
      nq[e].pop();
      if (k->co==1-e) break;
      k->co=e;
      for (j=k->l.size()-1;j>=0;j--) if (k->l[j]->co==-1) nq[e].push(k->l[j]);
    }
    if (i!=s) break;
    e=1-e;
  }
  bool con=true;
  while (con){
    con=false;
    for (i=0;i<n;i++){
      for (j=nl[i].l.size()-1;j>=0;j--){
        if (nl[i].co==-1) con=true;
        else if (nl[i].l[j]->co==-1) nl[i].l[j]->co=nl[i].co;
      }
    }
  }
  int f=0;
  for (i=0;i<n;i++) if (nl[i].co==0) f++;
  if (f*2>n) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    vector<int> s,t;
    rep(i,n) {
        cin >> a[i];
        if (a[i]<0) t.push_back(a[i]);
        else s.push_back(a[i]);
    }

    int S = sz(s);
    int T = sz(t);
    bool ok = false; //正にできるか
    if (S > 0) {
        if (n==k) ok = (T%2==0);
        else ok = true;
    } else {
        ok = (k%2==0);
    }

    mint ans = 1;
    if (!ok) { //正にできない場合
        sort(all(a), [](int x, int y) {
            return abs(x) < abs(y);
        }); //絶対値が小さい順にソート
        rep(i,k) ans *= a[i];
    } else {
        sort(all(s));
        sort(rall(t));
        if ((k%2) == 1) {
            ans *= s.back();
            s.pop_back();
        }
        vector<ll> p;
        while (sz(s) >= 2) {
            ll x = s.back(); s.pop_back();
            x *= s.back(); s.pop_back();
            p.push_back(x);
        }
        while (sz(t) >= 2) {
            ll x = t.back(); t.pop_back();
            x *= t.back(); t.pop_back();
            p.push_back(x);
        }
        sort(rall(p));
        rep(i,k/2) ans *= p[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 6404
#include<stdio.h>
 int main(void){
char s[5];
scanf("%s",s);
 if(s[0]==s[1]&&s[1]==s[2]){
 printf("Yes\n");
 }else if(s[1]==s[2]&&s[2]==s[3]){
 printf("Yes\n");
 }else if(s[2]==s[3]&&s[3]==s[4]){
   printf("Yes\n");
 }else{
   printf("No\n");
 }
 
 return 0;
 }

Measured memory_bytes: 128
from itertools import product
import numpy as np

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i, j in product(range(N-M+1), repeat=2):
  if np.prod([A[i+k][j:j+M] == B[k] for k in range(M)]):
    print('Yes')
    break
else:
  print('No')

Measured memory_bytes: 27256