akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
typedef complex<double> P;
double dot(P a, P b){ //内積
    return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a, P b){ //外積
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_orth(P a1, P a2, P b1, P b2){ //垂直か
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}

bool is_para(P a1, P a2, P b1, P b2){ //平行か
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

bool is_online(P a, P b, P c){ //cが線分上か
    return (abs(a-c) + abs(c-b) < abs(a-b) + EPS);
}

bool distance_lp(P a, P b, P c){ //直線abと点cの距離
    return abs(cross(b-a, c-a)) / abs(b-a);
}

bool is_intersect(P a1, P a2, P b1, P b2){ //線分の交差判定
    return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS) && 
        (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS);
}

P intersect_pos(P a1, P a2, P b1, P b2){ //直線同士の交点
    P a = a2 - a1;
    P b = b2 - b1;
    return a1 + a * cross(b, b1 - a1) / cross(b, a);
}

#define printP(P) cout << "(" << P.real() << ", " << P.imag() << ")" << endl;




int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    P p10(x1-x0, y1-y0);
    ll q;
    cin >> q;
    while(q--){
        double x2,y2;
        cin >> x2 >> y2;
        P p(x2,y2);
        P p20(x2-x0, y2-y0);
        if(abs(p20) < EPS || abs(p10) < EPS){
            print("ON_SEGMENT");
        }else{
            double sin = cross(p10, p20) / abs(p10) / abs(p20);
            double cos = dot(p10, p20) / abs(p10) / abs(p20);
            if(abs(cos+1) < EPS){
                print("ONLINE_BACK");
            }else if(abs(sin) < EPS){
                if(abs(p20) > abs(p10)){
                    print("ONLINE_FRONT");
                }else{
                    print("ON_SEGMENT");
                }
            }else if(sin > 0){
                print("COUNTER_CLOCKWISE");
            }else{
                print("CLOCKWISE");
            }

        }

    }
}


Measured memory_bytes: 3348
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int N;
  cin >> N;
  int ans = 1;
  while (ans * 2 <= N) {
    ans *= 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.security.SecureRandom;
import java.sql.Array;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       long x=sc.nextLong();
        long k=sc.nextLong();
        long d=sc.nextLong();
        x=Math.abs(x);
        if (x/d>=k) System.out.println((x-k*d));
        else{
            k-=x/d;
            x-=(x/d)*d;
            if (k%2==0){
                System.out.println(x);
            }
            else{
                System.out.println(Math.abs((x-d)));
            }
        }
    }

}



Measured memory_bytes: 35784
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

D, G = map(int, raw_input().split())
lst = []

for loop in range(D):
    p, c = map(int, raw_input().split())
    lst.append((p, c))

ans = 100000

for p in it.product([0, 1], repeat = D):
    S = 0
    cnt = 0
    rem = []
    for i in range(D):
        if p[i] == 1:
            S += 100 * (i + 1) * lst[i][0] + lst[i][1]
            cnt += lst[i][0]
        else:
            rem = [lst[i][0], i + 1]
    if S >= G:
        ans = min(ans, cnt)
        continue
    if S + 100 * rem[0] * rem[1] >= G:
        cnt += (G - S) / (100 * rem[1])
        if (G - S) % (100 * rem[1]) != 0:
            cnt += 1
        ans = min(ans, cnt)

print ans

Measured memory_bytes: 2936
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n ,d, a;
  cin>>n>>d>>a;
  vector<long long> x(n), h(n);
  typedef pair<long long, long long> P;
  vector<P> xh;
  REP(i,n){
    cin>>x[i]>>h[i];
    xh.push_back(P(x[i], h[i]));
  }
  sort(ALL(xh));
  REP(i,n){
    x[i] = xh[i].first;
    h[i] = xh[i].second;
  }
  queue<P> q;//(rlimit, damage)
  long long total_dmg = 0;
  long long ans = 0;
  REP(i,n){
    while(!q.empty() && q.front().first < x[i]){
      total_dmg -= q.front().second;
      q.pop();
    }
    long long th = h[i] - total_dmg;
    if(th <= 0)continue;
    long long cnt = (th + a - 1)/a;
    total_dmg += a * cnt;
    q.push(P(x[i] + 2*d, a * cnt));
    ans += cnt;
  }
  cout<<ans<<endl;  
  return 0;
}


