akhauriyash/Code-Regression huggingface dataset:
h,w = map(int,input().split())
c = list(map(int,input().split()))
c[0] -= 1
c[1] -= 1
d = list(map(int,input().split()))
d[0] -= 1
d[1] -= 1
p = []
q = [[None for i in range(w)]for i in range(h)]
r = [[] for i in range(10**6)]
for i in range(h):
    s = input()
    s = list(s)
    p.append(s)
from collections import deque
de = deque()
de.append([c[0],c[1]])
q[c[0]][c[1]] = 0
g = 0
while q[d[0]][d[1]] == None and g < 10**6-3:
    while de:
        v = de.pop()
        r[g].append([v[0],v[1]])
        for i in (-1,1):
            j = 0
            if 0 <= v[0]-i <= h-1:
                if 0 <= v[1]-j <= w-1:
                    if p[v[0]-i][v[1]-j] == '.' and q[v[0]-i][v[1]-j] == None:
                        q[v[0]-i][v[1]-j] = g
                        de.append([v[0]-i,v[1]-j])
        for j in (-1,1):
            i = 0
            if 0 <= v[0]-i <= h-1:
                if 0 <= v[1]-j <= w-1:
                    if p[v[0]-i][v[1]-j] == '.' and q[v[0]-i][v[1]-j] == None:
                        q[v[0]-i][v[1]-j] = g
                        de.append([v[0]-i,v[1]-j])
    g += 1
    while r[g-1]:
        v = r[g-1].pop()
        for i in range(-2,3):
            for j in range(-2,3):
                if (abs(i) == 1 and j == 0) or (abs(j) == 1 and i == 0):
                    continue
                else:
                    if 0 <= v[0]-i <= h-1:
                        if 0 <= v[1]-j <= w-1:
                            if p[v[0]-i][v[1]-j] == '.' and q[v[0]-i][v[1]-j] == None:
                                q[v[0]-i][v[1]-j] = g
                                de.append([v[0]-i,v[1]-j])
if q[d[0]][d[1]] == None:
    print(-1)
else:
    print(q[d[0]][d[1]])

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

long long A,B,C;

int solve(){
  for (int i=0;i<1000;++i){
    if (A & 1) return i;
    if (B & 1) return i;
    if (C & 1) return i;
    long long tA=(B+C)/2;
    long long tB=(A+C)/2;
    long long tC=(B+A)/2;
    A=tA,B=tB,C=tC;
  }
  return -1;
}

int main(){
  cin >>A>>B>>C;
  cout<<solve()<<endl;
}

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

