akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0;i < n;i++) p[i] = sc.nextInt();
        int[] q = new int[n];
        for(int i = 0;i < n;i++) q[i] = sc.nextInt();
        List<List<Integer>> perms = new ArrayList<>();
        List<Integer> candidate = new ArrayList<>();
        for(int i = 1;i <= n;i++) candidate.add(i);
        
        searchRoute(candidate, new ArrayList<>(), perms);
        
        int a = 0;
        int b = 0;
        for(int i = 0;i < perms.size();i++) {
            List<Integer> perm = perms.get(i);
            boolean isA = true;
            boolean isB = true;
            for(int j = 0;j < perm.size();j++) {
                if(perm.get(j).intValue() != p[j]) isA = false;
                if(perm.get(j).intValue() != q[j]) isB = false;
            }
            if(isA) a = i;
            if(isB) b = i;
        }

        int ans = Math.abs(a - b);
        System.out.println(ans);
    }

    private static void searchRoute(List<Integer> candidate, List<Integer> perm, List<List<Integer>> result) {
        if(candidate.isEmpty()) {
            result.add(perm);
        }

        for(int i = 0;i < candidate.size();i++) {
            Integer tmp = candidate.get(i);
            List<Integer> tmpCandidate = new ArrayList<>(candidate);
            List<Integer> tmpRoute = new ArrayList<>(perm);
            tmpCandidate.remove(i);
            tmpRoute.add(tmp);
            searchRoute(tmpCandidate, tmpRoute, result);
        }

        return;
    }

}


Measured memory_bytes: 46228
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
    int a,b,c;
    int z=0;
    cin >>a >>b >>c;
    for(int x = a; x <= b; x++){
        if(c%x==0){
        //cout << x <<endl;
            z++;
        }
    }
    // insert code here...
   // std::cout << "Hello, World!\n";
    cout << z<<endl;
    return 0;
}

Measured memory_bytes: 1164
S = input()
S_list = list(S)
ACGT_list = ["A", "C", "G", "T"] 

max_ACGT = 0
count = 0
for i in range(len(S_list)):
    if S_list[i] in ACGT_list:
        count += 1
        if max_ACGT < count:
            max_ACGT = count
        else:
            pass
    else:
        count = 0
print(max_ACGT)

Measured memory_bytes: 3060
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = 2
ans = ''

if n==0:
    print(0)
    exit()

while n != 0:
    if n%a == 0:
        ans = '0' + ans
    else:
        ans = '1' + ans
        n-=(a//2)
    a*=(-2)

print(ans)

Measured memory_bytes: 9208
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=True
if 0 in A:
    print(0)
else:
    for j in A:
        ans*=j
        if ans>10**18:
            print(-1)
            flag=False
            break
    if flag:
        print(ans)  

Measured memory_bytes: 21468
import sys
read = sys.stdin.readline


def readln():
    return list(map(int, read().split()))


N, M = readln()
A = [0]*M
B = [0]*M
for i in range(M-1, -1, -1):
    a, b = readln()
    A[i], B[i] = a-1, b-1
# AB = [readln() for _ in range(M)]
# A = [ab[0]-1 for ab in AB[::-1]]
# B = [ab[1]-1 for ab in AB[::-1]]


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードをしめす。負は自身が親ということ。
        self.parent = [-1] * N  # idxが各ノードに対応。

    def root(self, A):
        # print(A)
        # ノード番号を受け取って一番上の親ノードの番号を帰す
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])  # 経由したノードすべての親を上書き
        return self.parent[A]

    def size(self, A):
        # ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
        return -self.parent[self.root(A)]

    def concat(self, A, B):
        # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        A = self.root(A)
        B = self.root(B)

        # すでにくっついている場合
        if (A == B):
            return False

        # 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
        if (self.size(A) < self.size(B)):
            A, B = B, A

        # くっつける
        self.parent[A] += self.parent[B]  # sizeの更新
        self.parent[B] = A  # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる

        return True


ans = [N * (N - 1) // 2]
uni = UnionFind(N)
for a, b in zip(A, B):
    if uni.root(a) == uni.root(b):
        ans.append(ans[-1])
    else:
        ans.append(ans[-1] - uni.size(a) * uni.size(b))
        uni.concat(a, b)

for a in ans[-2::-1]:
    print(a)


Measured memory_bytes: 17772
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number_n, i, count = 0;
    number_n = Integer.parseInt(sc.next());
    int[] level = new int[number_n];
    for(i = 0; i < number_n; i++) level[i] = Integer.parseInt(sc.next());
    Arrays.sort(level);
    count = level[number_n/2] - level[number_n/2-1];
    System.out.println(count);
  }
}