Measured memory_bytes: 9456
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60;
const int MOD = 1000000007;



template <typename T>
void cout_vector(vector<T> A){
    for (T a : A) cout << a << " ";
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    bool flag = true;
    vector<vector<int>> X(15,vector<int>(15));
    vector<vector<int>> Y(15,vector<int>(15));
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
        X[i].resize(A[i]);
        Y[i].resize(A[i]);
        rep(j,A[i]){
            int x,y;
            cin >> x >> y;
            X[i][j] = x - 1 ; //0-based indexにする
            Y[i][j] = y ;
        }
    }
    int max_honest = -1;
    for(int bit = 0; bit < (1 << N); bit++){
        flag = true;
        //cout << "search[" << bitset<3> (bit) << "]pettern..." << endl;
        int honest_count = 0;
        for(int i = 0; i < N; i++){
            if (!(flag)) break;
            if (bit & (1 << i)){
                honest_count++;
                for (int j = 0; j < A[i]; j++){
                    int y = Y[i][j];
                    int x = X[i][j];
                    int w = (bit & (1 << x)) != 0;
                    //cout << i << " says " << x << " is " << y << " " << "true:" << w << endl;;
                    if (w != y) {
                        flag = false;
                        honest_count = -1;
                        break;
                    }
                }
            }
        }
        //cout << "honest count:" << honest_count << endl;
        //cout << "=====" << endl;

        max_honest = max(max_honest,honest_count);
    }
    cout << max_honest << endl;

}

Measured memory_bytes: 256
k, n = map(int, input().split())

houses = [int(value) for value in input().split()]


distance = [0] * n

for i in range(n):
    distance[i] = houses[int((i+1)%n)] - houses[i]
    if distance[i] < 0:
        distance[i] = min(abs(distance[i]), distance[i]+k)

max_distance = max(distance)

sum_distance = 0
for dis in distance:
    sum_distance += dis

sum_distance -= max_distance

print(sum_distance)


Measured memory_bytes: 24564
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""

import sys

sys.setrecursionlimit(int(1e5))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def Tarjan(current, low, dfn, scc_stack, in_scc_stack):
    global timer
    dfn[current] = low[current] = timer
    timer += 1

    scc_stack.append(current)
    in_scc_stack[current] = True

    current_scc_set = set()
    for adj in adj_table[current]:
        if not dfn[adj]:
            Tarjan(adj, low, dfn, scc_stack, in_scc_stack)
            low[current] = min(low[current], low[adj])

        elif in_scc_stack[adj]:
            low[current] = min(low[current], dfn[adj])

    scc_candidate = -1
    if dfn[current] == low[current]:
        while scc_candidate != current:
            scc_candidate = scc_stack.pop()
            in_scc_stack[scc_candidate] = False
            current_scc_set.add(scc_candidate)

        init_scc_sets_list.append(current_scc_set)

    return None


def scc_cluster():
    dfn = [0] * vertices
    low = [0] * vertices
    scc_stack = list()
    in_scc_stack = [False] * vertices

    for v in range(vertices):
        if not dfn[v]:
            Tarjan(v, low, dfn, scc_stack, in_scc_stack)

    return init_scc_sets_list


def solve(_scc_sets_list):
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in _scc_sets_list:
            if (ele1 in each) and (ele2 in each):
                flag = True
                break
        if flag:
            print('1')
        else:
            print('0')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    timer = 0
    init_scc_sets_list = []
    scc_sets_list = scc_cluster()

    solve(scc_sets_list)

Measured memory_bytes: 26416
import queue