int main(){
	char str1[11],str2[11],str3[11];
	int lastchar1,lastchar2;
	scanf("%s %s %s", str1, str2, str3);
	if((str1[strlen(str1)-1]==str2[0])&&(str2[strlen(str2)-1]==str3[0])){
		printf("YES");
	}
	else{
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 1720
n = int(input())
a = list(map(int, input().split()))

ans = 0
abs_mina = 10 ** 10
import copy
copy_a = copy.copy(a)
sum_a = 0

for i in range(n - 1):
    if copy_a[i] < 0:
        copy_a[i] *= -1
        copy_a[i + 1] *= -1

for i in a:
    ans += abs(i)
    abs_mina = min(abs_mina, abs(i))

if copy_a[-1] < 0:
    ans -= abs_mina * 2


print(ans)

Measured memory_bytes: 14332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for (int i = 0; i < tx-sx; ++i) {
        cout << "R";
    }
    for (int i = 0; i < ty-sy; ++i) {
        cout << "U";
    }
    for (int i = 0; i < tx-sx; ++i) {
        cout << "L";
    }
    for (int i = 0; i < ty-sy; ++i) {
        cout << "D";
    }
    cout << "D";
    for (int i = 0; i < tx-sx+1; ++i) {
        cout << "R";
    }
    for (int i = 0; i < ty-sy + 1; ++i) {
        cout << "U";
    }
    cout << "L";
    cout << "U";
    for (int i = 0; i < tx-sx+1; ++i) {
        cout << "L";
    }
    for (int i = 0; i < ty-sy+1; ++i) {
        cout << "D";
    }
    cout << "R";
    cout << endl;
}


Measured memory_bytes: 256
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define rep( i, n )    for( lint i= 0  ; i <  (n) ; ++i )
#define all( v )       (v).begin(), (v).end()

int main() {
    vector<int> osatsu({1,6,9,36,81,216,729,1296,6561,7776,46656,59049});
    int N;
    cin >> N;

    vector<int> dp(N+1,0);
    for( int i=1; i<=N; i++ ) {
        int min_ = INT_MAX;
        int min_index;
        for( int j : osatsu ) {
            if( i - j >= 0 && dp[i-j] < min_ ) {
                min_ = dp[i-j];
                min_index = i-j;
            }
        }
        dp[i] = dp[min_index] + 1;
    }

    cout << dp[N] << endl;
}


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

int main(){
  string s; cin >> s;
  int l = s.size();
  if (s[l-1] == '1' || s[0] == '0') {
    cout << -1 << endl;
    return 0;
  }
  vector<int> u(l-1), v(l-1); int num = 2; int now = 1;
  for (int i = 0; i*2 <= l-2; i++) {
    if (s[i] != s[l-i-2]) {
      cout << -1 << endl;
      return 0;
    }
    if (s[i] == '1') {
      u[i] = now; v[i] = num;
      now = num; num++;
    } else {
      u[i] = now; v[i] = num; num++;
    }
  }
  for (int i = 0; i*2 <= l-2; i++) {
    cout << u[i] << " " << v[i] << endl;
  }
  for (; num <= l; num++) {
    cout << now << " " << num << endl;
  }
  return 0;
}


Measured memory_bytes: 2432
from math import sqrt


def sieve(x):
    """
    Sieve of Eratosthenes
    :param x: max value
    :return: list of primes
    """

    primes = []
    li = list(range(2, x + 1))

    while li[0] <= sqrt(x):
        p = li[0]
        primes.append(p)
        li = [e for e in li if e % p != 0]

    primes += li
    return primes


n = int(input())

primes = sieve(55555)
mod5is1 = [e for e in primes if e % 5 == 1]
ans = mod5is1[:n]
print(*ans)


Measured memory_bytes: 5492
#include<iostream>
#include<stdio.h>
#include<vector>

using namespace std;


int main()
{
    int N, K, T, U, V, L;
    cin >> N >> K >> T >> U >> V >> L;
    
    vector<int> D(N);
    for(auto &d : D)
    {
        cin >> d;
    }

    double ans = 0.0;

    int speed = 0;
    int acceledDistance = 0;
    int d_sub = 0;
    int nowStock = 0;
    
    /*
    ?????????????????? -> ?£???????
    ?????????????????? -> ????????????
        ??????????????§????????? -> ?£???????
    */

    for(int i = 0; i < L; i++)
    {
        //?????????????????????
        if(D[d_sub] == i)
        {
            d_sub = min(d_sub + 1, (int)(D.size() - 1));
            speed = V;
            
            if(nowStock == K)acceledDistance = T * V;
            else
            {
                ++nowStock;
                if(acceledDistance == 0)
                {
                    acceledDistance = T * V;
                    --nowStock;
                }
            }

            --acceledDistance;
            if(acceledDistance == 0 && nowStock > 0)
            {
                --nowStock;
                acceledDistance = T * V;
            }
        }
        else
        {
            speed = U;
            if(acceledDistance > 0)
            {
                speed = V;
                --acceledDistance;
                if(acceledDistance == 0 && nowStock > 0)
                {
                    --nowStock;
                    acceledDistance = T * V;
                }
            }
        }

        ans += 1.0 / speed;//((acceledDistance > 0) ? V : U);
    }
    printf("%.6lf\n", ans);

    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  cin >> s;

  int n = s.length();
  rep(i, n) {
    rep(j, i) {
      if (s[j] == 'C' && s[i] == 'F') {
        cout << "Yes" << '\n';
        return 0;
      }
    }
  }
  cout << "No" << '\n';


  
  return 0;
}

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

sum = as.reduce(&:+)

cnt = 0

as.each do |a|
  if a * m * 4 >= sum
    cnt += 1
  end
end

if cnt >= m
  puts 'Yes'
else
  puts 'No'
end



Measured memory_bytes: 1788
N, M = [int(i) for i in input().split()]
data_ls = list()
for i in range(M):
    data_ls.append([int(i) -1 for i in input().split()])
A_ls, B_ls = zip(*data_ls)
conv_ls = list()

par = list(range(N))
rank = [1] * N

def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)
    if rank[x] < rank[y]:
        par[x] = y
        rank[y] += rank[x]
        rank[x] = rank[y]
    else:
        par[y] = x
        rank[x] += rank[y]
        rank[y] = rank[x]

def is_same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False

def ranking(x):
    return rank[find(x)]

