akhauriyash/Code-Regression huggingface dataset:
from collections import deque

def search(xs, ys, xg, yg, board):  
  direct = ((-1, 0), (1, 0), (0, -1), (0, 1))
  visited = [[False] * (w + 2) for _ in range(h + 2)]
  visited[ys][xs] = True
  que = deque()
  que.append((xs, ys))
  while que:
    x, y = que.popleft()
    for dx, dy in direct:
      nx, ny = x + dx, y + dy
      if (nx, ny) == (xg, yg):
        print("OK")
        return
      if not visited[ny][nx]:
        visited[ny][nx] = True
        if board[ny][nx] == color:
          que.append((nx, ny))
  else:
    print("NG")


while True:
  w, h = map(int, input().split())
  if w == 0:
    break

  xs, ys = map(int, input().split())
  xg, yg = map(int, input().split())

  board = [[0] * (w + 2) for _ in range(h + 2)]
  n = int(input())
  for _ in range(n):
    c, d, x, y = map(int, input().split())
    if d == 0:
      for xi in range(x, x + 4):
        for yi in range(y, y + 2):
          board[yi][xi] = c
    else:
      for xi in range(x, x + 2):
        for yi in range(y, y + 4):
          board[yi][xi] = c
  
  color = board[ys][xs]
  if color == 0 or board[yg][xg] != color:
    print("NG")
    continue
  
  search(xs, ys, xg, yg, board)


Measured memory_bytes: 6140
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define MP make_pair
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

int dp[20000][256];

int main(){
	//freopen("test.txt", "r", stdin);
	int n, m;
	while(cin >> n >> m, n|m){
		vector<int> C(m);
		rep(i, m) cin >> C[i];
		vector<int> x(n);
		rep(i, n) cin >> x[i];

		rep(i, 20000) rep(j, 256) dp[i][j] = 2<<29;

		rep(i, m){
			int val = 128+C[i];
			if(val < 0) val = 0;
			if(val > 255) val = 255;
			dp[0][val] = (x[0]-val)*(x[0]-val);
		}
		rep(i, n-1){
			rep(j, 256){
				if(dp[i][j] == -1) continue;
				rep(k, m){
					int val = j+C[k];
					if(val < 0) val = 0;
					if(val > 255) val = 255;
					int d = (x[i+1]-val)*(x[i+1]-val);
					dp[i+1][val] = min(dp[i+1][val], dp[i][j]+d);
				}
			}
		}
		int ans = 2<<29;
		rep(i, 256){
			ans = min(ans, dp[n-1][i]);
		}
		cout << ans << endl;
	}

	return 0;
}

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

#define ll long long

using namespace std;

const int maxn = 2 * (int)1e5 + 100;
int n, a[maxn];
struct node {
    int l, r, val;
    node() {}
    node(int _l, int _r, int _val) : l(_l), r(_r), val(_val) {}
    friend bool operator < (node a, node b) {
        return a.val < b.val;
    }
};