def bfs01(s: int, t: int, V: int, graph: list)->int:
    '''01-bfs
    :param s: source
    :param t: sink
    :param V: number of vertex
    :param graph: graph
    :return: minimum distance from `s` to `t`
    '''
    INF = float('inf')

    # deque と s から各頂点への距離を初期化する。
    q = queue.deque([])  # deque
    qc = 0               # 毎度 len(q) を回すと時間かかりそうなので変数で管理
    l = [INF] * V        # s から各頂点への距離

    # s に関する初期化
    q.append(s)
    qc += 1
    l[s] = 0

    # deque に頂点が存在する限り次を繰り返す。
    # 1. deque の先頭から頂点を取り出す。
    # 2. 取り出した頂点に隣接する全ての頂点に対して以下を行う。
    # 2-a. 距離が更新されるなら更新する。加えて辺の長さが 0 なら
    #      先頭に、1 なら末尾に追加する。
    while qc > 0:
        u = q.popleft()
        qc -= 1
        for v, c in graph[u]:
            if l[u] + c < l[v]:
                l[v] = l[u] + c
                qc += 1
                if c == 0:
                    q.appendleft(v)
                else:
                    q.append(v)

    return l[t]


def small_multiple(K: int)->int:
    graph = []
    for k in range(K):
        # k -> k+1 に 1 の辺を、k -> 10*k に 0 の辺を張る。
        # ただし、どちらも mod K をとって k と等しくない場合のみ
        graph.append([])
        v1 = k+1 if k+1 < K else 0
        v10 = (k*10) % K

        graph[k].append((v1, 1))
        if v10 != k:
            graph[k].append((v10, 0))

    return bfs01(1, 0, K, graph) + 1


if __name__ == "__main__":
    K = int(input())
    ans = small_multiple(K)
    print(ans)


Measured memory_bytes: 35816
#include <stdio.h>
#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  double x[n], y[n], sum=0;
  for (int i=0; i<n; i++)  scanf("%lf %lf", x+i, y+i);
  int f=1;
  for (int i=1; i<n; i++) f *= i;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      sum += sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  sum = sum/n;
  printf("%lf\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> P(N), Q(N);
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) cin >> Q[i];

	if (P > Q) swap(P, Q);

	int ans = 0;
	do {
		if (P != Q) ans++;
		else break;
	} while (next_permutation(P.begin(), P.end()));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
N , W = map(int,input().split())
mono = [tuple(map(int,input().split())) for i in range(N)]
w1 = mono[0][0]
dp = [[-1 for i in range(301)] for j in range(N+1)]
dp[0][0] = 0 

for i in range(N):
    p = mono[i][0] - w1
    for j in reversed(range(N)):
        for k in reversed(range(301)):
            if dp[j][k] != -1:
                dp[j+1][k+p] = max(dp[j+1][k+p],dp[j][k]+mono[i][1])

ans = 0
for i in range(N+1):
    for j in range(301):
        if i*w1 + j <= W:
            ans = max(ans,dp[i][j])

print(ans)

Measured memory_bytes: 74368
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true) {
            int h = scanner.nextInt();
            int w = scanner.nextInt();
            if (h == 0 && w == 0) break;
            for (int i = 0; i < w; i++) {
                System.out.print("#");
            }
            System.out.print("\n");
            for (int i = 0; i < h - 2; i++) {
                System.out.print("#");
                for (int j = 0; j < w - 2; j++) {
                    System.out.print(".");
                }
                System.out.print("#");
                System.out.print("\n");
            }
            for (int i = 0; i < w; i++) {
                System.out.print("#");
            }
            System.out.print("\n");
            System.out.print("\n");
        }
        scanner.close();
    }
}



Measured memory_bytes: 37536
using System;

namespace AOJ
{
    class SwappingTwoNumbers
    {
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Trim().Split(' ');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);
                if (a == 0 && b == 0) { break; }
                if (a > b) { Console.WriteLine(b + " " + a); }
                else { Console.WriteLine(a + " " + b); }
            }
        }
    }
}

Measured memory_bytes: 5836
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll s;
  cin >> s;
  ll x2,y2,x3,y3;
  ll M=1000000000;
  y3=M;
  y2=1;
  x3=(M-s%M)%M;
  x2=(s+x3)/M;
  
  cout << 0 << " "  << 0 << "  " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

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

int bubbleSort(int A[], int N)
{
    int num_swaps = 0;
    int flag = 1;
    int i = 0;

    while (flag != 0) {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                int tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = 1;
                num_swaps++;
            }
        }
        i++;
    }

    return num_swaps;
}