Measured memory_bytes: 48548
from collections import deque

K = int(input())

queue = deque([])
for i in range(1,9+1):
    queue.append(i)

lunlun = []
for i in range(K):
    x = queue.popleft()
    lunlun.append(x)
    if x%10 != 0:
        queue.append(10*x+x%10-1)
    queue.append(10*x+x%10)
    if x%10!=9:
        queue.append(10*x+x%10+1)
print(lunlun[K-1])

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

typedef long long ll;

ll gcd(ll a, ll b){
return a != 0 ? gcd(b % a, a) : b;
}

int main() {
ll a, b;
while(cin >> a >> b)
cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;}

Measured memory_bytes: 3016
#include<stdio.h>

int max(int,int);

int main(void){
  int n,a,sum,m,v,i;
  
  while(1){
    m=0;
    v=-100000;
    sum=0;
    scanf("%d",&n);
    if(n==0)break;
    
    for(i=0;i<n;i++){
      scanf("%d",&a);
      m=max(0,m+a);
      sum=max(sum,m);
      v=max(v,a);
    }
    printf("%d\n",(v<0)?v:sum);
  }
  
  return 0;
}

int max(int x,int y){
  return (x>y)?x:y;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using str = string; using cstr = const str;
using ll = long long; using ull = unsigned long long; using cint = const int; using cll = const ll;
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 vd = vector<double>; using vvd = vector<vd>;
using vc = vector<char>; using vvc = vector<vc>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using psl = pair<string, ll>;
using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7;
static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32_t main(int32_t argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
    vs args(argv, argv+argc);
    string sample = make_sample(args, "sample-1");
    ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#endif


    int N,Y; cin>>N>>Y;

    REP(i,N+1) {
        REP(j,N+1-i) {
            int k = N - i - j;
            int total = 10000*i + 5000*j + 1000*k;
            if (total == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    
    cout << "-1 -1 -1" << endl;

    return 0;
}


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

int main(){
  int a,b,s,t;
  s=0;t=0;

  for(int i=0;i<4;i++){
    cin>>a;
    s+=a;
  }
  
  for(int i=0;i<4;i++){
    cin>>b;
    t+=b;
  }

  if(s<=t)s=t;

  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int n = ni();
        int m = ni();

        ArrayList<Pair> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int l = ni(), r = ni();
            list.add(new Pair(l, r));
        }
        Collections.sort(list);

        BIT bit = new BIT(m);
        int idx = 0;
        for (int i = 1; i <= m; i++) {
            while (idx < n && list.get(idx).y - list.get(idx).x < i) {
                bit.add(list.get(idx).x, 1);
                bit.add(list.get(idx).y + 1, -1);
                idx++;
            }

            int ans = n - idx;
            for (int j = i; j <= m; j += i) {
                ans += bit.sum(j);
            }
            out.println(ans);
        }
    }

    class BIT {
        int n;
        int[] bit;

        BIT(int n) {
            this.n = n;
            bit = new int[n + 1];
        }

        int sum(int i) {
            int s = 0;
            while (i > 0) {
                s += bit[i];
                i -= i & -i;
            }
            return s;
        }

        void add(int i, int x) {
            while (i <= n) {
                bit[i] += x;
                i += i & -i;
            }
        }
    }

    public class Pair implements Comparable<Pair> {
    	int x, y;

    	Pair(int x, int y) {
    		this.x = x;
    		this.y = y;
    	}

    	public int compareTo(Pair p) {
    		return (y - x) - (p.y - p.x);
    	}
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 53956
N, M = list(map(int,input().split()))
adj = []
visit = []

def DFS(p):
  count = 0
  if all(visit):
    return 1
  for n in adj[p]:
    if visit[n] == 0:
      visit[n] = 1
      count += DFS(n)
      visit[n] = 0
  return count

def main():
  for n in range(N):
    adj.append([])
    visit.append(0)
  for m in range(M):
    i, j = list(map(int,input().split()))
    adj[i-1].append(j-1)
    adj[j-1].append(i-1)
  visit[0] = 1
  return DFS(0)

print(main())

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] Ss = new int[M];
        int[] Cs = new int[M];
        for (int m = 0; m < M; m++){
            Ss[m] = sc.nextInt();
            Cs[m] = sc.nextInt();
        }

        int[] text = new int[N];
        int noFlg = 0;
        for (int m = 0; m < M; m++){
            if (((Ss[m]-1) == 0) && (Cs[m] == 0) && (N>1)) {
                noFlg = 1;
                break;
            }
            if ((text[Ss[m]-1] != 0) && (text[Ss[m]-1] != Cs[m])) {
                noFlg = 1;
                break;
            }
            text[Ss[m]-1] = Cs[m];
        }
        StringBuilder sb = new StringBuilder();
        for (int t: text) {
            sb.append(String.valueOf(t));
        }
        String ans_text = sb.toString();
        if ((ans_text.length() > 1) && (ans_text.charAt(0) == '0')) {
            ans_text = ans_text.replaceFirst("0","1");
        }
        if (noFlg == 1) System.out.println("-1");
        else System.out.println(ans_text);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m,x;
  cin>>n>>m;
  vector<int> c(m),d(m);
  vector<vector<int>> e(n+1);
  for(int i=0;i<m;i++){
    cin>>c[i]>>d[i];
    e[c[i]].push_back(d[i]);
  }
  for(int i=0;i<n+1;i++){
    sort(e[i].begin(),e[i].end());
  }
  for(int i=0;i<m;i++){
    x=lower_bound(e[c[i]].begin(), e[c[i]].end(), d[i])- e[c[i]].begin() + 1;
    printf("%06d", c[i]);
    printf("%06d\n",x);
  }
}

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

int main(){
	int a, b;
	cin >> a >> b;
	int max = a + b;
	if (a - b > max) {
		max = a - b;
	}
	if (a * b > max) {
		max = a * b;
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xa = sorted([(a[i], i) for i in range(N)], key = lambda x: x[0])
xb = sorted([(b[i], i) for i in range(N)], key = lambda x: x[0])
for i in range(N):
  if xa[i][0] > xb[i][0]:
    print("No")
    exit(0)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1] * (n + 1)
    self.rnk = [0] * (n + 1)

  def Find_Root(self, x):
    if self.root[x] < 0:
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if x == y:
      return 
    elif self.rnk[x] > self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x] == self.rnk[y]:
        self.rnk[y] += 1

  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  def Count(self, x):
    return -self.root[self.Find_Root(x)]
uf = UnionFind(N)
c = 0
#print(xa, xb)
f = 0
for i in range(N):
  #print((xa[i][1], xb[i][1]))
  if uf.isSameGroup(xa[i][1], xb[i][1]):
    c += 1
  uf.Unite(xa[i][1], xb[i][1])
if c >= 2:
  print("Yes")
else:
  for i in range(N - 1):
    if xa[i + 1] <= xb[i]:
      print("Yes")
      exit(0)
  print("No")

Measured memory_bytes: 120280
/* #region template */
#![allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, Bytes, Read, Stdin, StdinLock, Stdout, StdoutLock, Write};
use std::iter::{repeat, repeat_with};
use std::mem::swap;
use std::str::FromStr;
#[allow(dead_code)]
struct Io<'a> {
    reader: Bytes<StdinLock<'a>>,
    writer: StdoutLock<'a>,
    in_buf: [u8; BUF_SIZE],
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn new(stdin: &'a Stdin, stdout: &'a Stdout) -> Io<'a> {
        Io {
            reader: stdin.lock().bytes(),
            writer: stdout.lock(),
            in_buf: [0; BUF_SIZE],
        }
    }
    fn r<T: FromStr>(&mut self) -> T {
        let mut count = 0;
        loop {
            match self.reader.next() {
                Some(Ok(b' ')) | Some(Ok(b'\n')) => break,
                Some(Ok(c)) => self.in_buf[count] = c,
                _ => panic!(),
            }
            count += 1;
        }

        let s = unsafe { std::str::from_utf8_unchecked(&self.in_buf[0..count]) };
        s.parse().unwrap_or_else(|_| panic!())
    }
    fn ru(&mut self) -> usize {
        self.r()
    }
    fn iter<'b, T>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter::new(self)
    }
    fn c<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        self.iter().take(n).collect()
    }
    fn cu(&mut self, n: usize) -> Vec<usize> {
        self.c(n)
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.writer, "{}", v).unwrap();
    }
    fn wn<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.writer, "{}", v).unwrap();
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T> {
    io: &'b mut Io<'a>,
    m: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a: 'b, 'b, T> IoIter<'a, 'b, T> {
    fn new(io: &'b mut Io<'a>) -> IoIter<'a, 'b, T> {
        IoIter {
            io,
            m: std::marker::PhantomData,
        }
    }
}
impl<'a, 'b, T: FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut io = Io::new(&stdin, &stdout);
    unsafe {
        solve(&mut io);
    }
}
/* #endregion */