bool cmp(int a, int b) {
    return a > b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n, cmp);
    ll ans = a[0];
    priority_queue<node> q;
    q.push(node(a[0], a[1], min(a[0], a[1])));
    q.push(node(a[0], a[1], min(a[0], a[1])));
    for (int i = 2; i < n; ++i) {
        node now = q.top();
        q.pop();
        ans += now.val;
        q.push(node(now.l, a[i], min(now.l, a[i])));
        q.push(node(now.r, a[i], min(now.r, a[i])));
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 7088
from itertools import accumulate

N, K = map(int, input().split())
A = list(map(int, input().split()))

C = [0] + list(accumulate(A))
S = []

for i in range(N):
    for j in range(i + 1, N + 1):
        S.append(C[j] - C[i])

for i in range(64)[::-1]:
    tmp = []
    for s in S:
        if (s >> i) & 1:
            tmp.append(s)

    if len(tmp) >= K:
        S = tmp

res = 2**64 - 1

for i in range(K):
    res &= S[i]

print(res)

Measured memory_bytes: 116632
#include<bits/stdc++.h>
using namespace std;
main(){
  int a[44],n;
  a[0]=a[1]=1;
  cin>>n;
  for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
  cout<<a[n]<<endl; 
}


Measured memory_bytes: 3128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;

#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}

fn get_word() -> String {
    let stdin = std::io::stdin();
    let mut stdin=stdin.lock();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn ask(i: i32) -> i32 {
    println!("{}", i);
    let s = get_word();
    if s == "Vacant" {
        return 0;
    }
    if s == "Male" {
        return 1;
    }
    2
}

fn solve() {
    let n: i32 = get();
    let mut a0 = ask(0);
    if a0 == 0 {
        return;
    }
    let mut al = ask(n - 1);
    if al == 0 {
        return;
    }
    let mut hi = n - 1;
    let mut lo = 0;
    while hi - lo > 1 {
        let mid = (hi + lo) / 2;
        let u = ask(mid);
        if u == 0 {
            return;
        }
        if (mid - lo + u + a0) % 2 != 0 {
            hi = mid;
            al = u;
        } else {
            lo = mid;
            a0 = u;
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 9040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        int count = 0;
        boolean isOdd = false;
        while (true) {
            for (int i = 0; i < a.length; i++) {
                if (a[i] % 2 != 0) {
                    isOdd = true;
                }
            }
            if (isOdd) {
                break;
            } else {
                for (int i = 0; i < a.length; i++) {
                    a[i] = a[i] / 2;
                }
                count++;
            }
        }

        System.out.println(count);
    }
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 998244353;
//constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

mint mod_pow(mint a, ll x) {
  mint res = 1;
  while(x > 0) {
    if (x & 1) res *= a;
    a *= a; x >>= 1;
  }
  return res;
}

bitset<4000> gcd(bitset<4000>& p, bitset<4000>& q) {
  int dp, dq;
  dp = dq = -1;
  rep(i, 4000) {
    if (p[i]) dp = i;
    if (q[i]) dq = i;
  }
  if (dq > dp) {
    swap(dp, dq);
    swap(p, q);
  }
  if (dq == -1) {
    return p;
  }
  int d = dp-dq;
  p ^= (q<<d);
  return gcd(p, q);
}

mint calc(bitset<4000>& x, bitset<4000>& r) {
  bitset<4000> k;
  int dx, dr;
  rep(i, 4000) {
    if (x[i]) dx = i;
    if (r[i]) dr = i;
  }
  mint ret = 0;

  r <<= dx-dr;
  for(int i=dx; i>=dr; i--) {
    if (x[i]) {
      ret += mod_pow(2, i-dr);
      debug(ret.x);
    }
    if (k[i] ^ x[i]) {
      k ^= r;
    }
    r >>= 1;
  }

  bool flag = true;
  for(int i=dr-1; i>=0; i--) {
    if (x[i] && !k[i]) {
      break;
    } else if (!x[i] && k[i]) {
      flag = false;
      break;
    }
  }
  if (flag) ret += 1;
  return ret;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  string s; cin >> s;
  bitset<4000> x;
  reverse(s.begin(), s.end());
  rep(i, s.size()) {
    if (s[i] == '1') {
      x.set(i);
    }
  }

  vector<bitset<4000>> vec(n);
  rep(i, n) {
    cin >> s;
    reverse(s.begin(), s.end());
    rep(j, s.size()) {
      if (s[j] == '1') {
        vec[i].set(j);
      }
    }
  }

  bitset<4000> r;
  rep(i, n) {
    r = gcd(r, vec[i]);
  }

  cout << calc(x, r) << endl;
}

Measured memory_bytes: 4480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		System.out.println(N <= K ? N * X : K * X + (N - K) * Y);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
ll pw(ll b, ll r){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%mod;
		b = (b*b)%mod;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,a,b;cin>>n>>a>>b;
	if(a>b)swap(a,b);
	if((b-a)&1){
		cout<<min(a,n-b+1)+((b-a-1)/2)<<en;
	} else cout<<((b-a)>>1)<<en;
	return 0 ; 
}



Measured memory_bytes: 256
S = input()
MAX = 0
ATGC = ['A','T','G','C']
for T in range(0,len(S)):
    if S[T] in ATGC:
        Count = 1
        for TT in range(T+1,len(S)):
            if S[TT] in ATGC:
                Count += 1
            else: break
        if Count>MAX: MAX = Count
print(MAX)

Measured memory_bytes: 9000
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		int n,a,b;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		if(n * a < b)	System.out.println(n * a);
		else System.out.println(b);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <string.h>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#define ll long long int
#define pb push_back
#define x first
#define y second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORR(i, a, b) for(int i = a; i>b; i--)
#define ri(x) scanf("%d", &x)
#define rl(x) scanf("%lld", &x)
using namespace std;
const int MAXN = 1e5 +5;

int zet[MAXN];
int n;
char str[MAXN];

void z_function(){
	int l =0, r =0;
	FOR(i, 1, n){
		if(i<=r) zet[i] = min(zet[i-l], r-i+1);
		while(i+zet[i]<n && str[i+zet[i]] == str[zet[i]]) zet[i]++;
		if(i+zet[i]-1>r){
			l = i; r = i+zet[i] -1;
		}
	}
}

void solve(){
	string s, t, text;
	cin>>s;
	cin>>t;
	text = t+"#"+s+s;
	int p = t.length();
	strcpy(str, text.c_str());
	n = strlen(str);
	z_function();
	FOR(i, 0, n){
		if(zet[i]==p){
			printf("Yes");
			return;
		}
	}
	printf("No");
}

int main(){
	solve();
	return 0;
}

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

bool comp(tuple<string,int,int> a,tuple<string,int,int> b){
    if(get<0>(a)!=get<0>(b))
        return get<0>(a)<get<0>(b);
    else
        return get<1>(a)>get<1>(b);
}

int main(){
    int n;cin>>n;
    vector<tuple<string,int,int>>vec;
    for(int i=0;i<n;i++){
        string d;int e;cin>>d>>e;
        vec.push_back(make_tuple(d,e,i+1));
    }
    sort(vec.begin(),vec.end(),comp);
    for(int i=0;i<n;i++){
        cout<<get<2>(vec[i])<<"\n";
    }
}



Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <bits/stdc++.h>
using namespace std ;
#define printshosu(a) cout << fixed << setprecision(15) << a << endl;
int main(){
  string N;
  cin >>N;
  bool res = false;
  for(int i = 0;i<N.size();i++){
    if(N.at(i)=='7'){
      res = true;
    }
  }
  if(res){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}




Measured memory_bytes: 3616
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    h = II()
    w = II()
    print((n-h+1)*(n-w+1))
    return

#B
def B():
    n = II()
    a, b = LI()
    p = LI()
    p.sort()
    ans = [0 for i in range(3)]
    for p_ in p:
        if p_ <= a:
            ans[0] += 1
        elif a < p_ <= b:
            ans[1] += 1
        else:
            ans[2] += 1
    print(min(ans))
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if (A * N <= B) {
    cout << A*N << endl;
  }
  else {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pii pair<ll, ll> 
#define pb push_back
#define debug(x) cerr<< #x << " is " <<x<<endl;
#define debug2(x) cerr<<#x<< " is\n"; for (auto &i:x) {cout<<i<<' '; } cout<<endl;
#define f first
#define s second
using namespace std;

double dp[301][301][301];

double n;

double f(int a, int b, int c){	
	if (a==0&&b==0&&c==0) return 0;
	if (dp[a][b][c]) return dp[a][b][c];
	double m = (a+b+c);
	if (a) dp[a][b][c]+=(a/m)*(f(a-1,b+1,c)+1);
	if (b) dp[a][b][c]+=(b/m)*(f(a,b-1,c+1)+1);
	if (c) dp[a][b][c]+=(c/m)*(f(a,b,c-1)+1);
	double tp = ((n-a-b-c)/n);
	dp[a][b][c]+=(tp/(1-tp));
	return dp[a][b][c];
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    vector<int> a(3);
    for (int i=0; i<n; i++){
    	int in; cin>>in;
    	a[in-1]++;
    }
    cout<<fixed<<setprecision(15)<<f(a[2],a[1],a[0])<<endl;

}

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

int main() {
  int N,A,B; cin >> N >> A >> B;
  int sum = 0;
  int ans = 0;
  for ( int i = 1; i <= N; i++ ) {
    sum = 0;
    int x = i;
    for ( int j = 0; j < 5; j++ ) {
      sum += x % 10;
      x /= 10;
    }
    if ( A <= sum && sum <= B ) {
      ans+=i;

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


Measured memory_bytes: 256
s=input()
a=0
find_a=0
z=len(s)-1
find_z=0
while find_a==0 or find_z==0:
    if find_a==0 and s[a]=="A":
        find_a=1
    if find_z==0 and s[z]=="Z":
        find_z=1
    if find_a==0:
        a+=1
    if find_z==0:
        z-=1
print(z-a+1)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, K;
    cin >> N >> K;
    Vl vec(N + 1);
    set<ll> st;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        ++vec[a];
        st.emplace(a);
    }
    sort(vec.begin(), vec.end(), greater<ll>());
    ll nm = (ll)st.size();
    ll ans = 0;
    for (ll i = K; i < nm; i++) {
        ans += vec[i];
    }
    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 14216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))

#define pb push_back
#define mp make_pair
#define ff first
#define ss second


int main()
{
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
}


Measured memory_bytes: 3636
N, K, S = [int(i) for i in input().split()]

a = S

val = a
ans = []
count = 0
dummy = S+1
if S==1000000000:
    dummy = S - 1
for i in range(N):
    if(count >= K):
        val = dummy
        if val > 1000000000:
            val = 1000000000  
    else:
        count += 1
        val = a
        
    ans += [val]
    if count ==K:
            val = dummy
            count += 1

print(*ans)


Measured memory_bytes: 6560
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    double r;
    cin >> r;

    double PI = 3.141592653589;
    double area = r*r*PI;
    double length = 2*PI*r;

    printf("%.6lf %.6lf", area, length);

    return 0;
}


Measured memory_bytes: 3296
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n;
	cin >> n;
	int dp[100020] = {};
	for (int i = 0; i < n; i++) {
		int l, r;
		cin >> l >> r;
		for (int i = l; i <= r; i++) {
			dp[i] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= 100000; i++) {
		if (dp[i] == 1) {
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
const ll mod1 = 998244353;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

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

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

 ll pow(ll a, ll b) {
    a %= mod1;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod1;
        a = a * a % mod1;
        b /= 2;
    }
    return ans;
}

int main(){

 
   ios_base :: sync_with_stdio(0);
   cin.tie(0);
  ll x;
  cin>>x;
  ll c= 0;
//  while(x > 500){
//    x -=500;
//    c+=1000;
//  }

  c = x/500;
  c *= 1000;
  ll t = x - (x/500)*500;
  x = t;
  ll c2 = 0;
  while(x > 5){
    x -=5;
    c2+=5;
  }
  c += c2;
  cout<<c;


}


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

using namespace std;


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

	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 14; j++) {
			if (i * 4 + j * 7 == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
}


Measured memory_bytes: 256
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 8/18/2018, 8:51:00 PM
# Powered by Visual Studio Code
#

a, b = gets.chomp.split(" ").map{|i| i.to_i}
puts (a - 1) * (b - 1)


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

#define INF (1<<20)
typedef pair<int,int> P;
typedef pair<int,P> Pi;

int D,N;
int a[111],e[111],r[111];
int dp[111][111];

int main(){
  while(cin >> D >> N , D){
    fill_n(*dp,111*111,INF);
    for(int i=0;i<N;i++){
      cin >> a[i] >> e[i] >> r[i];
    }
    dp[D][0] = 0;
    for(int i=D;i>0;i--){
      for(int j=0;j<101;j++){
	if(dp[i][j] == INF) continue;
	for(int k=0;k<N;k++){
	  if(j < r[k]) continue;
	  dp[max(0,i-a[k])][min(100,j+e[k])] = min(dp[max(0,i-a[k])][min(100,j+e[k])],dp[i][j]+1);
	}
      }
    }
    int ans = INF;
    for(int i=0;i<101;i++){
      ans = min(ans,dp[0][i]);
    }
    if(ans == INF) cout << "NA" << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 3124
n = int(input())

l9 = [9**(i+1) for i in range(6)]
l6 = [6**(i+1) for i in range(6)]
l9.sort(reverse=True)
l6.sort(reverse=True)
ans = n
for i in range(n):
    n9 = i+1
    n6 = n-n9
    tmp = 0

    while (n9 >= 9):
        for t in l9:
            if t <= n9:
                n9 -= t
                tmp += 1
                break
    n6 += n9
    while (n6 >= 6):
        for t in l6:
            if t <= n6:
                n6 -= t
                tmp += 1
                break
    ans = min(ans, tmp+n6)
print(ans)


Measured memory_bytes: 3064
from itertools import accumulate
mod = 10**9+7
frac = [1]*114514
for i in range(2,114514):
    frac[i] = i * frac[i-1]%mod
fraci = [None]*114514
fraci[-1] = pow(frac[-1], mod -2, mod)
for i in range(-2, -114514-1, -1):
    fraci[i] = fraci[i+1] * (114514 + i + 1) % mod

N = int(input())
A = list(map(int, input().split()))

B = [0] + [pow(i, mod-2, mod) for i in range(1, N+1)]
for i in range(1, N+1):
    B[i] = (B[i-1] + B[i])%mod


ans = 0
for i in range(N):
    ans = (ans +  A[i] *(B[i+1] + B[N-i] - 1))%mod

ans = (ans * frac[N])%mod
print(ans)

Measured memory_bytes: 68504
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

class UnionFindTree{
public:
  int treeCnt; //ツリーの数
  vector<int> rank,p;  //rank => 根の高さ, p => 親
  vector<int> num; //木の要素数
  UnionFindTree(){}
  UnionFindTree(int size){
    rank.resize(size,0);
    p.resize(size,0);
    num.assign(size,1);
    treeCnt = 0;
    REP(i,size){
      makeset(i);
    }
  }

  void makeset(int x){
    p[x] = x;
    rank[x] = 0;
    treeCnt++;
  }

  //同じ木に属しているか判定
  bool same(int x, int y){
    return findSet(x) == findSet(y);
  }

  //xとyが属している木をつなぐ
  void unite(int x, int y){
    link(findSet(x),findSet(y));
  }
  
  ///木と木を繋ぐ処理をする。
  void link(int x, int y){
    if(!same(x,y)){
      if(rank[x] > rank[y]){
	p[y] = x;
	num[x] += num[y];
      }else{
	p[x] = y;
	if(rank[x] == rank[y]){
	  rank[y]++;
	}
	num[y] += num[x];
      }
      treeCnt--;
    }
  }

  //xが属している木の根を探る
  int findSet(int x){
    if(p[x] == x) return x;
    else return p[x] = findSet(p[x]);
  }

  int countTree(){
    return treeCnt;
  }

  int getNum(int a){
    return num[findSet(a)];
  }
};

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int n,m;
  cin >> n >> m;
  vi P(n);
  REP(i,n){
    cin >> P[i];
    P[i]--;
  }
  UnionFindTree utf(n);
  REP(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    utf.unite(x,y);
  }
  int ans = 0;
  REP(i,n){
    if(utf.same(i,P[i])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <string>
#include <algorithm>
#include <limits.h>
#include <iostream>

using namespace std;

int main()
{
	int N, i, j=0, k;
	string s;
	char ans[100000] = { 0 };
	cin >> s;

	for (i = 0; 2*i < s.length(); i++) {
		ans[i] = s[2*i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;

vector<int> choose(int target) {
    vector<int> vec;
    for (int i=0; i<12; i++) {
        if (((1<<i) & target)>0) vec.push_back(i+1);
    }
    return vec;
}

int main() {
    // input, ready
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> cost(N+1);
    vector<vector<int>> books(N+1);
    for (int i=1; i<=N; i++) {
        vector<int> tmp(M);
        books[i] = tmp;
    }
    for (int i=1; i<=N; i++) {
        cin >> cost[i];
        for (int j=0; j<M; j++) {
            cin >> books[i][j];
        }
    }

    // resolve
    ll ans = LINF;
    for (int i=1; i<=((1 << N) -1); i++) {
        vector<int> choose_books = choose(i);
        ll tmp_ans = 0;
        vector<int> skills(M,0);
        for (auto b: choose_books) {
            tmp_ans += cost[b];
            for (int j=0; j<M; j++) {
                skills[j] += books[b][j];
            }
        }
        bool ok=true;
        for (int j=0; j<M; j++) {
            if (skills[j] <X) {
                ok = false;
                break;
            }
        }
        if (ok) ans = min(ans, tmp_ans);
    }

    // output
    if (ans == LINF) cout << -1 << endl;
    else cout << ans << endl;

    // cout << fixed << setprecision(10) << middle << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<queue>
#include<vector>

#define INF 100000000
#define Max_N 5001

typedef std::pair<int,int> pair;

int n,k;
std::vector<std::vector<int> >data_a;
pair data_b[Max_N];
int dijkstra[Max_N][Max_N];
int cost[Max_N];
bool used[Max_N];

void bfs(int i){
	int distance[Max_N];
	for(int j=0;j<=n;j++)distance[j]=0,dijkstra[i][j]=INF;
	distance[i]=0;
	std::queue<int>que;
	que.push(i);
	while(que.size()){
		int j=que.front();que.pop();
		for(unsigned int k=0;k<data_a[j].size();k++){
			int a=data_a[j][k];
			if(distance[a]==0){
				distance[a]=distance[j]+1;
				que.push(a);
			}
		}
	}
	for(int j=1;j<=n;j++){
		if(i!=j&&distance[j]<=data_b[i].second)dijkstra[i][j]=data_b[i].first;
	}
}

void solve(int s){
	cost[s]=0;
	while(true){
		int v=-1;
		for(int i=1;i<=n;i++){
			if(!used[i]&&(v==-1||cost[i]<cost[v]))v=i;
		}
		if(v==-1)break;
		used[v]=true;
		for(int i=1;i<=n;i++){
			cost[i]=std::min(cost[i],cost[v]+dijkstra[v][i]);
		}
	}
}

int main(){
	std::cin>>n>>k;
	for(int i=0;i<=n;i++){
		data_a.push_back(std::vector<int>());
		cost[i]=INF;
		used[i]=false;
	}
	for(int i=1;i<=n;i++){
		int a,b;
		std::cin>>a>>b;
		data_b[i]=pair(a,b);
	}
	for(int i=0;i<k;i++){
		int a,b;
		std::cin>>a>>b;
		data_a[a].push_back(b);
		data_a[b].push_back(a);
	}
	for(int i=1;i<=n;i++)bfs(i);
	solve(1);
	std::cout<<cost[n]<<std::endl;
	return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;

  int x = atoi((a+b).c_str());

  for (int i = 1; i <= x; i++) {
    if (i*i == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;

}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())
cnt = [0 for _ in range(N)]

for i in range(1, N):
    for j in range(i+1, N+1):
        d = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
        cnt[d] += 1

for i in range(1, N):
    print(cnt[i])

Measured memory_bytes: 3444
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>



struct Rail {
	int to, company;
};
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<std::unordered_map<int, std::vector<Rail>>> stations(n);
	for (auto i = 0; i < m; ++i) {
		int a, b, c; std::cin >> a >> b >> c;
		stations[a - 1][c].push_back(Rail{ b - 1, c });
		stations[b - 1][c].push_back(Rail{ a - 1, c });
	}
	std::deque<std::pair<int, int>> deque;
	std::vector<std::unordered_map<int, int>> min_cost(n);
	std::vector<bool> do_change(n, false);
	min_cost[0][0] = 0;
	deque.emplace_back(0, 0);
	while (!deque.empty()) {
		const auto top = deque.front(); deque.pop_front();
		const auto current = min_cost[top.first][top.second];
		if (!do_change[top.first]) {
			do_change[top.first] = true;
			for (const auto& s : stations[top.first]) {
				const auto min = min_cost[top.first].find(s.first);
				if (min == min_cost[top.first].end() || min->second > current + 1) {
					min_cost[top.first][s.first] = current + 1;
					deque.emplace_back(top.first, s.first);
				}
			}
		}
		for (const auto& p : stations[top.first][top.second]) {
			const auto min = min_cost[p.to].find(p.company);
			if (min == min_cost[p.to].end() || min->second > current) {
				min_cost[p.to][p.company] = current;
				deque.emplace_front(p.to, p.company);
			}
		}
	}
	if (min_cost.back().empty()) {
		std::cout << "-1\n";
	}
	else {
		int result{ INT_MAX };
		for (const auto& p : min_cost.back()) {
			result = std::min(result, p.second);
		}
		std::cout << result << '\n';
	}
}

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

int main() {
  int R,C,K;
  cin>>R>>C>>K;
  vector<vector<int64_t>> p(R,vector<int64_t>(C));
  for(int i=0;i<K;i++){
    int a,b;
    int64_t c;
    cin>>a>>b>>c;
    a--,b--;
    p[a][b]=c;
  }
  vector<vector<int64_t>> dp(R,vector<int64_t>(C));
  for(int i=0;i<R;i++){
    vector<int64_t> kdp(4);
    for(int j=0;j<C;j++){
      if(i!=0){
        kdp[0]=max(kdp[0],dp[i-1][j]);
      }
      for(int k=2;k>=0;k--){
        kdp[k+1]=max(kdp[k+1],kdp[k]+p[i][j]);
        dp[i][j]=max(dp[i][j],kdp[k+1]);
      } 
    }
  }
  cout<<dp[R-1][C-1]<<endl;
}

Measured memory_bytes: 144044
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, l;
	cin >> n >> l;

    int ans=n*(l-1)+n*(n+1)/2;
    if(l+n-1<0) ans -= l+n-1;
    else if(l>0) ans -= l;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


int main() {

	int n;
	cin >> n;
	vector<ll> a(n + 1);
	rep(i, n + 1) cin >> a[i];
	vector<ll> b(n);
	rep(i, n) cin >> b[i];

	ll sum = accumulate(allof(a), 0LL);

	// 後ろから貪欲でいい
	for (int i = n - 1; i >= 0; i--) {
		if (b[i] >= a[i + 1]) {
			a[i] = max(0LL, a[i] - (b[i] - a[i + 1]));
			a[i + 1] = 0;
		}
		else {
			a[i + 1] -= b[i];
		}
	}

	ll left = accumulate(allof(a), 0LL);

	cout << sum - left << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
cin>>A>>B>>C>>D;
for(int i=0; i<100; i++){
C=C-B;
if(C>0){
A=A-D;
if(A<=0){
cout<<"No"<<endl;
break;
}
}
else{
cout<<"Yes"<<endl;
break;
}
}
}





Measured memory_bytes: 3588
import sys


def visit(current, v, dist, color):
    for ele in v[current]:
        if color[ele] != -1:
            continue
        if dist[(ele, current)] % 2 == 0:
            color[ele] = color[current]
        else:
            if color[current] == 0:
                color[ele] = 1
            else:
                color[ele] = 0
        visit(ele, v, dist, color)

def main():
    sys.setrecursionlimit(100100)
    num = int(input())

    v = [[] for i in range(num + 1)]

    dist = {}

    for i in range(1, num):
        a, b, d = map(int, input().split())
        v[a].append(b)
        v[b].append(a)
        dist[(a, b)] = d
        dist[(b, a)] = d

    color = [-1 for i in range(num + 1)]
    color[1] = 0
    visit(1, v, dist, color)

    for i in range(1, num + 1):
        print(color[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 165536
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int Nums[]=new int[A];
    int sum=0;
    for(int i=0;i<A;i++){
    	Nums[i]=sc.nextInt();
    }
    for(int i=0;i<A;i++){
      for(int j=0;j<A;j++){
        if(j>i){
        	sum+=Nums[j]*Nums[i];
        }
      }
    }
    System.out.print(sum);
  }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

long long min(long long a,long long b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  long N;
  long long sum = 0,x = 0;
  long long ans = 10000000000000000;
  scanf("%ld",&N);

  long long a[N];

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

  for(int i = 0;i < N-1;i++){
    x += a[i];
    ans = min(ans,llabs(sum-2*x));
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

const int AMAX = 100000;
long long cnt[AMAX + 1];

int main() {
	
	int n, i, a, b, ans;
	long long  k;

	cin >> n >> k;

	for (i = 0; i < n; i++) {
		cin >> a >> b;
		cnt[a] += b;
	}

	for (ans = 1; ans <= AMAX; ans++) {
		if (k <= cnt[ans]) {
			cout << ans;
			break;
		}
		k -= cnt[ans];
	}
	return 0;
}

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

int main()
{
  string s; cin >> s;
  int ans = 0;
  for (auto c:s) if (c=='1') ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

int main(){
	int k;
	cin>>k;
	
	if(k%2==0 or k%5==0){
		cout<<-1<<endl;
		return 0;
	}
	
	int ans=0;
	llong tmp=0;
	while(1){
		ans++;
		tmp=10*tmp+7;
		tmp%=k;
		if(tmp==0) break;
	}
	
	cout<<ans<<endl;
}

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

#define Debug(x) x
typedef int regular_int;
#define int ll
typedef long long ll;

regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	string S;
	ll K;

	cin >> S;
	cin >> K;

	if (S.size() == 1){
        cout << K / 2 << endl;
        return 0;
	}

	ll res = 0 ;
	int x = 1, y = 1;
	while(x < S.size() - y && S[x - 1] == S[x]) {
		++x;
	}
	while(y < S.size() - x && S[S.size() - y] == S[S.size() - y - 1]) {
		++y;
	}

	if(S[0] == S[S.size() - 1] && x + y == S.size()) {
		cout << ((((ll )S.size()) * K) / 2) << endl;
		return 0;
	}
	int pos = x;
	while(pos < S.size() - y) {
		int cnt = 1;
		while(S[pos + 1] == S[pos]) {
			++cnt;
			++pos;
		}
		res += (cnt / 2) * K;
		++pos;
	}
	if(S[0] == S[S.size() - 1])
		res += (x / 2) + (y / 2) + ((x + y) / 2) * (K - 1);
	else {
		res += (x / 2) * K + (y / 2) * K;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int s,t,i,j,count=0;
  int n[100000];
  int q[500];

  scanf("%d",&s);
  for(i=0;i<s;i++)
    scanf("%d",&n[i]);
  
  scanf("%d",&t);
  for(i=0;i<t;i++)
    scanf("%d",&q[i]);

  for(i=0;i<t;i++)
    for(j=0;j<s;j++)
      if(q[i] == n[j])
	{
	  count++;
	  break;
	}
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>

int main(){

	int k=0,a=0,b=0,count=0,i;

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

	for(i=a;i<=b;i++){
		if(i%k==0){
			printf("OK");
			count+=1;
			break;
		}
	}

	if(count==0)
		printf("NG");
	return 0;
}



	



Measured memory_bytes: 1728
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;




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

	int count = 0;
	int t = 0;

	for (int i = 1; i <= N; ++i)
	{
		int a; cin >> a;

		if (a == i)
		{
			++t;

			if (t % 2 != 0)
			{
				count++;
			}
		}
		else
		{
			t = 0;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int n, m;
    int **a;
    int *b;
    int *c;

    cin >> n >> m;

    a = new int*[n];
    for (int i=0; i<n; i++)
        a[i] = new int[m];
    b = new int[m];
    c = new int[n];

    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)
            cin >> a[i][j];
    for (int j=0; j<m; j++)
        cin >> b[j];

    for (int i=0; i<n; i++)
    {
         for (int j=0; j<m; j++)
        {
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << endl;
    }

    delete[] a;
    delete b;
    delete c;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a, b, c, d;

int main() {
	cin >> n >> a >> b >> c >> d;
	
	b -= a;
	LL B = b * 2;
	LL M = c + d;
	LL D = d - c;
	
	bool ans = false;
	incII(i, -(n - 1), n - 1) {
		if(n % 2 != (i + 10000000) % 2) { ans |= inII(B, M * i - D * (n - 1), M * i + D * (n - 1)); }
	}
	
	cout << (ans ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 305
#define P 998244353
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, m, siz, a[MAXN][MAXN], bas[MAXN][MAXN], temp[MAXN], vis[MAXN];

int ksm(int x, int y)
{
    int ans=1;
    while(y)
    {
        if(y&1) ans=1LL*ans*x%P;
        x=1LL*x*x%P; y>>=1;
    }
    return ans;
}

void insert(int a[])
{
    memcpy(temp, a, sizeof(temp));
    for(rint i=1; i<=m; ++i)
        if(temp[i])
        {
            if(!vis[i])
            {
                for(rint j=1; j<=m; ++j) bas[i][j]=temp[j];
                vis[i]=1;
                siz++;
                break;
            }
            for(rint j=1; j<=m; ++j) temp[j]^=bas[i][j];
        }
}

int main()
{
    scanf("%d%d", &n, &m);
    for(rint i=1; i<=n; ++i)
        for(rint j=1; j<=m; ++j) scanf("%d", &a[i][j]);
    for(rint i=1; i<=n; ++i) insert(a[i]);
    printf("%d\n", 1LL*(ksm(2, n)-ksm(2, n-siz)+P)*ksm(2, m-1)%P);
}

Measured memory_bytes: 896
x, y = map(int, input().split())


def group(v):
    if v in [1, 3, 5, 7, 8, 10, 12]:
        return 1
    elif v == 2:
        return 2
    else:
        return 3


if group(x) == group(y):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,k;cin>>n>>k;
  if(k==1){
    cout<<0<<endl;
    return 0;
  }
  cout<<abs(n-k)<<endl;
}

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

def bubbleSort(a, n):
  flag = 1
  count = 0
  while flag:
    flag = 0
    for j in reversed(range(1,n)):
      if a[j] < a[j-1]:
        temp = a[j]
        a[j] = a[j-1]
        a[j-1] = temp
        flag = 1
        count += 1
  return count

count = bubbleSort(a,n)
print(*a)
print(count)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> order(N);
  for(int i = 0; i < N; i++){
  cin >> order.at(i);
  }
  vector<int> dish(N);
  for(int j = 0; j < N; j++){
  cin >> dish.at(j);
  }
  vector<int> more(N-1);
  for(int k = 0; k < N-1; k++){
  cin >> more.at(k);
  }
  
  int count = 0;
  count = count + dish.at(order.at(0) - 1);
    for(int m = 1; m<N; m++){
      count = count + dish.at(order.at(m) - 1);
      if(order.at(m) == order.at(m - 1) + 1){
      count = count + more.at(order.at(m - 1) - 1);
      }
  }
  
  cout << count << endl;
 }

Measured memory_bytes: 256