def main():
    conv_ls.append(0)
    for i, (x,y) in enumerate(data_ls[::-1]):
        N1 = ranking(x)
        N2 = ranking(y)
        if is_same(x, y):
            conv_ls.append(conv_ls[i])
        else:
            conv_ls.append(conv_ls[i] + N1 * N2)
            unite(x,y)
    for conv in conv_ls[::-1][1:]:
        print(int(N * (N - 1) / 2 - conv))

main()

Measured memory_bytes: 34532
import copy

h, w, k = map(int, input().split())
c = [list(map(int, list(input()))) for _ in range(h)]
c.insert(0, [0] * w)
maxscore = 0
for i in range(1, h + 1):
    for j in range(w):
        if i == 1:
            maxscore = max(maxscore, c[i][j])
        else:
            s = copy.deepcopy(c)
            s[i][j] = 0
            score = 0
            p = 1
            while True:
                for m in range(w):
                    z = 0
                    x = []
                    for l in range(i + 1):
                        if s[l][m] != 0:
                            x.append(s[l][m])
                    x = [0] * (i + 1 - len(x)) + x
                    for l in range(i + 1):
                        s[l][m] = x[l]
                b = 0
                for l in range(1, i + 1):
                    n = s[l][0]
                    cnt = 0
                    for m in range(w):
                        if s[l][m] == n and s[l][m] != 0:
                            cnt += 1
                        else:
                            if cnt >= k:
                                b = 1
                                for ii in range(m - cnt, m):
                                    s[l][ii] = 0
                                    score += p * n
                            n = s[l][m]
                            if s[l][m] != 0:
                                cnt = 1
                            else:
                                cnt = 0
                    if cnt >= k:
                        b = 1
                        for ii in range(w - cnt, w):
                            s[l][ii] = 0
                            score += p * n
                if b == 0:
                    break
                p *= 2
            maxscore = max(maxscore, score)

print(maxscore)

Measured memory_bytes: 56284
N = int(input())
a = list(map(int, input().split()))
gray = 0
brown = 0
green = 0
sky = 0
blue = 0
yellow = 0
orange = 0
red = 0
god = 0
for i in range(N):
    if a[i] < 400:
        gray = 1
    elif a[i] < 800:
        brown = 1
    elif a[i] < 1200:
        green = 1
    elif a[i] < 1600:
        sky = 1
    elif a[i] < 2000:
        blue = 1
    elif a[i] < 2400:
        yellow = 1
    elif a[i] < 2800:
        orange = 1
    elif a[i] < 3200:
        red = 1
    else:
        god+=1
zako = gray + brown + green + sky + blue + yellow + orange + red
if god > 0 and zako == 0:
    color_max = god
    color_min = 1
elif god > 0 and zako != 0:
    color_max = zako + god
    color_min = zako
else:
    color_max = zako
    color_min = zako
print(color_min, color_max)

Measured memory_bytes: 3064
N, M = map(int,input().split())
crain = (4 * N - M) / 2
t = N - crain
if crain.is_integer() and crain > 0:
  if t.is_integer() and t >= 0:
    print("Yes")
  else:
    print("No")
elif t.is_integer() and t > 0:
  if crain.is_integer() and crain >= 0:
    print("Yes")
  else:
    print("No")