const BUF_SIZE: usize = 1024;

unsafe fn solve(io: &mut Io) {
    let k: u64 = io.r();
    let mut sum = 0;
    for a in 1..=k {
        for b in 1..=k {
            let ab = gcd(a, b);
            for c in 1..=k {
                sum += gcd(ab, c);
            }
        }
    }
    io.w(sum);
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=0,D=0,E=0,F=0,G=0,H=0,N,M;
  vector<lli>P(100000,0);
  rep(i,3,100000){
    P[i]=P[i-1];
    if(is_prime(i)&&is_prime((i+1)/2))P[i]++;
  }
  cin >> A;
  rep(i,0,A){
    cin >> B >> C;
    Out(P[C]-P[B-1]);
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//約数列挙
vector<ll> pickdiv(ll n){
    vector<ll> res;
    for(ll i=1; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i);
        ll q = n/i;
        if(q != i){
            res.emplace_back(q);
        }
    }
    return res;
}
int main(){
    ll N;
    //string S;
    cin >> N;
    ll sum = 0;
    REP(i,1,N+1){
        sum += ((((N/i)+1)*(N/i))/2)*i;
    }
    cout << sum << endl;
}


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

using namespace std;

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

	int q;
	cin >> q;

	char* front_queue = new char[q];
	char* back_queue = new char[q];
	int front_cnt = 0;
	int back_cnt = 0;

	bool reverse = false;

	for (int i = 0; i < q; ++i) {
		int t;
		cin >> t;
		if (t == 1) {
			reverse = !reverse;
		}
		else if (t == 2) {
			int f;
			cin >> f;
			char c;
			cin >> c;

			if (f == 2) {
				if (reverse) {
					front_queue[front_cnt] = c;
					front_cnt++;
				}
				else{
					back_queue[back_cnt] = c;
					back_cnt++;
				}
			}
			else if (f == 1) {
				if (reverse) {
					back_queue[back_cnt] = c;
					back_cnt++;
				}
				else {
					front_queue[front_cnt] = c;
					front_cnt++;
				}
			}
		}
	}

	string front(front_queue, front_cnt);
	string back(back_queue, back_cnt);

	s += back;
	std::reverse(s.begin(), s.end());
	s += front;

	if (!reverse) std::reverse(s.begin(), s.end());

	cout << s << endl;

	delete[] front_queue;
	delete[] back_queue;
	return 0;
}