int main()
{
    int N;
    int A[100];

    scanf("%d", &N);

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

    int num_swaps = bubbleSort(A, N);
    Print(A, N);
    printf("%d\n", num_swaps);
    return 0;
}


Measured memory_bytes: 2044
package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N := sc.i()
	if N%1000 == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - (N % 1000))
	}

}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//------------------------------

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

const int M = 1000000007;

signed main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	cin >> a >> b;

	vector<int> s(m, 0);
	rep(i, n) {
		int sum = accumulate(all(s), 0LL);
		for (int j = m - 1; j >= 0; j--) {
			sum = (sum-s[j]+M)%M;
			if (a[i] == b[j]) (s[j] += sum + 1)%=M;
		}
	}
	cout << accumulate(all(s), 1LL)%M << endl;
}


Measured memory_bytes: 384
N=int(input())
MOD=10**9+7

def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        fac[i]=fac[i-1]*i%MOD
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i]=finv[i-1]*inv[i]%MOD
    return fac,finv,inv

#nCr
def COM(n,r):
    if n<r or r<0:
        return 0
    else:
        return ((fac[n]*finv[r])%MOD*finv[n-r])%MOD

fac,finv,inv=facinv(N)

ans=0

for i in range(2,N+1):
    a=pow(8,N-i,MOD)
    b=COM(N,i)
    c=(pow(2,i,MOD)-2+MOD)%MOD
    ans=(ans+a*b*c)%MOD
print(ans)


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

int main() {
  string a, b;
  cin >> a >> b;
  int num = stoi(a + b);

  bool jug = false;
  for (int i = 0; i < 1000; i++) {
    if (i * i == num) {
      jug = true;
      break;
    }
  }
  if (jug) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3608
g = [(1, 3, 5, 7, 8, 10, 12), (4, 6, 9, 11), (2,)]


def main():
    x, y = map(int, input().split())
    for gx in g:
        if x in gx and y in gx:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }



struct UnionFind {
    vector<ll> par;
        
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    ll find(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    
    bool same(ll x, ll y) {
        return find(x) == find(y);
    }
    
    bool unite(ll x, ll y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    ll size(ll x) {
        return -par[find(x)];
    }

    void print(ll x){
        rep(i,x){
            cout<<par[i]<<endl;
        }
        return ;
    }
};




void solve() {
    ll n;
    ll x[200010],y[200010];
    cin>>n;
    pair<pll,ll> p[200010];
    rep(i,n){
        cin>>x[i]>>y[i];
        p[i]=make_pair(pll(x[i],y[i]),i);
    }
    UnionFind uf(n);
    sort(p,p+n);
    priority_queue<pll,vector<pll>,greater<pll>> que;
    rep(i,n){
        ll mi = p[i].fi.sc,index =p[i].sc;
        while( !que.empty() && que.top().fi < p[i].fi.sc){
            uf.unite(p[i].sc, que.top().sc);
            if(chmin(mi,que.top().fi)) index=que.top().sc;
            que.pop();
        }
        que.push({mi,index});
        // rep(i,n){cout<<uf.size(i)<<" ";}cout<<endl;
    }

    rep(i,n) cout<<uf.size(i)<<endl;
}


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


    ll t=1;
    
    // cin>>t;

    rep(i,t){
        solve(); 
    }

    return 0;
}


Measured memory_bytes: 12928
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const list = input.split(' ');

const n = Number(list[0]);

const k = Number(list[1]);

const isEven = (t) => {
  if(t % 2 === 0) {
    return true;
  } else {
    return false;
  }
};

const output = () => {
  if (isEven(n)) {
    if (n / 2 < k) {
      console.log('NO');
    } else {
      console.log('YES')
    }
  } else {
    if ((n + 1) / 2 < k) {
      console.log('NO');
    } else {
      console.log('YES');
    }
  }
};

output();


Measured memory_bytes: 7372
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  // ifstream cin("../test.txt");
  int a, b, d;
  char x, y;
  int t = 0;
  int h = 0;
  while (cin >> a >> x >> b >> y >> d) {
    if (a * a + b * b == d * d) t++;
    if (a == b) h++;
  }
  cout << t << endl << h << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>

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

