akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N;cin>>N;
    vector<int> A(N);
    REP(i,N){
        cin >> A[i];
    }
    vector<int> dp(N,-1);
    dp[N-1] = A[0];
    int min_itr = N-1;
    for(int i =1 ; i < N; i++){
        if(A[i] > dp[N-1]){
            dp[N-1] = A[i];
        }
        else if (A[i] <= dp[min_itr]){
            min_itr--;
            dp[min_itr] = A[i];
         }

        else{
            int sort_itr = lower_bound(ALL(dp),A[i]) - dp.begin() - 1;
            dp[sort_itr] = A[i];
        }
    }
    int ans = 0;
    REP(i,N){
        if(dp[i] != -1) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1152
#TLE

#comb_mod(n, r, mod) = nCr % mod
def comb_mod(n, r, mod):
    ans = 1
    if r <= n/2:
        for i in range(n-r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    else:
        for i in range(r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, n-r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    return ans

n, a, b = map(int, input().split())
ans = pow(2, n, 10**9+7) - comb_mod(n, a, 10**9+7) - comb_mod(n, b, 10**9+7) - 1
if ans < 0:
    ans += 10**9 + 7
if ans < 0:
    ans += 10**9 + 7

print(int(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n, d, ans = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++){
		double x, y;
		cin >> x >> y;
		if (sqrt(x*x + y*y) <= d){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

int main(){
	IOS;
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n ; ++i){
		cin >> a[i];
	}
	int dp[n];

	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for(int i=2;i<n ; ++i){
		dp[i] = 1e9;
		for(int j = max(0,i-k) ; j<i ; ++j){
			dp[i] = min(dp[i],dp[j] + abs(a[j]-a[i]));
		}
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
N, Y = list(map(int, input().split()))
maxx = Y // 10000
break_loop = False
noans = 1
for i in range(maxx + 1):
    y = Y - 10000 * i
    max_2 = y // 5000
    for j in range(max_2 + 1):
        y_2 = y - 5000 * j
        if y_2 == 1000 * (N - i -j):
            if i <= N and j <= N and 0 <= N - i - j <= N: 
                print(i, j, N - i - j)
                break_loop = True
                noans = 0
                break
    if break_loop:
        break
if noans:
    print(-1, -1, -1)


Measured memory_bytes: 3064
from collections import defaultdict, deque

n, m = [int(i) for i in input().split()]
graph = defaultdict(list)
for _ in range(m):
    a, b = [int(i) for i in input().split()]
    graph[a].append(b)
    graph[b].append(a)

def bfs():
    q = deque([(1, None)])
    visited = set()
    posts = {}

    while q:
        node, last_node = q.pop()
        if last_node:
            posts[node] = last_node
        visited.add(node)
        for neighbor in graph[node]:
            if neighbor not in visited:
                q.appendleft((neighbor, node))
                visited.add(neighbor)
    
    return posts, len(visited)

posts, total_visited = bfs()
if total_visited != n:
    print('No')
else:
    print('Yes')
    for p in range(2, n+1):
        print(posts[p])


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

int main()
{
	int n, k;
	cin >> n >> k;
	int h[100001];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}
	sort(h, h + n);
	int mi = (1<<30)-1;
	for (int i = 0; i < n - k + 1; ++i)
	{
		mi = min(mi, h[i + k - 1] - h[i]);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int H,W;
	cin>>H>>W;
	vector<vector<char>> S(H+2);
	fx(H+2){
		fy(W+2){
			if(x==0||x==H+1||y==0||y==W+1){
				pb(S.at(x),'#')
			}else{
				char h;
				cin>>h;
				pb(S.at(x),h)
			}
		}
	}
	
	fx(H+2){
		fy(W+2){
			cout<<S.at(x).at(y);
		}
      cout<<endl;
	}
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int maxNum = sc.nextInt();
    int over = sc.nextInt();
    int under = sc.nextInt();

    int ans = 0;

    for(int num=1; num<=maxNum ; num++){
        String numStr = String.valueOf(num);

        int plusNum = 0;
        for(char charNum : numStr.toCharArray()){
            plusNum += Integer.parseInt(String.valueOf(charNum));
        }
        if(plusNum >= over && plusNum <= under){
            ans += num;
        }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 24148
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int N = 10005;

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

int n, a[N], np[N], p[N];
vector<int> out;

void work()
{
	int u = a[0];
	for(int i = 1; i <= n; ++i)
		u = gcd(u, abs(a[i]));
	if(u)
	{
		for(int i = 0; i <= n; ++i)
			a[i] /= u;
	}
	for(int x = 2; x * x <= u; ++x)
		if(u % x == 0)
		{
			out.push_back(x);
			for(; u % x == 0; u /= x);
		}
	if(u > 1)
		out.push_back(u);
}

void work2()
{
	for(int j = 1; j <= p[0]; ++j)
	{
		vector<long long> po(a, a + n + 1);
		for(int k = n; k >= p[j]; --k)
			po[k - p[j] + 1] += po[k];
		int ok = 1;
		for(int k = 0; k < p[j]; ++k)
			if(po[k] % p[j])
			{
				ok = 0;
				break;
			}
		if(ok)
			out.push_back(p[j]);
	}
}

int main()
{
	scanf("%d", &n);
	for(int i = 0; i <= n; ++i)
		scanf("%d", &a[n - i]);
	for(int i = 2; i <= n; ++i)
	{
		if(!np[i])
			p[++p[0]] = i;
		for(int j = 1; j <= p[0] && i * p[j] <= n; ++j)
		{
			np[i * p[j]] = 1;
			if(i % p[j] == 0) break;
		}
	}
	work();
	work2();
	sort(out.begin(), out.end());
	out.erase(unique(out.begin(), out.end()), out.end());
	for(auto p : out)
		printf("%d\n", p);
	return 0;
}

Measured memory_bytes: 384
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

string s;
int k;

void solve() {
    rep(i, s.length()) {
        if (s[i] != 'a' && s[i] + k > 'z') {
            k -= ('z' - s[i] + 1);
            s[i] = 'a';
        }
    }
    k %= 26;
    if (k > 0) s[s.length() - 1] += k;
    cout << s << endl;
}

int main() {
    cin >> s;
    cin >> k;
    solve();
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.D
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = ReadLongs();
            var A = inputs[0];
            var B = inputs[1];

            var min = Math.Min(A, B);
            var max = Math.Max(A, B);
            var factsOfMin = GetPrimeFactors(min).ToList();
            var factsOfMax = GetPrimeFactors(max).ToList();

            var count = 1L;
            foreach (var fact in factsOfMin)
            {
                if (factsOfMax.Contains(fact))
                {
                    count++;
                }
            }

            return count;
        }
        public static IEnumerable<long> GetPrimeFactors(long n)
        {
            for (long a = 2; a * a <= n; ++a)
            {
                if (n % a != 0) continue;

                // 割れる限り割り続ける
                while (n % a == 0)
                {
                    n /= a;
                }

                yield return a;

            }

            // 最後に残った数について
            if (n != 1) yield return n;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 13396
import qualified Data.Set as Set
import Control.Monad


isBothMember :: Ord a => Set.Set a -> Set.Set a -> a -> Bool
isBothMember xs ys x
  | (Set.member x xs) && (Set.member x ys) = True
  | otherwise = False

countUniq :: String -> Int -> Int
countUniq xs n =
  let a = Set.fromList $ take n xs
      b = Set.fromList $ drop n xs
  in length $ filter (==True) $ map (isBothMember a b) ['a'..'z']


countMax :: String -> Int
countMax xs = foldr1 max $ map (countUniq xs) [0..n]
  where n = length xs



main :: IO ()
main = do
  _ <- getLine
  xs <- getLine                                                                                                            

  print $ countMax xs

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define N 10004
#define llong long long
#define _pair  pair<int, int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    llong a,b;
    cin>>a>>b;
    llong res=(a+b)/2;
    if (abs(a-res) == abs(b-res)){
        cout<<res;
    }
    else{
        cout<<"IMPOSSIBLE";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define int long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int mod = 1e9+7;

int32_t main(){

	int n;
	cin>>n;

	map<string,int> m;
	string s;
	// cin>>s;
	for(int i = 0; i < n; i++){
		cin>>s;
		m[s]++;
	}

	cout<<m.size()<<"\n";
	return 0;
}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;

struct edge {
    int src, dst, cost; 
    edge(int s, int t, int c): src(s), dst(t), cost(c) {}
    bool operator < (const edge &rhs) const {return cost > rhs.cost;}
};
const int INF = 1e8;

void dijkstra(const vector<vector<edge> > &G, vector<int> &d, const int s) {
    d.assign(d.size(), INF);
    d[s] = 0;
    typedef pair<int, int> P;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, s));

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(auto &e : G[v]) {
            if(d[e.dst] > d[v] + e.cost) {
                d[e.dst] = d[v] + e.cost;
                que.push(P(d[e.dst], e.dst));
            }
        }
    }
}

int main(void) {
    int n, m, s, g1, g2;
    while(cin >> n >> m >> s >> g1 >> g2 && n) {
        vector<vector<edge> > G(n);
        vector<vector<int> > d(n, vector<int>(n));
        --s; --g1; --g2;
        REP(i, m) {
            int b1, b2, c;
            cin >> b1 >> b2 >> c;
            G[b1-1].push_back(edge(b1-1, b2-1, c));
        }
        REP(i, n) {
            dijkstra(G, d[i], i);
        }
        int cost = numeric_limits<int>::max();
        REP(i, n) {
            cost = min(cost, d[s][i] + d[i][g1] + d[i][g2]);
        }
        cout << cost << endl;
    }
}

Measured memory_bytes: 3168
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<String> items = new HashSet<String>();
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			String item = sc.next();
			if(!items.contains(item)) items.add(item);
		}
		System.out.println(items.size());
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++) {
        cin >> H[i];
    }
    
    int Temp=H[0];
    bool b=true;
    for(int i=1;i<N;i++){
        if(H[i] > Temp) Temp=H[i];
        else if(Temp - H[i] > 1) {
            b=false;
            break;
        }
    }
    
    if(b) cout<<"Yes";
    else cout<<"No";
    
    cout<<endl;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::{HashSet,HashMap};
#[allow(unused_imports)]
use std::cmp::{min,max};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!(s:String);
    let mut i = 0;
    let mut ok = true;
    for c in s.chars() {
        i += 1;
        if i % 2 == 1 && (c == 'R' || c == 'U' || c == 'D') {
            continue;
        }
        if i % 2 == 0 && (c == 'L' || c == 'U' || c == 'D') {
            continue;
        }
        ok = false;
    }
    if ok {
        println!("Yes");
    }
    else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;
 
public class Main {
 
    public static void main(String args[]) throws Exception {
 
        Scanner sc = new Scanner(System.in);
        int A =  sc.nextInt();
        int B = sc.nextInt();
 
        System.out.println((int)Math.ceil((double)(A+B)/2));
    }
}

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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            long T = 1, A = 1;
            for (int i = 0; i < N; ++i)
            {
                var t = cin.ReadInt;
                var a = cin.ReadInt;
                var n = Max((long)((T + t - 1) / t), (long)((A + a - 1) / a));
                T = n * t;
                A = n * a;
            }
            WriteLine(T + A);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
    }
}


Measured memory_bytes: 13268
a = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".replace(
    " ", ""
).split(
    ","
)
K = int(input())
print(a[K - 1])


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}




ll A, B, C;

int main () {
  cin >> A >> B >> C;

  Rep(i, 100000) {
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
      cout << i << "\n";
      return 0;
    }

    ll na = B / 2 + C / 2;
    ll nb = C / 2 + A / 2;
    ll nc = A / 2 + B / 2;

    A += na;
    B += nb;
    C += nc;
  }

  cout << "-1\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
char s[N];
int ans[N]={};

int main(){
	scanf("%s", s);
	int n = strlen(s);
	REP(i, n){
		if(!(s[i] == 'R' && s[i+1] == 'L')) continue;
		for(int j = i; s[j] == 'R'; j--) ans[i + (i-j)%2]++;
		for(int j=i+1; s[j] == 'L'; j++) ans[i+1-(j-i-1)%2]++;
	}
	REP(i, n) printf("%d ", ans[i]);
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

int n, m, ans, x, a[N], cnt[N], s[N];
int main()
{
	int i, j, t1, t2;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
		s[a[i]]++;
//		cnt[a[i]]++;
	}
	for (i = n; i >= 1; i--) {
		for (j = i; j > i - s[i]; j--) cnt[j]++;
	}
	for (i = 1; i<= n; i++) if (cnt[i] > 0) ans++;
	while (m--) {
		scanf("%d %d", &t1, &t2);
		x = a[t1];
		if (x - s[x] + 1 >= 1) {
			cnt[x - s[x] + 1]--;
			if (cnt[x - s[x] + 1] == 0) ans--;
		}
		s[x]--;
		if (t2 - s[t2] >= 1) {
			cnt[t2 - s[t2]]++;
			if (cnt[t2 - s[t2]] == 1) ans++;
		}
		s[t2]++;
		a[t1] = t2;
		printf("%d\n", n - ans);
	}
    return 0;
}


Measured memory_bytes: 3712
from math import ceil
n,k = map(int,input().split())
a=list(map(int,input().split()))
#index = a.index(1)
#left, right = index, n-index-1
#if n!=k: print(ceil(left/(k-1))+ceil(right/(k-1)))
if n!=k: print(1+ceil((n-k)/(k-1)))
else: print(1)

Measured memory_bytes: 13812
# 2019/12/12

a,b,k=map(int,input().split())
turn=1

def eat(x,y):
    if x%2:
        x-=1
    x//=2
    y+=x
    return x,y

for i in range(k):
    if turn:
        a,b=eat(a,b)
    else:
        b,a=eat(b,a)
    turn=1-turn
print('{} {}'.format(a,b))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC062A___Grouping
{
    class Program
    {
        static int[] group1 = { 1, 3, 5, 7, 8, 10, 12 };
        static int[] group2 = { 4, 6, 9, 11 };
        static int[] group3 = { 2 };
        static void Main(string[] args)
        {
            List<int[]> groups = Initialize();

            string[] input = Console.ReadLine().Split(' ');

            bool isSameGroup = IsSameGroup(int.Parse(input[0]), int.Parse(input[1]), groups);

            string result = "No";
            if (isSameGroup)
            {
                result = "Yes";
            }

            Console.WriteLine(result);

        }

        static List<int[]> Initialize()
        {
            List<int[]> list = new List<int[]>();
            list.Add(group1);
            list.Add(group2);
            list.Add(group3);
            return list;
        }

        static bool IsSameGroup(int a, int b, List<int[]> groups)
        {
            bool result = false;

            foreach (var group in groups)
            {
                if (group.Contains(a) &&
                    group.Contains(b))
                {
                    result = true;
                }

            }

            return result;
        }
    }
}


Measured memory_bytes: 13268
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A, B, C = sorted(il()), sorted(il()), sorted(il())

    ret = 0
    for b in B:
        a = bisect.bisect_left(A, b)
        c = bisect.bisect_left(C, b+1)
        ret += a * (len(C) - c)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37480
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll R,G,B;

void solve(){
    if((R*100+G*10+B)%4==0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

int main(){
    cin >> R >> G >> B;

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
#define mod 1000000007
int dp[3005][3005];
int32_t main() {
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    string lcs={};
  
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    {
        if(s[i-1]==t[j-1])
        dp[i][j]=1+dp[i-1][j-1];
        else
        {
         dp[i][j]=max(dp[i-1][j],dp[i][j-1]); 
        }
    }
    int i=n,j=m;
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        lcs.pb(s[i-1]),i--,j--;
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            i--;
            else
            j--;
            
        }
        
    }
    reverse(lcs.begin(),lcs.end());
    cout<<lcs;
  
    return 0;
}



Measured memory_bytes: 74048
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
  
int main(){
int N;
cin>>N;
for(int i=1;i<11;i++){
    if((i*100)+(i*10)+i>=N){
    cout<<(i*100)+(i*10)+i<<endl; 
    break;}
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
	FASTIO;
    int k;
    int a[1000001];
    cin >> k;
    a[1] = 7 % k;
    for(int i = 2; i <= k; ++i) a[i] = (a[i-1] * 10 + 7) % k;
    for(int i = 1; i <= k; ++i) {
        if(a[i] == 0) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
}

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

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

  int a,b; cin>>a>>b;
  if(a<=0&&0<=b) { cout << "Zero" << endl; return 0; }
  if(a>0) { cout << "Positive" << endl; return 0; }

  if( (b-a) %2 == 0 ) cout << "Negative" << endl;
  else cout << "Positive" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n,m;
int a[maxn];
priority_queue<int> pq;
long long kq;

int main(){
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  for(int i=1;i<=n;i++) pq.push(a[i]);
  for(int i=1;i<=m;i++){
    int z=pq.top();
    pq.pop();z=z/2;
    pq.push(z);
  }
  kq=0;
  while(!pq.empty()){
    int z=pq.top();pq.pop();
    kq=kq+z;
  }
  cout<<kq;
}


Measured memory_bytes: 1276
import heapq
N = int(input())
a = list(map(int, input().split()))

heap_left = []
left = 0
for i in range(N):
    left += a[i]
    heapq.heappush(heap_left, a[i])

lst_left = [left]
for i in range(N, 2 * N):
    tmp = heapq.heappushpop(heap_left, a[i])
    left = left - tmp + a[i]
    lst_left += [left]

heap_right = []
right = 0
for i in range(2 * N, 3 * N):
    right += a[i]
    heapq.heappush(heap_right, -1 * a[i])

lst_right = [right]
for i in range(2 * N -1, N-1, -1):
    tmp = heapq.heappushpop(heap_right, -1 * a[i])
    right = right - (-1 * tmp) + a[i]
    lst_right += [right]

# print (lst_left)
# print (lst_right)
ans = -1 * 10 ** 20
for i in range(N+1):
    # print (lst_left[i], lst_right[-(i+1)])
    ans = max(ans, lst_left[i]-lst_right[-(i+1)])

print (ans)

Measured memory_bytes: 37212
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;

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

    int h[n];
    int ans[n];
    for(int i=0;i<n;i++)cin >> h[i];

    ans[0] = 0;
    ans[1] = abs(h[1]-h[0]);

    for(int i=2;i<n;i++){
        ans[i] = min(ans[i-2]+abs(h[i-2]-h[i]),ans[i-1]+abs(h[i-1]-h[i]));
    }
    cout << ans[n-1] << endl;
}


Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  add = 1
  for j in A[:i]:
    if j % 2 == 0: add *= 2
  if A[i] % 2 == 1: add *= 2
  add *= 3 ** (N - i - 1)
  ans += add
print(ans)  

Measured memory_bytes: 38384
#include <cstdio>
#include <cmath>
#include <limits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <string>
#include <iostream>

int main()
{
	using namespace std;
    int a,b;
	cin >> a >> b;
    if ((a*b)%2==1)
    {
        cout << "Odd" << endl;
    }
    else
    {
        cout << "Even" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n,xr=0;
  cin >> n;
  int a[n+1]={0};
  for(int i=1;i<=n;i++){
    int x;
    cin >> x;
    a[i] = x;
    xr = (xr^x);
  }
  for(int i=1;i<=n;i++){
    cout << (xr^a[i]) << " ";
  }
  cout<<endl;


return 0;
}
///....


Measured memory_bytes: 5224
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
struct Node{
    int num;
    int pre;
    int cnt;
};
int main(int argc, char const *argv[]){
    ll n, ans=0;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        ans^=a[i];
    }
    rep(i,n){
        cout << (ans^a[i]) << endl;
    }

    return 0;
}





Measured memory_bytes: 4696
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;

using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%ld", &n);

    vector<int> a(n), s(n+1), s0(n+1);
    int i;
    s[0]=0;
    s0[0]=1;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        s[i+1]=s[i]^a[i];
        s0[i+1]=s0[i]+((s[i+1]==0)? 1: 0);
    }
#ifdef _DEBUG
    printf("s[n]=%d, s0[n]=%d\n", s[n], s0[n]);
#endif
    map<int, int> z;  // val, previous index
    set<int> save;

    vector<ll> dp(n), dp0(n);
    dp0[0]=1;
    for(i=1; i<n; i++) {
        if(s[i]!=0) {
            int prev=z[s[i]];
            int num0 = s0[i]-s0[prev];
            {
                dp0[i]=(dp[prev]*(num0)+dp0[prev])%MOD;
                dp[i]=(dp[prev]*(num0+1)+dp0[prev])%MOD;
            }
            z[s[i]]=i;
            save.insert(i);
            save.erase(prev);
        }
    }

    ll ans=1;
    if(s[n]==0) {
        for(i=0; i<s0[n]-2; i++) {
            ans = ans*2%MOD;
        }
    }

    auto it=save.begin();
    for(; it!=save.end(); ++it) {
        if(s[n]==0) {
            ans = (ans + dp[*it])%MOD;
        }
        else if(s[n]==s[*it]) {
            int num0 = s0[n]-s0[*it];
            ans = (dp0[*it] + dp[*it]*num0)%MOD;
        }
    }
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 40832
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
int main(){
    ll n; cin>>n;
    VI a(n),b(n); 
    rep(i,n){cin>>a[i]; b[i]=a[i];}
    ll max_a,sec_a,cnt;
    set<ll> S;
    rep(i,n) S.insert(a[i]);
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    max_a=a[0];
    cnt=count(a.begin(),a.end(),max_a);
    S.insert(0);
    if(cnt>1) {rep(i,n) cout<<max_a<<endl; return 0;}
    else {
        S.erase(*rbegin(S));sec_a=*rbegin(S);
        rep(i,n){
            if(b[i]==max_a) cout<<sec_a<<endl;
            else cout<<max_a<<endl;
        }
    }
}

Measured memory_bytes: 10240
/*
 * Author : Sadi
 * Wed 01/07/2020
 * 18:23:09.20
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, x;
    cin >> n >> x;
    vector<int> v(n + 1);
    v[0] = x;
    for(int i = 0; i < n; ++i) {
        cin >> v[i + 1];
    }
//        cout << v << endl;
    vector<int> dif;
    for(int i = 1; i <= n; ++i) {
        dif.push_back(abs(v[i] - v[i - 1]));
    }
    int gcd = 0;
//        cout << dif << endl;
    for(int i = 0; i < (int) dif.size(); ++i) {
        gcd = __gcd(gcd, dif[i]);
    }
    cout << gcd << endl;

    return 0;
}


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

INF = 1 << 29
dp = [[INF] * 55 for _ in range((1 << N) + 1)]
dp[0][0] = 0

for bit in range(1 << N):
    con = 0
    for i in range(N):
        if bit & (1 << i):
            con += 1
            
    ords = []
    iters = con
    for i in range(N):
        if not (bit & (1 << i)):
            ords.append([i, iters])
            iters += 1

    for s in range(51):
        if dp[bit][s] >= INF:
            continue

        for p in ords:
            # p[0]: 元々のaのindex, p[1]: dp[bit][s]の状態でのindex
            ns = -1
            if abs(p[0] - con) % 2 == 0:
                ns = A[p[0]]
            else:
                ns = B[p[0]]

            if ns >= s:
                dp[bit|(1 << p[0])][ns] = min(dp[bit|(1 << p[0])][ns],
                                              dp[bit][s] + abs(p[1] - con))
                    
ans = INF
for s in range(51):
    ans = min(ans, dp[(1 << N) - 1][s])
if ans < INF:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 174328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, n-1) {
    if (s[i] == s[i+1]) ans++;
  }
  ans = min(n-1, ans + 2 * k);
  cout << ans << '\n';  
  return 0;
}

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

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

  int d, g; cin >> d >> g;
  vector<int> p(d), c(d);
  for(int i = 0; i < d; i++) {
  	cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for(int i = 0; i < (1 << d); i++) {
  	int cnt = 0;
  	long long sum = 0;
  	int mx = -1;
  	for(int j = 0; j < d; j++) {
  		if((1 & i >> j)) {
  			sum += p[j] * 100 * (j + 1) + c[j];
  			cnt += p[j];
  		}
  		else{
  			mx = j;
  		}
  	}
  	if(sum < g) {
  		for(int j = 0; j < p[mx]; j++) {
  			sum += (mx + 1) * 100;
  			cnt++;
  			if(sum >= g) {
  				break;
  			}
  		}
  	}
  	if(sum < g) {
  		continue;
  	}
  	else{
  		ans = min(ans, cnt);
  	}
  }
  cout << ans << endl;
	return 0;
}	


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int sum = 0;
        for(int i = 0; i < n; i++) sum += Integer.parseInt(sc.next());
        System.out.println(h > sum ? "No" : "Yes");
    }
}


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

int main(){
    int n;
    rep(i, 5){
        cin >> n;
        if(n == 0){
            cout(i+1);
            return 0;
        }
    }
}


Measured memory_bytes: 3636
n,m,x,y = gets.chomp.split(" ").map(&:to_i)
x_arr = gets.chomp.split(" ").map(&:to_i)
y_arr = gets.chomp.split(" ").map(&:to_i)

z = y_arr.min
if x < z && z <= y && x_arr.max < z && z <= y_arr.min
  puts "No War"
else
  puts "War"
end


Measured memory_bytes: 14240
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
K = int(input())
A, B = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
#list = [input() for i in range(N)]
i=A
while(i<=B):
    if(i%K==0):
        print("OK")
        exit()
    i=i+1

print("NG")


Measured memory_bytes: 9112
import numpy as np

n, k = [int(i) for i in input().split()]
s = input()

ones = [len(x) for x in s.replace('0', ' ').split()]
zeros = [len(x) for x in s.replace('1', ' ').split()]

if s[0]=='0':
  ones = [0] + ones
if s[-1]=='0':
  ones = ones + [0]
  
ones = np.array(ones)
zeros = np.array(zeros)

if k >= len(zeros):
  result = n
else: 
  result = [
    np.sum(ones[i:i+k+1]) + np.sum(zeros[i:i+k])
    for i in range(len(zeros)-k+1)]
  result = max(result)

print(result)

Measured memory_bytes: 15364
tailrec fun gcd(a:Int,b:Int):Int=if(b==0) a else gcd(b,a%b)

fun main() {
	val n=readLine()!!.toInt()
	var r=0L
	for(i in 1..n) {
		for(j in 1..n) {
			val t=gcd(i,j)
			for(k in 1..n) {
				r+=gcd(t,k)
			}
		}
	}
	println(r)
}


Measured memory_bytes: 34528
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	string s;
	ll k;
	char ans=1;
	cin >>s>>k;
	for (ll i = 0; i < s.size() and i<k ; i++) {
		if (s[i] != '1') {
			ans = s[i];
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1<< endl;
}

Measured memory_bytes: 3584
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>
#include <bitset>

using namespace std;

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

  vector<long> nums(N+1, 0);
  for (size_t n = 1; n <= N; ++n) cin >> nums[n];
  vector<uint8_t> check(N, 0);
  vector<long> res;
  res.reserve(N);
  for (size_t n = N; n > 0; --n) {
    long sum = 0;
    for (size_t i = 2 * n; i <= N; i += n) {
      if (check[i]) ++sum;
    }
    if ((sum & 1) ^ nums[n] == 1) {
      check[n] = 1;
      res.push_back(n);
    }
  }
  if (res.size() == 0) cout << 0 << endl;
  else {
    cout << res.size() << endl;
    auto it = res.crbegin();
    cout << *it++;
    for (auto end = res.crend(); it != end; ++it) {
      cout << " " << *it;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x:sum(x))

x = y = 0
i = 0
while AB:
    a,b = AB.pop()
    if i%2:
        y += b
    else:
        x += a
    i += 1
print(x-y)

Measured memory_bytes: 27056
import sys
input = sys.stdin.readline

N = int(input())
A = [int(i) for i in input().split()]

from collections import Counter

for key,count in sorted(Counter(A).items(), key=lambda x:x[0]):
    if key == 0 and N % 2 == 1:
        continue
    if count == 2 and key % 2 != N % 2:
        continue
    print(0)
    exit()

if N % 2 == 1:
    N -= 1

print(2 ** (N//2) % (10**9 + 7))

Measured memory_bytes: 15844
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
li=[[0]*10 for i in range(10)]
for i in range(n):
    tmp=str(i+1)
    li[int(tmp[0])][int(tmp[-1])]+=1
# print(li)
ans=0
for i in range(10):
    for j in range(10):
        ans+=li[i][j]*li[j][i]
print(ans)

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }


int n;

int main()
{
  cin >> n;

  int k = 0;
  while ((1<<k) < n) k++;

  forn1(i,n) {
    for (int j = i+1; j <= n; j++) {
      cout << ffs(i^j) << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char a[3*maxn];
int b[3*maxn]={0};
int c[3*maxn]={0};
int main()
{
    int n,k=0,p=0;
    scanf("%d",&n);
    scanf("%s",a+1);
    int ans=3*maxn;
    for(int i=1;i<=n;i++)
    {
        if(a[i]=='W') p++;
        b[i]=p;
    }
    for(int i=n;i>=1;i--)
    {
        if(a[i]=='E') k++;
        c[i]=k;
    }
    for(int i=1,j=n;i<=n&&j>=1;i++,j--)
    {
        p=b[i],k=c[i];
        ans=min(ans,p+k-1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

int main() {

	int N;
	cin >> N;

	int count = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) count++;
	}

	cout << (double)count / N << endl;

	return 0;

}

Measured memory_bytes: 256