Measured memory_bytes: 1348
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int n;
  cin >> n;
  if (n%2 == 0) cout << n*n/4 << endl;
  else cout << n/2 *((n+2-1)/2) << endl;




  return 0; 
}



Measured memory_bytes: 256
import math
from typing import List, Tuple


def dist(p1: Tuple[int, int], p2: Tuple[int, int]) -> float:
    return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)


if __name__ == "__main__":
    N = int(input())
    points: List[Tuple[int, int]] = [(0, 0)] * N
    for idx in range(N):
        x, y = map(lambda x: int(x), input().split())
        points[idx] = (x, y)

    table1 = [float('inf')] * N
    table2 = [float('inf')] * N
    table1[0] = table2[0] = dist(points[0], points[1])

    for i in range(2, N):
        d1 = d2 = float('inf')
        for j in range(i - 1):
            d = dist(points[i], points[j])
            d1 = min(d1, table2[j] + d)
            d2 = min(d2, table1[j] + d)
        table1[i - 1] = d1
        table2[i - 1] = d2
        d = dist(points[i - 1], points[i])
        for j in range(i - 1):
            table1[j] += d
            table2[j] += d

    ans = min(min(d1, d2) + dist(points[i], points[N - 1])
              for i, (d1, d2) in enumerate(zip(table1, table2)))
    print(ans)



Measured memory_bytes: 7456
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;

int main(){
	while (cin >> n&&n){
		ll co = 0;
		while (n != 1){
			co++;
			if (n % 2 == 0)n /= 2;
			else n = n * 3 + 1;
		}
		cout << co << endl;
	}
}

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

int main() {
  int fib[45];
  fib[0]=1;
  fib[1]=1;
  for(int i=2;i<45;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }

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

  printf("%d\n",fib[n]);
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll p[n];
	REP(i, n){ cin >> p[i]; }
	ll cnt = 0;
	REP(i, n){
		if (p[i] != i+1){ cnt++; }
		if (cnt >= 3){ cout << "NO" << endl; return 0; }
	}
	cout << "YES" << endl;
}


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