    return gcd(b, a % b);
}

int main(void) {
    int a, b;

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

    printf("%d\n", gcd(a, b));

    return 0;
}


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

int main(){
	int N;
	cin >> N;
	int a[105];
	for(int i = 1;i <= N;i++){
		cin >> a[i];
	}
	sort(a+1,a+1+N,greater<int>());
	int Alice = 0;
	int Bob = 0;

	for(int i=1; i <= N;i++){
		if(i % 2 != 0){
			Alice += a[i];
		}else{
			Bob += a[i];
		}
	}
	cout << Alice - Bob << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while (n > 0) {
        ++ans;
        n /= k;

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

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B.at(i)=i+1;
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(A.at(i)!=B.at(i)){
      count++;
    }
  }
  bool a=false;
  if(count==0){
    cout << "YES" << endl;
  }
  else if(count!=2){
    cout << "NO" << endl;
  }
  else{
    sort(A.begin(),A.end());
    for(int i=0;i<N;i++){
      if(A.at(i)!=B.at(i)){
        a=true;
        break;
      }
    }
    if(!a){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
}

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

int main(){

  int a,b;
  cin>>a>>b;

  if(a < b)cout<<"a < b"<<endl;
  if(a > b)cout<<"a > b"<<endl;
  if(a == b)cout<<"a == b"<<endl;


  return 0;
}
  


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N, 0);
  
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  
  int cnt = 0;
  
  for (int i = 0; i < N; ++i) {
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      cnt++;
    }
  }
  
  cout << cnt << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
#define mkp make_pair
#define fi first
#define se second
void outputno(){
	puts("No");
	exit(0);
}
int n,m;
map<int,int>mp,mp1;
multiset<piii>st;
int main(){
	n=2,cin>>m;
	vector<vector<int> >a(n+1),ans(n+1);
	for(int i=1;i<=n;i++)a[i].resize(m+1),ans[i].resize(m+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
	for(int i=1;i<=m;i++)ans[1][i]=a[1][i];
	for(int i=2;i<=n;i++){
		mp.clear(),mp1.clear(),st.clear();
		for(int j=1;j<=m;j++)mp1[a[i][j]]++,mp[a[i-1][j]]++,mp[a[i][j]]++;
		for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){ 
			if(mp1[it->first]>0)st.insert(mkp(-it->second,mkp(mp1[it->first],it->first)));
		}
		for(int j=1;j<=m;j++){
			piii s=(*st.begin()),ss;st.erase(st.begin());ss=s;
			if(-s.fi>m-j+1)outputno();
			if(s.se.se==ans[i-1][j])s=(*st.begin()),st.erase(st.begin()),st.insert(ss);
			ans[i][j]=s.se.se;
			int tmp=--mp1[s.se.se],tmp2=--mp[s.se.se];
			if(tmp>0)st.insert(mkp(-tmp2,mkp(tmp,s.se.se)));
			tmp=mp1[ans[i-1][j]];
			if(tmp>0){
				int val=mp[ans[i-1][j]]--;
				st.erase(st.find(mkp(-val,mkp(tmp,ans[i-1][j]))));
				val--;
				st.insert(mkp(-val,mkp(tmp,ans[i-1][j])));
			}
		}
	}
	puts("Yes");
		for(int j=1;j<=m;j++)
			printf("%d ",ans[2][j]);
}

Measured memory_bytes: 37532
#include <bits/stdc++.h>
using namespace std;
#define int long long

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'