else:
    print('No')

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  i64 ans = 1;
  rep(i, N) {
    i64 t; cin >> t;
    ans = lcm(ans, t);
  }
  cout << ans << '\n';
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vpll a(n);
  rep(i,n){
    ll x,y; cin>>x>>y;
    a[i]={x,y};
  }
  vpll b(m);
  rep(i,m){
    ll x,y; cin>>x>>y;
    b[i]={x,y};
  }
  rep(i,n){
    ll min=INF,ans;
    rep(j,m){
      // cout<<abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second)<<endl;
      if(chmin(min,abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second))){
        // cout<<a[i].first<<" "<<b[i].first<<endl;
        ans=j+1;
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
foods=[0 for i in range(m)]
for i in range(n):
	buf=list(map(int,input().split()))
	k=buf[0]
	for i in range(k):
		foods[buf[i+1]-1]+=1
		
num=0
for i in range(m):
	if foods[i]==n:
		num+=1

print(num)

Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int A;
  int B;
  int C;
  rd(A);
  rd(B);
  rd(C);
  if(A > B){
    swap(A, B);
  }
  ;
  if(A<C && C<B){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// {
//   int A,B,C;
//   rd(A,B,C);
//   sortE(A,B);
//   wt(if[A<C<B, "Yes", "No"]);
// }


Measured memory_bytes: 256
// ABC84-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

int n=100000;
vector<bool> is_prime(100010,true);
void hurui(){
    for(int i=2;i<=n;i++){
        int num=2*i,seki=2;
        while(num<=n){
            is_prime[num]=false;
            seki++;
            num=seki*i;
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int q;
    cin>>q;
    is_prime[0]=false,is_prime[1]=false;
    hurui();
    vector<int> rui(100010,0);
    for(int i=3;i<=n;i++){
        if(i%2==0) rui[i]=rui[i-1];
        else{
            if(is_prime[i] && is_prime[(i+1)/2]){
                rui[i]=rui[i-1]+1;
            }else{
                rui[i]=rui[i-1];
            }
        }
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<rui[r]-rui[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    map<ll, ll> mp[220000];
    rep(i, 0, m) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        mp[a][b] = 1, mp[b][a] = 1;
    }
    rep(i, 1, n-1) {
        if (mp[0][i] == 1 && mp[i][n-1] == 1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 48000
import java.util.Scanner;
import java.text.DecimalFormat;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		DecimalFormat df = new DecimalFormat();
		df.applyLocalizedPattern("0.000");
		
		while (true)
		{
			try
			{
				double a = sc.nextInt();
				double b = sc.nextInt();
				double c = sc.nextInt();
				double d = sc.nextInt();
				double e = sc.nextInt();
				double f = sc.nextInt();
				
				double x = (e * c - b * f) / (a * e - b * d);
				double y = (a * f - d * c) / (a * e - b * d);
				
				if (x == 0.0) x = 0.0;
				
				System.out.print(df.format(x) + " ");
				System.out.println(df.format(y));
			}
			catch(Exception e)
			{
				break;
			}
		}
	}
}

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

int main() { 
    ll n,k;
    std::cin >> n>>k;
    vector<ll> a(n);
    vector<ll> next(n,0);
    map<ll,ll> ex;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n*2; i++) {
        if(ex.find(a[i%n])==ex.end()){
            ex[a[i%n]] = i%n;
        }else{
            next[ex[a[i%n]]] = i%n;
            ex[a[i%n]] = i%n;
        }
    }
    
    ll per = 1;
    {
        ll now = 0;
        bool ok = true;
        while(now!=0||ok){
            ok=false;
            if(now>=next[now]){
                per++;
            }
            now = next[now]+1;
            now %= n;
        }
    }
    k %= per;
    
    vector<ll> ans;
    
    ll now = 0;
    k--;
    if(k==-1){
        std::cout << std::endl;
        return 0;
    }
    while(true){
        if(now>=next[now]){
            if(k){
                k--;
                now = next[now]+1;
            }else{
                ans.push_back(a[now]);
                now++;
            }
        }else{
            now = next[now]+1;
        }
        if(now==n){
            if(k){
                k--;
                now=0;
            }else{
                break;
            }
        }
    }
    for (auto e : ans) {
        std::cout << e<<" ";
    }
    std::cout << std::endl;
}

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

using namespace std;
int main() {
    string s; cin >> s;
    int l, r;
    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'A') {
            l = i;
            break;
        }
    }
    for(int i = s.length() - 1; i >= 0; i--) {
        if(s[i] == 'Z') {
            r = i;
            break;
        }
    }
    cout << r - l + 1;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
	cin>>n>>k;long long res=0;
	if(k==0){
		printf("%lld",1ll*n*n);return 0;
	}
	for(int i=k+1;i<=n;++i){
		res+=(i-k)*(n/i);
		int x=n%i;
		res+=max(0,x-k+1);//cout<<res<<endl;
	}cout<<res;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int dp[3001][50];
const static int MOD = 100000;

int main(){
  int bingo_card_size;
  int upper_number;
  int bingo_card_sum;
  while(~scanf("%d %d %d",
	       &bingo_card_size,
	       &upper_number,
	       &bingo_card_sum)){
    if(bingo_card_size == 0
       && upper_number == 0
       && bingo_card_sum== 0) break;

    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int num=1;num<=upper_number;num++){
      for(int sum=bingo_card_sum;sum-num>=0;sum--){
	for(int filled_count=bingo_card_size*bingo_card_size;filled_count-1>=0;filled_count--){
	  dp[sum][filled_count] += dp[sum-num][filled_count-1];
	  dp[sum][filled_count] %= MOD;
	}
      }
    }

    printf("%d\n",dp[bingo_card_sum][bingo_card_size*bingo_card_size]);
  }
}

Measured memory_bytes: 1780
#include<stdio.h>
int main(void){

    int r,c,A[101][101]={{0}};
    char ch;
    scanf("%d %d",&r,&c);
    scanf("%c",&ch);

    // 入力と行と列の和の計算
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            scanf("%d",&A[i][j]);
            A[i][c]+=A[i][j];
            A[r][j]+=A[i][j];
            A[r][c]+=A[i][j];
        }   
    }

    // 出力
    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            printf("%d",A[i][j]); 
            if (j!=c)printf(" ");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
#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>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m;
    cin>>n>>m;
    ll bc[200002]={}, ac[200002]={};
    ll as[200020]={}, acs[200020]={};
    for(int i=0; i<n; i++){
        int a; cin>>a; ac[a]++;
    }
    for(int i=0; i<m; i++){
        int b; cin>>b; bc[b]++;
    }
    for(ll i=1; i<=200000; i++){
        as[i]=as[i-1]+ac[i]*i;
        acs[i]=acs[i-1]+ac[i];
    }
    ll ans=0;
    for(int i=1; i<=200000; i++){
      if(bc[i]==0) continue;
        for(int k=0; k*i<=200000; k++){
            ans+=(as[min(200000, (k+1)*i-1)]-as[max(0, k*i-1)]-k*i*(acs[min(200000, (k+1)*i-1)]-acs[max(0, k*i-1)]))*bc[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int mark(char s){
    int k;
    if(s == 'S') k = 0;
    else if(s == 'H') k = 1;
    else if(s == 'C') k = 2;
    else k = 3;
    
    return k;
}

char demark(int x){
    char y;
    if(x == 0) y = 'S';
    else if(x == 1) y = 'H';
    else if(x == 2) y = 'C';
    else y = 'D';
    
    return y;
}

int main(){
    int n, m;
    char a;
    bool l[4][53];
    for(int i = 0; i < 4; i++) for(int j = 0; j < 13; j++) l[i][j] = true;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a >> m;
        l[mark(a)][m - 1] = false;
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(l[i][j]){
                cout << demark(i) << " " << j + 1 << endl;
            }
        }
    }
    
    return 0;
}


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

typedef long long ll;
#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << max({a * c, a * d, b * c, b * d});
}

int32_t main() {
	_

#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
	solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}

Measured memory_bytes: 3800
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#define MAXN 2000
typedef long long ll;
using namespace std;
ll n, x;
ll a[MAXN+5], f[MAXN+5][MAXN+5];
int main()
{
//	freopen("slime.in", "r", stdin);
//	freopen("slime.out","w",stdout);
	ll px;
	cin>>n>>x;
	for(ll i=0LL; i<n; i++)
		cin>>a[i], f[0][i] = a[i];
	for(ll i=1LL; i<n; i++)
		for(ll j=0LL; j<n; j++)
			f[i][(j+i)%n] = min(a[j], f[i-1][(j+i)%n]);
	px = 0LL;
	for(ll i=0LL; i<n; i++)
		px += a[i];
	ll tmp = 0LL;
	for(ll i=1; i<n; i++)
	{
		tmp = 0LL;
		for(ll j=0LL; j<n; j++)
			tmp += f[i][j];
		px = min(px, tmp + i*x);
	}
	cout<<px;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
	{
        cin>>t>>x>>y;
        if(!(x+y<=t&&(t-x-y)%2==0))
		{
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include <cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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


int main(){
	ll N, M;
	cin >> N >> M;
	
	vll A(N + 1);
	repn(i, N)cin >> A[i];

	vll count(N + 1);
	repn(i, N)count[A[i]]++;

	vll z(N + 1);
	repn(i, N) {
		rep(j, count[i]) {
			ll x = i - j;
			if (x > 0) { z[x]++; }
		}
	}

	//repn(i, N)cout << z[i] <<" ";
	//cout << endl;

	ll ans = 0;
	repn(i, N) {
		if (z[i] == 0) { ans++; }
	}

	repn(i, M) {
		ll x, y;
		cin >> x >> y;

		ll k = A[x];

		if (k - count[k] + 1 > 0) {
			z[k - count[k] + 1]--;
			if (z[k - count[k] + 1] == 0) { ans++; }
		}
		count[k]--;

		if (y - count[y] > 0) {
			z[y - count[y]]++;
			if (z[y - count[y]] == 1) { ans--; }
		}
		count[y]++;

		A[x] = y;
		//repn(i, N)cout << z[i] << " ";
		//cout << endl;
		cout << ans << endl;

	}
	
}



Measured memory_bytes: 7992
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    long long a,b,n;
    cin>>a>>b>>n;
    long long x=min(n,b-1);
    
    cout<<(a*x)/b-(x/b)*a;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

int main(){
  int z, x, y;

  while(scanf("%d", &z) && z){
    z = pow((double)z, 3);
    int res = 0, tx, ty;
    for(x = 1; x <= 1111; x++){
      for(y = 1; y <= 1111; y++){
	tx = pow((double)x, 3); ty = pow((double)y, 3);
	if(tx + ty > z) break;
	res = max(res, tx+ty);
      }
    }
    printf("%d\n", z - res);
  }
  return 0;
}

Measured memory_bytes: 1188
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

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

	N := scanInt()
	K := scanInt()
	l := make([]int, N)
	for i := 0; i < N; i++ {
		l[i] = scanInt()
	}

	sort.Sort(sort.Reverse(sort.IntSlice(l)))

	total := 0
	for i := 0; i < K; i++ {
		total += l[i]
	}

	fmt.Println(total)
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> c(N+1,-1);
    vector<pair<int,int>> v[N+1];
    rep2(i,1,N){
        int a,b,c;
        cin >> a >> b >> c;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
    c[1]=0;
    queue<int> que;
    que.push(1);
    while(!que.empty()){
        int  v_cur =que.front();
        que.pop();

        for(auto v_next : v[v_cur] ){
            if(c[v_next.first]!=-1) continue;
            c[v_next.first]=(c[v_cur]+v_next.second)%2;
            que.push(v_next.first);
        }
    }

    rep2(i,1,N+1){
        cout << c[i]<<endl;

    }
    
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
int main(){
 int n ;
 cin>> n ;
 vector<ll> A(n) ;
 vector<ll> B(n) ;
 vector<ll> wa(n) ; 
  rep(i,n){
    cin>>A[i]>>B[i] ;
    wa[i]=A[i]+B[i] ;
  }  
   vector<P> wawa(n) ;
   rep(i,n){
    wawa[i] = make_pair(wa[i],i) ; 
   }
  sort(wawa.rbegin(),wawa.rend()) ;
  ll sente=0 ;
  for(ll i=0;2*i<n;i++){
    sente+= A[wawa[i*2].second] ;
  }
  ll gote=0 ;
  for(ll i=0;2*i+1<n;i++){
    gote+=B[wawa[i*2+1].second] ;
  } 
    cout<< sente-gote<<endl;
    return 0;
  }

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll h,w,m;
    cin>>h>>w>>m;
    
    set<pair<ll,ll> >s;
    vector<ll>mpr(300001,0);
    vector<ll>mpc(300001,0);
    while(m--)
    {
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        s.insert({x,y});
        mpr[x]++;
        mpc[y]++;
    }
    ll mar=INT_MIN;
    ll r;
    for(ll i=0;i<h;i++)
    {
        if(mpr[i]>mar)
        {
            mar=mpr[i];
            r=i;
        }
    }
    ll mac=INT_MIN;
    ll c;
    for(ll i=0;i<w;i++)
    {
        if(mpc[i]>mac)
        {
            mac=mpc[i];
            c=i;
        }
    }
    ll cnt=INT_MIN;
    for(ll i=0;i<h;i++)
    {
        if(s.find({i,c})!=s.end())
        {
            cnt=max(cnt,mpr[i]+mac-1);
        }
        else
        {
            cnt=max(cnt,mpr[i]+mac);
        }
    }
    for(ll i=0;i<w;i++)
    {
        if(s.find({r,i})!=s.end())
        {
            cnt=max(cnt,mpc[i]+mar-1);
        }
        else
        {
            cnt=max(cnt,mpc[i]+mar);
        }
    }
    cout<<cnt<<endl;
    //cout<<ma<<endl;
}

Measured memory_bytes: 26728
#include <stdio.h>

int key[500001],h;
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}
void max(int i)
{
  int largest,tmp;
  int l = left(i);
  int r = right(i);
  if(l<=h&&key[l]>key[i]) largest = l;
  else largest = i;
  if(r<=h&&key[r]>key[largest]) largest = r;
  if(largest!=i)
  {
    tmp=key[i];
    key[i]=key[largest];
    key[largest]=tmp;
    max(largest);
  }
}
void build()
{
  int i;
  for(i=h/2;i>0;i--)max(i);
}

int main()
{
  int i;
  scanf("%d",&h);
  for(i=1;i<=h;i++)
  {
    scanf("%d",&key[i]);
  }
  build();
  for(i=1;i<=h;i++)
  {
    printf(" %d",key[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3696
#include <iostream>
#include<cmath>
using namespace std;
#define MAX 1000000
typedef long long llong;
int n,k;
llong T[MAX];
double th=M_PI*60/180;
struct Point{double x,y;};

void koch(int c,Point p1,Point p2);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c;
    cin>>c;
    Point p1,p2;
    p1.x=0.0;
    p1.y=0.0;
    p2.x=100.0;
    p2.y=0.0;
    cout<<p1.x<<" "<<p1.y<<endl;
    koch(c,p1,p2);
    cout<<p2.x<<" "<<p2.y<<endl;
    return 0;
}

void koch(int c,Point p1,Point p2){
    if(c==0) return;
    Point s,t,u;
    s.x=(p2.x-p1.x)/3+p1.x;
    t.x=(p2.x-p1.x)*2/3+p1.x;
    s.y=(p2.y-p1.y)/3+p1.y;
    t.y=(p2.y-p1.y)*2/3+p1.y;
    u.x=cos(th)*(t.x-s.x)-sin(th)*(t.y-s.y)+s.x;
    u.y=sin(th)*(t.x-s.x)+cos(th)*(t.y-s.y)+s.y;
    
    koch(c-1,p1,s);
    cout<<s.x<<" "<<s.y<<endl;
    koch(c-1,s,u);
    cout<<u.x<<" "<<u.y<<endl;
    koch(c-1,u,t);
    cout<<t.x<<" "<<t.y<<endl;
    koch(c-1,t,p2);

}


Measured memory_bytes: 3472
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    int n,m;
    cin>>n>>m;
    vector<int> bulbs[m+1];
    for(int i=1;i<=m;i++)
    {
        int k;
        cin>>k;
        for(int j=1;j<=k;j++)
        {
            int s;
            cin>>s;
            bulbs[i].pb(s);
        }
    }
    int p[m+1];
    for(int i=1;i<=m;i++)
        cin>>p[i];
    int ans = 0;
    for(int i=0;i<(1<<n);i++)
    {
        int mark[n+1]={};
        for(int j=1;j<=n;j++)
        {
            if(i&(1<<(j-1)))
                mark[j] = 1;
        }
        int flag = 1;
        for(int i=1;i<=m;i++)
        {
            int cnt = 0;
            for(int j=0;j<bulbs[i].size();j++)
            {
                if(mark[bulbs[i][j]]==1)
                    cnt++;
            }
            if((cnt%2)!=(p[i]%2))
            {
                flag = 0;
                break;
            }
        }
        if(flag)
            ans++;
    }
    cout<<ans;
}   

Measured memory_bytes: 256
#include <stdio.h>

#define DICE 6
#define DNUM 128

typedef struct {
  int side[DICE];
} dice_t;

dice_t rotate(dice_t d, int dir);

enum direction {N, S, W, E, R, L};

int main(void){
  int n, i, j, k, l, isEqual;
  dice_t dice[DNUM], dcopy;

  scanf("%d", &n);
  for (j = 0; j < n; j++) {
    for (i = 0; i < DICE; i++)
      scanf("%d", &dice[j].side[i]);
  }

  for (l = 0; l < n; l++) {
    for (k = l + 1; k < n; k++) { 
      dcopy = dice[k];
      /* // debug */
      /* printf("dice[%d] = ", l); */
      /* for (i = 0; i < DICE; i++) */
      /* 	printf("%d ", dice[l].side[i]); */
      /* printf("\n"); */
      /* printf("dice[%d] = ", k); */
      /* for (i = 0; i < DICE; i++) */
      /* 	printf("%d ", dice[k].side[i]); */
      /* printf("\n"); */
      
      // search for top side and fix
      for (j = 0; j < DICE; j++) {
	isEqual = 1;
	dice[k] = dcopy;
	if (dice[l].side[0] == dice[k].side[j]) {
	  switch (j) {
	  case 0:
	    break;
	  case 1:
	    dice[k] = rotate(dice[k], N);
	    break;
	  case 2:
	    dice[k] = rotate(dice[k], W);
	    break;
	  case 3:
	    dice[k] = rotate(dice[k], E);
	    break;
	  case 4:
	    dice[k] = rotate(dice[k], S);
	    break;
	  default: // case 5:
	    dice[k] = rotate(dice[k], N);
	    dice[k] = rotate(dice[k], N);
	    break;
	  }
	}

	// search for front side
	for (i = 0; i < 3; i++) {
	  if (dice[l].side[1] == dice[k].side[1])
	    break;
	  dice[k] = rotate(dice[k], R);
	}

	// compare dice1 with dice2
	for (i = 0; i < DICE; i++) {
	  if (dice[l].side[i] != dice[k].side[i]) {
	    isEqual = 0;
	    break;
	  }
	}
	/* // debug */
	/* printf("dice[%d]:dice[%d] %d\n",l ,k ,isEqual); */
	if (isEqual)
	  goto OUT;
      }
    }
  }

 OUT:
  if (!isEqual)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

dice_t rotate(dice_t d, int dir){
  int tmp;
  switch (dir) {
  case N:
    tmp = d.side[0];
    d.side[0] = d.side[1];
    d.side[1] = d.side[5];
    d.side[5] = d.side[4];
    d.side[4] = tmp;
    return d;
    break;
  case S:
    tmp = d.side[0];
    d.side[0] = d.side[4];
    d.side[4] = d.side[5];
    d.side[5] = d.side[1];
    d.side[1] = tmp;
    return d;
    break;
  case W:
    tmp = d.side[0];
    d.side[0] = d.side[2];
    d.side[2] = d.side[5];
    d.side[5] = d.side[3];
    d.side[3] = tmp;
    return d;
    break;
  case E:
    tmp = d.side[0];
    d.side[0] = d.side[3];
    d.side[3] = d.side[5];
    d.side[5] = d.side[2];
    d.side[2] = tmp;
    return d;
    break;
  case R:
    tmp = d.side[1];
    d.side[1] = d.side[2];
    d.side[2] = d.side[4];
    d.side[4] = d.side[3];
    d.side[3] = tmp;
    return d;
    break;
  case L:
    tmp = d.side[1];
    d.side[1] = d.side[3];
    d.side[3] = d.side[4];
    d.side[4] = d.side[2];
    d.side[2] = tmp;
    return d;
    break;
  default:
    printf("This direction is not available\n");
    return d;
    break;
  }
}

Measured memory_bytes: 584
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    string c[3];
    rep(i, 3)cin >> c[i];
    
    cout << c[0][0] << c[1][1] << c[2][2] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#define cmax(_i,_j) ((_i)<(_j)?(_i)=(_j):0)
#define cmin(_i,_j) ((_i)>(_j)?(_i)=(_j):0)
using namespace std;
namespace runzhe2000
{
	void main()
	{
		int d, n; scanf("%d%d",&d,&n);
		
		if(n != 100)
		{
		
			printf("%d",n);
			for(int i = 1; i <= d; i++)printf("00");
		}
		
		else
		{
			printf("101");
			for(int i = 1; i <= d; i++)printf("00");
		}
		
	}
}
int main()
{
	runzhe2000::main();
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A <= 9 && B <= 9 ? A * B : -1) << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  vector<int> vec(A);
  int C=0;
  
  for(int i=0;i<A;i++){
    cin >> vec.at(i);
    if(vec.at(i)>=B){
      C++;
    }
  }  
  cout << C << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N = 0;
    cin>>N;
    int L[N];
    for(int i = 0;i < N;i++){
        cin>>L[i];
    }
    sort(L,L+N,greater<int>());
    
    int res = 0;
    for(int i = 1;i < N;i++){
       res += L[i];
    }
    
    if(L[0] < res){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    
    return 0;
    
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
	for(int i = 0; i < n; i++){
		a[i] = sc.nextInt();
	}
    for(int i = 1; i < n; i++){
      for(int k = 0; k < n-1; k++){
      	System.out.print(a[k] + " ");
	  }
	  System.out.println(a[n-1]);
      int v = a[i];
      int j = i-1;
      while(j>=0 && a[j] > v){
      	a[j+1] = a[j];
      	j--;
      }
	  a[j+1] = v;
    }
	for(int i = 0; i < n-1; i++){
    	System.out.print(a[i] + " ");
	}
	System.out.println(a[n-1]);
  }
}



Measured memory_bytes: 32616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long ll;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    std::string S, T;
    std::cin >> S;
    std::cin >> T;

    int len = S.length(), res=0;
    floop(len)
    {
        if(S[i] != T[i])
            res++;
    }

    print(res);

    return 0;
}

Measured memory_bytes: 3848