int main()
{
    std::string S, sub0, sub1;
    std::cin >> S;
    while (true)
    {
        S.pop_back();
        if (S.length() % 2 == 0)
        {
            sub0 = S.substr(0, S.length() / 2);
            sub1 = S.substr(S.length() / 2, S.length());
            if (sub0 == sub1)
            {
                std::cout << S.length() << std::endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define eb emplace_back
using namespace std;
const int N = 2e+5;
vector<ll> v[N], col(N), cnt(N, 0), sz(N, 0), freq(N, 0), ans(N, 0);
void add(ll x, ll y) {
	v[x].eb(y);
	v[y].eb(x);
}
ll nc2(ll n) {
	return( n * (n - 1)) >>1;
}
void dfs(ll nd = 1, ll par = 0) {

	sz[nd] = 1;
	ll count = cnt[col[nd]];
	for (ll ch : v[nd]) {
		if (ch != par) {

			cnt[col[nd]] = 0;

			dfs(ch, nd);

			ans[col[nd]] += nc2(sz[ch] - cnt[col[nd]]);

			sz[nd] += sz[ch];
		}
	}

	cnt[col[nd]] = count + sz[nd];// up subtree +down subtree containing col[nd];


}
int main() {
	ll n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> col[i], freq[col[i]]++;
	ll x, y;
	for (int i = 1; i <= n - 1; i++)
		cin >> x >> y,
		add(x, y);
	dfs();
	ll tot = nc2(n);
	for (int i = 1; i <= n; i++)
		ans[i] += nc2(n - cnt[i]);
	for (int i = 1; i <= n; i++)
		cout << tot - ans[i] + freq[i] << "\n";


}




Measured memory_bytes: 37528
from itertools import accumulate
import sys
input = sys.stdin.readline

H, W, K = map(int, input().split())
S = [list(map(int, input().rstrip())) for _ in range(H)]
cum = [list(accumulate(S[i])) for i in range(H)]
ans = float('inf')
for bit in range(1 << (H-1)):
    cnt = 0
    prev = -1
    for h in range(H-1):
        cnt += (bit >> h) & 1
    for w in range(W):
        s = 0
        cut = False
        for h in range(H):
            if h > 0 and bit >> (h-1) & 1:
                if s > K:
                    cut = True
                    break
                s = 0
            s += cum[h][w] - (cum[h][prev] if prev >= 0 else 0)
        if s > K:
            cut = True
        if cut:
            if w-1 == prev:
                break
            cnt += 1
            prev = w-1
            continue
    else:
        ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 44764
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
using namespace std;
typedef pair<int,int> P;
const int INF = (int)((unsigned int)-1>>1);

const int MAX_N = 1000000;
const int MAX_XY = 1001;
//const int MAX_N = 49;
//const int MAX_XY = 7;

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

int n, m;
bool is_prime[MAX_N+1];
int cave[MAX_XY][MAX_XY];
P dp[MAX_XY][MAX_XY];


int main(){
    P point[MAX_N+1];
    int r = 1, n1 = 1, count = 0, dire = 0;
    int x = MAX_XY/2, y = MAX_XY/2;
    while(n1 <= MAX_XY*MAX_XY){
        cave[y][x] = n1;
        if (n1<=MAX_N) point[n1] = P(y,x);
        n1++;
        x += dx[dire]; y+= dy[dire];
        count++;
        if (r == count){
            count = 0;
            dire++;
            if(dire==4) dire = 0;
            if(dire==0 || dire==2) r++;
        }
    }

    fill(is_prime,is_prime+MAX_N+1,true);
    is_prime[1] = false;
    for(int i=2;i<=MAX_N;i++){
        if(is_prime[i]){
            for(int j=2;j*i<=MAX_N;j++){
                is_prime[j*i] = false;
            }
        }
    }

    while(1){
        cin >> m >> n;
        if (m==0)break;
        for(int i=0;i<MAX_XY;i++)for(int j=0;j<MAX_XY;j++)dp[i][j] = P(0,0);
        for(int i=MAX_XY-1;i>=0;i--){
            for(int j=0;j<MAX_XY;j++){
                if(cave[i][j]>m) continue;
                //cout << i << "," << j << ":" << cave[i][j] << endl;
                P p = P(0,0);
                for(int k=0;k<3;k++){
                    int nextx = j+dx_cave[k], nexty = i+1;
                    if (0<=nextx && nextx<MAX_XY && 0<=nexty && nexty<MAX_XY && cave[nexty][nextx]<=m ){
                        p = max(p,dp[nexty][nextx]);
                    }
                }
                if(is_prime[cave[i][j]]){
                    p.first++;
                    if(p.first==1) p.second = cave[i][j];
                }
                //cout << p.first << endl;
                dp[i][j] = p;
                //cout << cave[i][j] << " " << n << endl;
            }
            if(i==point[n].first) break;
        }
        P p = dp[point[n].first][point[n].second];
        printf("%d %d\n",p.first,p.second);
    }
    /*
    for(int i=0;i<MAX_XY;i++){
        for(int j=0;j<MAX_XY;j++){
            printf("%2d ",cave[i][j]);
        }
        printf("\n");
    }
    */

    return 0;
}

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

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    while(true){
        ll cnt=0;
        ll sum=0;
        rep(i,n){
            cnt+=a[i]&1;
            a[i]>>=1;
            sum+=a[i];
        }
        if(cnt%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
        if(sum==0)break;
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
    char s[3];
    rep(i, 3){
        cin >> s[i];
    }
    if(s[0] == s[1]){
        if(s[0] == s[2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include "math.h"
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <functional>
#include <numeric>
#include <cmath>
using namespace std;

int n, k;
int long long modd = 1e9+7;



int main()
{
	//freopen("input.txt", "r+", stdin);
	//freopen("output.txt", "w+", stdout);

	cin >> n >> k;
	vector<long long> arr;
	vector<long long> neg_arr;

	int pos,neg;
	pos = neg = 0;

	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		arr.push_back(a);
		if (a >= 0) {
			pos++;
		}
		if (a < 0) {
			neg_arr.push_back(a);
			neg++;
		}
	}

	long long mx = 1;
	if (pos==0 && k%2==1)
	{
		if (neg<k)
		{
			cout << 0;
		}
		else {
			sort(neg_arr.begin(), neg_arr.end(), greater<int>());
			for (int i = 0; i < k; i++)
			{
				mx *= (modd+neg_arr[i]);
				mx %= modd;
			}
			cout << mx;
		}
	}
	else {
		int l, r;
		l = 0;
		r = n - 1;
		sort(arr.begin(), arr.end(), greater<int>());
		while (k > 0) {
			if (k%2)
			{
				mx = mx*arr[l]%modd;
				l++;
				k--;
			}
			else if(k>=2) {
				
				if (arr[l] * arr[l + 1]>=arr[r] * arr[r - 1])
				{
					mx =mx*(modd+arr[l])%modd * (modd+arr[l + 1])%modd;
					l += 2;
					k -= 2;
				}
				else {
					mx =mx*(modd+arr[r])%modd * (modd+arr[r - 1]) %modd;
					r -= 2;
					k -= 2;
				}
				
			}
		}
		cout << (mx+modd)%modd;
	}
	cout << endl;
	

	return 0;
}


Measured memory_bytes: 6700
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;
  
int main() {

  int n;
  cin >> n;

  vector<int> v(n, 0);
  rep (i, n) cin >> v[i];

  vector<int> box(n, 0);
  stack<int> ans;

  for (int i = n; i > 0; i--) {
    int tmp = 0;
    for (int j = 2; j <= n / i; j++) {
      tmp = (tmp + box[i * j - 1]) % 2;
    }
    if (tmp != v[i - 1]) {
      box[i - 1] = 1;
      ans.push(i);
    }
  }
  cout << ans.size() << endl;

  while (ans.size()) {
    cout << ans.top() << (ans.size() > 1 ? " " : "\n");
    ans.pop();
  }
    
  return 0;
}


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

int main() {
	int N, v, max_v = -1000000000, min_v;
	cin >> N >> min_v;
	for(int i=1; i<N; i++){
		cin >> v;
		max_v = max(max_v, v - min_v);
		min_v = min(min_v, v);
	}
	cout << max_v << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
  string s;
  cin >> s;
  if(s == "Sunny")cout<<"Cloudy";
  else if(s == "Cloudy")cout<<"Rainy";
  else cout <<"Sunny";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int x,n;
  cin>>x>>n;
  vector<bool> used(102,false);
  for(int i=0;i<n;i++){
    int v;
    cin>>v;
    used[v]=true;
  }
  for(int diff=0;diff<=101;diff++){
    int l=x-diff;
    if(0<=l && !used[l]){
      cout<<l<<endl;
      return 0;
    }
    int r=x+diff;
    if(r<=101&&!used[r]){
      cout<<r<<endl;
      return 0;
    }
  }
  if(abs(x)<=abs(101-x)){
    cout<<0<<endl;
  }else{
    cout<<101<<endl;
  }


  return 0;
}




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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

#ifdef LOCAL
#include "/Users/swad/Desktop/CP/debug.h"
#endif

// const int N = int(1e5) + 10;
// const int MOD = int(1e9) + 7;

int n;
vector<ll> dp, f;
vector<vector<int>> a;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d", &n);

	a.resize(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &a[i][j]);
		}
	}

	f.resize(1 << n, 0);
	for (int mask = 1; mask < 1 << n; mask++) {
		f[mask] = f[mask & (mask - 1)];
		for (int _mask = mask; _mask; _mask &= (_mask - 1)) {
			f[mask] += a[__builtin_ctz(mask)][__builtin_ctz(_mask)];
		}
	}

	dp.resize(1 << n, 0);
	for (int mask = 1; mask < 1 << n; mask++) {
		for (int _mask = mask; _mask; _mask = (_mask - 1) & mask) {
			dp[mask] = max(dp[mask], f[_mask] + dp[mask ^ _mask]);
		}
	}

	printf("%lld\n", dp.back());

	return 0;
}

Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    char c[3][4];
    rep(i, 2) rep(j, 3) cin >> c[i][j];

    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n = 0;
    int score[101];
    bool hai[10] = {false};
    int over = 0;
    int minans = 0;
    int maxans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> score[i];
    }

    for (int j = 0; j < n; ++j) {
        if (score[j] <= 399){
            hai[0] = true;
        } else if (score[j] <= 799){
            hai[1] = true;
        } else if (score[j] <= 1199){
            hai[2] = true;
        } else if (score[j] <= 1599){
            hai[3] = true;
        } else if (score[j] <= 1999){
            hai[4] = true;
        } else if (score[j] <= 2399){
            hai[5] = true;
        } else if (score[j] <= 2799){
            hai[6] = true;
        } else if (score[j] <= 3199){
            hai[7] = true;
        } else{
            over++;
        }
    }

    for (int k = 0; k < 8; ++k) {
        if (hai[k] == true)minans++;
    }
    maxans = over + minans;
    if(minans == 0)minans++;
    cout << minans << " " << maxans;
    return 0;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    StringTokenizer stk = new StringTokenizer(in.readLine());
    String s = stk.nextToken();  
    int cnt = 0;
    String s_rep = s.replace("ABC","a");

    for (int i = 0; i < s_rep.length(); i++){
      if(s_rep.charAt(i) == 'a')
        cnt++;
    }
    System.out.println(cnt);
  }
}

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

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> M(N);
  int Min=1000;
  int Sum=0;
  for(int i=0; i<N; i++){
    cin >> M.at(i);
    Min=min(Min, M.at(i));
    Sum+=M.at(i);
  }
  int Ans=N;
  int P=X-Sum;
  Ans+=P/Min;
  cout << Ans << endl;
}
  

Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
using namespace std;

#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vector<int>>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define itr(v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fd(i,n)         for(int i=n-1;i>=0;i--)
#define fir(i,a,b)      for(int i=a;i<b;i++)
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);
#define MAXZ            200005
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