int r, d, x;
signed main()
{
    cin >> r >> d >> x;

    int res = r;
    FOR(i, 1, 11){    
        x = r*x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

template <typename T>
class PXSum {
  // Prefix Sum: push all data first, then call queries
  vector<T> data; public: PXSum() { }
  template <typename F>
    PXSum(vector<F>& d) { const int n = d.size(); data.resize(n); if (n) { data[0] = d[0]; for (int i = 1; i < n; ++i) { data[i] = d[i] + data[i-1]; } } }
  template <typename F>
    void push(F val) { data.push_back(data.size() ? val + data.back() : val); }
  size_t size() const { return data.size(); }
  // val[i]
  T query(int i) const { return (i ? data[i] - data[i-1] : data[0]); }
  // sum[l, r)
  T query(int l, int r) const {
    if (l == r) return T(0);
    return l ? (data[r-1] - data[l-1]) : data[r-1]; }
};

PXSum<ll> sum;
VL nums;
vector<VL> mem;


ll solve(int l, int r) {
  if (l+1 == r) return 0;
  if (mem[l][r] == LINF) { 
    for(int k = l+1; k < r; ++k) {
      mem[l][r] = min(mem[l][r], solve(l, k) + solve(k, r));
    }
    mem[l][r] += sum.query(l, r);
  }
  return mem[l][r];
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n;
  cin >> n;
  int t;
  forx(i,n) {
    cin >> t;
    sum.push(t);
  }
  mem.assign(n+1, VL(n+1, LINF));

  cout << solve(0, n) << nl;
  
  cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl;
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
using namespace std;
int a[100005];
int b[100005];
int c[100005];
ll d[100005];
ll e[100005];
int main()
{
    int n;
    scanf("%d", &n);
    FOR(i,1,n)
    {
        scanf("%d", &a[i]);
    }
    FOR(i,1,n)
    {
        scanf("%d", &b[i]);
    }
    FOR(i,1,n)
    {
        scanf("%d", &c[i]);
    }
    sort(a+1, a+n+1);
    sort(b+1, b+1+n);
    sort(c+1, c+1+n);
    ll ans = 0;
    memset(d, 0, sizeof(d));
//    int mins = lower_bound(c+1, c+1+n, b[n])-c;
    int k = 1;
    for(int i = 1; i <= n; i++)
    {
        while(b[i] >= c[k] && k <= n){k++;}
        d[i] = n-k+1;
//        cout << n-k+1 << endl;
    }
    for(int i = n; i >= 1; i--)
    {
        e[i] = e[i+1]+d[i];
    }
    k = 1;
    for(int i = 1; i <= n; i++)
    {
        while(a[i] >= b[k] && k <= n){k++;}
//        if(k >= n)k--;
//        if(kk >= n)kk--;
        ans += e[k];
//        cout << ans << endl;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2944
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: i32 = sc.cin();
    let i: i32 = sc.cin();
    put!(n-i+1);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
N = int(input())
B = list(map(int, input().split()))

A = [0] * N

A[0] = B[0]
A[1] = B[0]

for i in range(1, N-1):
    if B[i-1] > B[i]:
        A[i] = B[i]
        A[i+1] = B[i]
    else:
        A[i] = B[i-1]
        A[i+1] = B[i]

print(sum(A))

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数liに代入。
h.append(1000000001)
max = 0
now = 0

for i in range(n):
    if h[i] < h[i+1]:
        if now > max:
            max = now
        now = 0
    else:
        now = now + 1
print(max)


Measured memory_bytes: 14224
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		

		if(N*A<=B){
			System.out.println(N*A);
		}else{
			System.out.println(B);
		}
	}
}


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

using namespace std;

int main() {
  char buf[11] = {0};
  int p = 0;

  string s;
  cin >> s;
  for (char c : s) {
    if (c == '0' || c == '1') {
      buf[p++] = c;
    } else {
      if (p == 0)
        continue;
      --p;
    }
  }

  buf[p] = 0;
  cout << buf << endl;

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()
  
  	val As = readLine()!!.split(" ").mapIndexed { i, a -> Pair(i + 1, a.toInt())}
  
  	As.sortedBy { it.second }
  		.map { it.first }
  		.forEach { print("$it ") }
}

Measured memory_bytes: 83268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int D,T,S;
  cin >> D >> T >> S;
  if(D<=T*S) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#define A 200000
int main(void){
    int n,s,t,u;
    int D[A];
    scanf("%d",&n);
    for(s=0;s<n;s++){
        scanf("%d",&D[s]);
    }
    for(s=0;s<n-1;s++){
        if(s==0 || t>D[s]){
            t=D[s];
        }
        if(s==0 || u<D[s+1]-t){
            u=D[s+1]-t;
        }
    }
    printf("%d\n",u);
    return 0;
}


Measured memory_bytes: 2640
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

enum {
    ONLINE_FRONT=-2,
    CLOCKWISE,
    ON_SEGMENT,
    COUNTER_CLOCKWISE,
    ONLINE_BACK,
};

int ccwise(const Point &a, Point b, Point c) {
    b -= a; c -= a;

    if (cross_prod(b, c) > 0) {
        return COUNTER_CLOCKWISE;
    } else if (cross_prod(b, c) < 0) {
        return CLOCKWISE;
    } else if (dot_prod(b, c) < 0) {
        return ONLINE_BACK;
    } else if (norm(b) < norm(c)) {
        return ONLINE_FRONT;
    } else {
        return ON_SEGMENT;
    }
}

struct Line: public pair<Point, Point> {
    Line() {}
    Line(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
    int _ccwise(const Point &rhs) const {
        return ccwise(first, second, rhs);
    }
    bool intersects(const Line &rhs) {
        if (abs(cross_prod(second-first, rhs.second-rhs.first)) > EPS)
            // non parallel
            return true;

        // same line
        return abs(cross_prod(second-first, rhs.first-first)) < EPS;
    }
    bool intersects(const Point &rhs) {
        return abs(cross_prod(second-rhs, first-rhs)) < EPS;
    }
};

struct LineSeg: public pair<Point, Point> {
    LineSeg() {}
    LineSeg(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
    int _ccwise(const Point &rhs) const {
        return ccwise(first, second, rhs);
    }
    bool intersects(const Line &rhs) {
        return (
            cross_prod(rhs.second-rhs.first, first-rhs.first) *
            cross_prod(rhs.second-rhs.first, second-rhs.first)
        ) < EPS;
    }
    bool intersects(const LineSeg &rhs) {
        if (_ccwise(rhs.first) * _ccwise(rhs.second) > 0)
            return false;

        return rhs._ccwise(first) * rhs._ccwise(second) <= 0;
    }
    bool intersects(const Point &rhs) {
        return abs(first-rhs)+abs(second-rhs)-abs(second-first) < EPS;
    }
};

int main() {
    size_t q;
    scanf("%zu", &q);
    for (size_t i=0; i<q; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        Point p0(x, y);

        scanf("%lf %lf", &x, &y);
        Point p1(x, y);

        scanf("%lf %lf", &x, &y);
        Point p2(x, y);

        scanf("%lf %lf", &x, &y);
        Point p3(x, y);

        LineSeg l(p0, p1), m(p2, p3);
        printf("%d\n", l.intersects(m));
    }

    return 0;
}

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


int main(void){
  char A[5000];
  char B[5000];

  scanf("%s",A);
  scanf("%s",B);

  int temp;
  int lenght_A;
  int lenght_B;
  int count=0;

  lenght_A = strlen(A);
  lenght_B= strlen(B);
  int i;
  i=0;
  int j=0;
  while(i<lenght_A){
    count=0;
    for(j=0;j<lenght_B;j++){
      if(A[i+j]==B[j]){
        count++;
      }

    }
    if(lenght_B==count){
      printf("%d\n",i);
    }
      i++;
  }
  return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int LevenshteinDist(const string& s, const string& t)
{
    int n = s.size();
    int m = t.size();
    vector<vector<int> > minCost(n+2, vector<int>(m+2, INT_MAX));
    minCost[0][0] = 0;
    for(int i=0; i<=n; ++i){
        for(int j=0; j<=m; ++j){
            minCost[i+1][j] = min(minCost[i+1][j], minCost[i][j] + 1);
            minCost[i][j+1] = min(minCost[i][j+1], minCost[i][j] + 1);
            if(i < n && j < m && s[i] == t[j])
                minCost[i+1][j+1] = min(minCost[i+1][j+1], minCost[i][j]);
            else
                minCost[i+1][j+1] = min(minCost[i+1][j+1], minCost[i][j] + 1);
        }
    }
    return minCost[n][m];
}

int main()
{
    for(;;){
        int n, d;
        cin >> n >> d;
        if(n == 0)
            return 0;

        vector<string> s(n);
        for(int i=0; i<n; ++i)
            cin >> s[i];
        sort(s.begin(), s.end());

        vector<set<string> > vss(n);
        for(int i=0; i<n; ++i){
            int m = s[i].size();
            for(int j=0; j<m-1; ++j){
                string t = s[i];
                swap(t[j], t[j+1]);
                vss[i].insert(t);
            }
        }

        int ret = 0;
        for(int i=0; i<n; ++i){
            for(int j=i+1; j<n; ++j){
                bool confuse = false;
                int ld = LevenshteinDist(s[i], s[j]);
                if(ld > d*2)
                    continue;

                if(ld <= d)
                    confuse = true;

                set<string>::iterator it1, it2;
                for(it1=vss[i].begin(); it1!=vss[i].end(); ++it1){
                    if(LevenshteinDist(*it1, s[j]) <= d-1){
                        confuse = true;
                        break;
                    }
                }
                for(it2=vss[j].begin(); it2!=vss[j].end(); ++it2){
                    if(LevenshteinDist(s[i], *it2) <= d-1){
                        confuse = true;
                        break;
                    }
                }

                if(d == 2){
                    it1 = vss[i].begin();
                    it2 = vss[j].begin();
                    while(it1 != vss[i].end() && it2 != vss[j].end()){
                        if(*it1 == *it2){
                            confuse = true;
                            break;
                        }
                        if(*it1 < *it2)
                            ++ it1;
                        else
                            ++ it2;
                    }
                }

                if(confuse){
                    cout << s[i] << ',' << s[j] << endl;
                    ++ ret;
                }
            }
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 1096
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;

int main() {
  vector<vector<int>> a(3, vector<int>(3));
  rep(i, 3) {
    rep(j, 3) {
      cin >> a.at(i).at(j);
      //cout << a.at(i).at(j) << endl;
    }
  }
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) {
    cin >> b.at(i);
  }
  rep(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if (b.at(i) == a.at(j).at(k)) {
          a.at(j).at(k) = 0;
        }
      }
    }
  }
  bool fin2 = false;
  bool flag = true;
  rep(i, 3) {
    int sum = 0;
    rep(j, 3) {
      sum += a.at(i).at(j);
    }
    if (sum == 0) {
      coyes;
      //cout << i + 10 << endl;
      flag = false;
      break;
    }
  }
  bool flag2 = true;
  bool fin = false;
  if (flag) {
    rep(i, 3) {
      int sum = 0;
      rep(j, 3) {
        sum += a.at(j).at(i);
      }
      if (sum == 0) {
        coyes;
        //cout << 20 << endl;
        flag2 = false;
        fin = true;
        break;
      }
    }
  }
  bool flag3 = true;
  if (flag) {
    if (flag2) {
      if (a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0) {
        coyes;
        //cout << 30 << endl;
        flag3 = false;
      }
      else if (a.at(0).at(2) == 0 && a.at(1).at(1) == 0 && a.at(2).at(0) == 0) {
        coyes;
        //cout << 40 << endl;
        flag3 = false;
      }
    }
  }
  if (flag) {
    if (flag2) {
      if (flag3) {
        cono;
      }
    }
  }
 // cout << flag << flag2 << flag3 << endl;
  
}



Measured memory_bytes: 256
import math

array = []

for i in range(2):
    val = input()
    array.append(val.split())

K = int(array[0][0])
A = int(array[1][0])
B = int(array[1][1])

compare = math.floor(B / K) * K

if compare >= A:
    print("OK")
else:  
    print("NG")

Measured memory_bytes: 9120
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
  int n;
  scanf("%d%*d",&n);
  char s[101][101];
  for(int i=0;i<n;i++)scanf("%s",&s[i]);
  qsort(s,n,sizeof(s[0]),strcmp); 
  for(int i=0;i<n;i++)printf("%s",s[i]);
  return 0;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  if (N % 1000 == 0)
    cout << 0 << endl;
  else
    cout << 1000 - (N % 1000) << endl;

  return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;


int main(){
   string S;
   cin >> S;
   if(S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
   else cout << "No" << endl;
}

Measured memory_bytes: 256