bool cmp(int a,int b) {return a>b;}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}
const double PI = 3.141592653589793238463;
int a[200001],b[200001];

int32_t main()
{
    FIO
    int a,b,m,h; cin>>a>>b>>h>>m;
    long double f=30*h-(5.5)*m;
    f=f/180.0;
    f=sqrt(a*a+b*b-2*a*b*cos(f*PI));
    cout<<ps(f,9)<<"\n";
    return 0;

}

Measured memory_bytes: 4180
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s  = sc.next();

        List<Integer> zero = new ArrayList<>();
        List<Integer> one = new ArrayList<>();

        int len = 0;
        while(len < s.length()){
            if(s.charAt(len) == '1'){
                int sublen = 0;
                while(s.charAt(len+sublen) == '1'){
                    sublen++;
                    if(len + sublen == s.length()){
                        break;
                    }
                }
                one.add(sublen);
                len += sublen;
            } else {
                int sublen = 0;
                while(s.charAt(len+sublen) == '0'){
                    sublen++;
                    if(len + sublen == s.length()){
                        break;
                    }
                }
                zero.add(sublen);
                len += sublen;
            }
        }

        if(zero.size() <= k){
            System.out.println(s.length());
            System.exit(0);
        }

        int max = 0;
        for(int i = 0;i <= zero.size() - k;i++){
            if(s.charAt(0) == '1'){
                int sum = 0;
                for(int j = 0;j < k;j++){
                    sum += one.get(i+j);
                    sum += zero.get(i+j);
                }
                if(i + k < one.size()) {
                    sum += one.get(i + k);
                }
                max = Math.max(max, sum);
            } else {
                int sum = 0;
                for(int j = 0;j < k;j++){
                    if(i + j < one.size()) {
                        sum += one.get(i + j);
                    }
                    sum += zero.get(i+j);
                }
                if(0 <= i - 1) {
                    sum += one.get(i-1);
                }
                max = Math.max(max, sum);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 26372
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli,lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mp  make_pair
#define ss  second
#define ff  first
#define all(x) x.begin(),x.end()
const lli mod = 1e9+7;
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
lli p2(lli n){lli ans=0;while(n>=1){n=n/2;ans++;}return ans;}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli add(lli a,lli b){return(a+b)%mod;}
lli mul(lli a,lli b){return (a*b)%mod;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli lcm(lli a,lli b)
{
    lli ans=(a*b)/(__gcd(a,b));
    return ans;
}
int n,m;
vi adj[200001];
int vis[200001];
bool f;
void dfs(int curr,int c=0)
{
    vis[curr]=1;
    if(curr==n){f=true;return;}
    if(c==2)return;
    for(int i:adj[curr])
    {
        if(vis[i]==0)dfs(i,c+1);
    }

}
int main()
{
    cin>>n>>m;
    while(m--)
    {
        int a,b;cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs(1);
    if(f)cout<<"POSSIBLE\n";
    else cout<<"IMPOSSIBLE\n";
}





Measured memory_bytes: 15640
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  string s; cin>>s;
  if (s == "RRR") cout<<3<<endl;
  else if (s == "SRR" || s=="RRS") cout<<2<<endl;
  else if (s == "SSS") cout<<0<<endl;
  else cout<<1<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cassert>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug(x) cout<<#x<<"="<<x<<endl
using namespace std;
typedef long long LL;
const int INF=1e9+7;
inline LL read(){
    register LL x=0,f=1;register char c=getchar();
    while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
    while(c>=48&&c<=57)x=(x<<3)+(x<<1)+(c&15),c=getchar();
    return f*x;
}

const int N = 4005;
const int mod = 924844033;

int a[N], g[N], f[N][N][2], fac[N];
int n, K, cnt, ans;

inline int add(int x, int y){return (x+y)%mod;}
inline int dec(int x, int y){return (x-y+mod)%mod;}
inline int mul(LL x, int y){return x*y%mod;}

int main(){
	n = read(), K = read();
	fac[0] = fac[1] = 1;
	for(int i = 2; i <= n; ++i) fac[i] = mul(fac[i-1], i);
	for(int i = 1; i <= K; ++i){
		for(int j = i; j <= n; j += K)
			a[++cnt] = j;
		for(int j = i; j <= n; j += K)
			a[++cnt] = j;
	}
	assert(cnt == (n << 1));
	f[1][0][0] = 1;
	for(int i = 2; i <= (n << 1); ++i){
		for(int j = 0; j <= min(n, i/2); ++j){
			f[i][j][0] = add(f[i-1][j][0], f[i-1][j][1]);
			if(j > 0 && a[i] - a[i-1] == K) f[i][j][1] = f[i-1][j-1][0];
		}
	}
	for(int i = 0; i <= n; ++i){
		g[i] = add(f[n << 1][i][0], f[n << 1][i][1]);
		if(!(i&1)) ans = add(ans, mul(g[i], fac[n - i]));
		else ans = dec(ans, mul(g[i], fac[n - i]));
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 123648
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int n;
vector<int> v;
int main(){
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
    return 0;
}


Measured memory_bytes: 256
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,x,y,t[3];
  cin>>a>>b>>c>>x>>y;
  t[0]=a*x+b*y;
  t[1]=c*min(x,y)*2;
  t[2]=c*max(x,y)*2;
  if(x>y){
    t[1]+=a*(x-y);
  }
  else{
    t[1]+=b*(y-x);
  }
  t[0]=min(t[0],t[1]);
  t[0]=min(t[0],t[2]);

  cout<<t[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

a, b = map(int, input().split())

if b - a > 2019:
    b = a + 2019
s = set()

for i in range(a, b+1):
    s.add(i%2019)
    
import itertools
minval = a*b
for pair in list(itertools.combinations(s,2)):
    val = (pair[0]*pair[1])%2019
    if minval > val:
        minval = val
print(minval)

Measured memory_bytes: 157844
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {

	int X;
	cin >> X;

	for (int i = -200; i <= 200; ++i)
	{
		for (int j = -200; j <= 200; ++j)
		{
			if (pow(i, 5) - pow(j, 5) == X) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3972