akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-1, 0, 1, 1};
int dx[4] = {0, 1, 0, 1};

int n, m, p, q;
int adj[300][300];

void precal() {
	rep(i,0,n) adj[i][i] = 0;

	rep(k,0,n) rep(i,0,n) rep(j,0,n) {
		adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
	}

	rep(i,0,n) rep(j,0,n) {
		adj[i][j] = (adj[i][j] <= p ? 1 : INF); 
	}

	rep(k,0,n) rep(i,0,n) rep(j,0,n) {
		adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
	}
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("in.txt", "r", stdin);
	cin >> n >> m >> p;
	rep(i,0,300) rep(j,0,300) {
		adj[i][j] = INF;
	}
	rep(i,0,m) {
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		adj[a][b] = c;
		adj[b][a] = c;
	}

	precal();

	cin >> q;
	rep(i,0,q) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		if(adj[s][t] == INF) {
			cout << -1 << '\n';
		} else {
			cout << adj[s][t]-1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
#define int long long
 
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999
 
using namespace std;

int gcd(int x, int y){
    if(x<y){
        swap(x, y);
    }

    int r=x%y;
    if(!r) return y;

    return gcd(y, r);
}

int32_t main(){
    int n, k;
    cin >> n >> k;
    int v[n], maxi=-1;
    REP(i, n){
        cin >> v[i];
        maxi=max(maxi, v[i]);
    }

    int g=v[0];
    FOR(i, 1, n){
        g=gcd(g, v[i]);
    }

    if(k<=maxi && k%g==0){
        cout << "POSSIBLE" << endl;
        return 0;
    }

    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
D - Lazy Faith
https://atcoder.jp/contests/abc119/tasks/abc119_d

"""
import sys
from bisect import bisect_left, bisect_right

def solve(shrines, temples, x):
    i = bisect_right(shrines, x)
    ds = x - shrines[i-1]
    j = bisect_right(temples, x)
    dt = x - temples[j-1]
    ans = max(ds, dt)

    i = bisect_left(shrines, x)
    ds = shrines[i] - x
    j = bisect_left(temples, x)
    dt = temples[j] - x
    ans = min(ans, max(ds, dt))

    i = bisect_left(shrines, x)
    ds = shrines[i] - x
    j = bisect_right(temples, x)
    dt = x - temples[j-1]
    d = min(ds, dt) * 2 + max(ds, dt)
    ans = min(ans, d)

    i = bisect_right(shrines, x)
    ds = x - shrines[i-1]
    j = bisect_left(temples, x)
    dt = temples[j] - x
    d = min(ds, dt) * 2 + max(ds, dt)
    ans = min(ans, d)

    return ans


def main(args):
    A, B, Q = map(int, input().split())
    shrines = sorted([int(input()) for _ in range(A)] + [float('-inf'), float('inf')])
    temples = sorted([int(input()) for _ in range(B)] + [float('-inf'), float('inf')])
    for _ in range(Q):
        x = int(input())
        ans = solve(shrines, temples, x)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 13424
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

vector<int> prime_vector(int n) {
    int m = (int)sqrt(n - 1);

    vector<bool> q(n);
    for (int i = 2; i <= m; i++) {
        if (q[i]) continue;
        for (int j = i * i; j < n; j += i) {
            q[j] = true;
        }
    }

    vector<int> p; p.reserve(n / log(n * 0.329));
    for (int i = 2; i < n; i++) {
        if (!q[i]) p.push_back(i);
    }
    return p;
}

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

    auto pv = prime_vector(55555);
    int m = pv.size();

    int k = 0;
    for (int i = 0; i < m; i++) {
        if (pv[i] % 5 == 1) {
            cout << pv[i] << " \n"[k == n - 1];
            k++;
            if (k == n) break;
        }
    }

    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

vector<ll> prime_factor(ll n){
	ll sn = sqrt(n)+1;
	auto prime_list = enum_prime(sn);
	vector<ll> res;
	for(int i=0,ei=prime_list.size();i<ei;i++){
		ll v = prime_list[i];
		if(v*v>n) break;
		while(!(n%v)){
			n /= v;
			res.push_back(v);
		}
	}
	if(n>1){
		res.push_back(n);
	}

	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in();
	map<int,int> M;
	for(int i=2;i<=N;i++){
		auto P = prime_factor(i);
		for(auto& x:P) M[x]++;
	}

	ll A=1;
	for(auto& x:M){
		A *= x.second+1LL;
		A %= atcoder_mod;
	}

	out(A);
	return 0;
}


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

using namespace std;

using ll = long long;

int main() {
	int n, W;
	scanf("%d %d", &n, &W);
	vector<ll> dp(W + 1, 0);
	for (int k = 0; k < n; k++) {
		int w, val;
		scanf("%d%d", &w, &val);
		for (int x = W - w; x >= 0; x--) {
			dp[x + w] = max(dp[x + w], dp[x] + val);
		}
	}
	ll res = 0;
	for (int i = 0; i <= W; i++) {
		res = max(res, dp[i]);
	}
	printf("%lld\n", res);
}


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

int main(){

    int D, N;
    cin >> D >> N;

    int S = pow(100,D);

    if( N <= 99 ) cout << (int) pow(100,D) * N << endl;
	else cout << (int) pow(100,D) * 101 << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    ll X; cin >> X;
    ll A, B;
    int flag = 0;
    for (A = -150; A < 150; A++) {
        for (B = -150; B < 150; B++) {
            if (pow(A, 5) - pow(B, 5) == X) { 
                flag = 1;
                break;
            }
        }
        if (flag) break;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 4028
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

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

int main() {
    ll x;
    cin >> x;
    ll money = 100;
    ll ans = 0;

    while(x > money) {
        money *= 1.01;
        ans += 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
n,t = map(int,input().split())

c = [list(map(int,input().split())) for i in range(n)] 

mincost = 10000
for i in range(n):
  if c[i][1] <= t:
    cost = c[i][0]
    mincost=min(cost,mincost)

if mincost ==10000:
  print("TLE")
else:
  print(mincost)

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

int n;
ll t[ (1<<18) ];

int main(){
  scanf("%d",&n);
  for(int i=0;i<(1<<n);i++)scanf("%lld",&t[i]);
  
  for(int len=(1<<n);len>1;len/=2){
    for(int i=0;i<len;i+=2){
      if(t[i]==t[i+1]){
        t[i/2]=t[i];
      }else{
        t[i/2]=abs(t[i]-t[i+1]);
      }
    }
  }
  
  printf("%lld\n",t[0]);
  return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> K;
	int R, S, P;
	cin >> R >> S >> P;
	string T;
	cin >> T;
	vector< vector< int > > dp(N + 1, vector< int >(3, 0));
	vector< int > table(3);
	table[0] = R;
	table[1] = S;
	table[2] = P;
	vector< char > table2(3);
	table2[0] = 'r';
	table2[1] = 's';
	table2[2] = 'p';
	rep(i, N) rep(j, 3) {
		if (i >= K)
			rep(k, 3) if (k != j) chmax(dp[i + 1][j], dp[i + 1 - K][k]);
		if (T[i] == table2[(j + 1) % 3])
			dp[i + 1][j] += table[j];
	}
	vector< int > ans2(K, 0);
	rep(j, 3) rep(i, K) chmax(ans2[i], dp[N - i][j]);
	int ans = 0;
	rep(i, K) ans += ans2[i];
	cout << ans << endl;
	//cout << dp;
	return 0;
}

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

int main(){
  ll n;
  cin>>n;
  ll a,b,ma=0,mb;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    ma=max(ma,a);
    if(ma==a){
      mb=b;
    }
  }
  while(mb>0){
    mb--;
    ma++;
  }
  cout<<ma<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <limits.h>
#include <math.h>

#include <iostream>
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
long long ll;

const int N = 1000000;
bool prime[N];
int cnt[N];

bool isPrime(int n) {
	int i;
	for (i=2; i<n; i++)
		if (n%i == 0) return false;
	return n != 1;
}

void setPrime(int n) {
	int i, j;
	prime[0] = prime[1] = false;
	for (i=2; i<=n; i++) prime[i] = true;

	for (i=2; i<=n; i++) {
//		if (isPrime(i)) prime[i] = true;
		if (prime[i])
			for (j=i*2; j<=n; j+=i) prime[j] = false;
	}
}

int main() {
	int i, j;
	int n;

	setPrime(N);

	for (i=2; i<N; i++) {
		cnt[i] = cnt[i-1];
		if (prime[i]) cnt[i]++;
	}

	while (scanf("%d ", &n) != EOF) {
		printf("%d\n", cnt[n]);
	}

	return 0;
}

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

int main() {
  int N, A;
  cin >> N;
  vector<int> ans(N,0);
  
  for (int i=1; i<N; i++) {
    cin >>A;
    ans.at(A-1)++;
  }
  
  for (int i=0; i<N; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 4048
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007
#define INF (1e9)
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    string s;
    cin >> s;
    ll count = 0;
    rep(i, 3) if (s[i] == 'o') count++;
    print(700 + count * 100);
    return 0;
}


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

using namespace std;

const int maxx = 1e5 + 20;

int x = 0, a[maxx], n;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	a[n] = 0;
	while (x < a[x])	x++;
	x--;
	int g = a[x] - x, y = x;
	while (x < a[y])	y++;
	y -= x;
//	cout << g << " " << y << " " << y - x << endl;
	if (g % 2 && y % 2) cout << "Second" << endl;
	else	cout << "First" << endl;
//	cout << x << endl;
//	cout << (((a[0] + n) % 2) ? "First" : "Second") << endl;
	return 0;
}

Measured memory_bytes: 640
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [usize; N],
    }
    let mut ans = 1;
    let modulo = 1_000_000_007;
    let mut A = A;
    A.sort();
    if N%2==0{
        for i in 0..N/2{
            if A[i*2] == i*2+1 && A[i*2+1] == i*2+1{
                ans *= 2;
                ans %= modulo;
            }else{
                ans = 0;
                break;
            }
        }
    }else{
        for i in 0..(N-1)/2{
            if A[i*2+1] == (i+1)*2 && A[i*2+2] == (i+1)*2{
                ans *= 2;
                ans %= modulo;
            }else{
                ans = 0;
                break;
            }
        }
        if A[0]!=0{
            ans = 0;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
<?php
    
    list($A,$B,$C,$K) = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    if($K<=$A+$B){
        echo min($A,$K)."\n";
    }else{
        $minus  = $K - ($A+$B);
        
        echo $A-$minus."\n";
    }

?>

Measured memory_bytes: 16168
#include <iostream>

int main() {
  const int ARRAY_SIZE = 100;
  int a[ARRAY_SIZE];
  int n;
  int count = 0;

  std::cin >> n;
  for (int i = 0;i < n;i++) {
    std::cin >> a[i];
  }

  for (int i = 0;i < n;i++) {
    int min_index = i;
    for (int j = i + 1;j < n;j++) {
      if (a[j] < a[min_index]) {
        min_index = j;
      }
    }
    if (a[min_index] < a[i]) {
      int tmp = a[i];
      a[i] = a[min_index];
      a[min_index] = tmp;
      count++;
    }
  }

  for (int i = 0;i < n;i++) {
    int min_index = i;
    for (int j = i + 1;j < n;j++) {
      if (a[j] < a[min_index]) {
        min_index = j;
      }
    }
    if (a[min_index] < a[i]) {
      int tmp = a[i];
      a[i] = a[min_index];
      a[min_index] = tmp;
      count++;
    }
  }

  for (int i = 0; i < n;i++) {
    if (i == n - 1) {
      std::cout << a[i] << std::endl;
    } else {
      std::cout << a[i] << " ";
    }
  }
  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 3104
#coding:utf-8
def kisuu(a):
    b = []
    for i in range(a):
        if i%2==0:
            b.append("#")
        else:
            b.append(".")
    return(b)

def gusuu(a):
    b = []
    for i in range(a):
        if i%2==0:
            b.append(".")
        else:
            b.append("#")
    return(b)
h = 1
w = 1

while h+w != 0:
    h, w=input().rstrip().split(" ")
    h = int(h)
    w = int(w)
    if h == 0:
        if w==0:
            break

    ki = "".join(kisuu(w))
    gu = "".join(gusuu(w))

    for i in range(h):
        #?\???°
        if i%2 ==0:
            print(ki)
        else:
            print(gu)

    print("")

Measured memory_bytes: 7724
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    rep(i,0,n-1) cin>>h[i];
    sort(h.begin(),h.end());
    ll min = 100000000000000000;
    rep(i,0,n-k){
        ll d = h[i+k-1] - h[i];
        if(min>d) min = d;
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#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 IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  string S;
  cin >> S;
  map<char, int> m;
  for(char c: S){
    m[c] += 1;
  }
  if(m.size() == 2 && m.begin()->second == 2 && (++m.begin())->second == 2 ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    char x, y;
    cin >> x >> y;
    char ans = x < y ? '<' : x != y ? '>' : '=';
    cout << ans << endl;
    return 0;
}

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

int main(void){
	int a, b, c;
	cin >>a >> b >> c;
	int five=0,seven=0;
	if(a==5) five++;else if(a==7) seven++;
	if(b==5) five++;else if(b==7) seven++;
	if(c==5) five++;else if(c==7) seven++;
	if(five==2 && seven==1) cout << "YES" <<endl;
	else cout << "NO" << endl;
	return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
#define iinf 0x3f3f3f3f3f3f3f3fll
using namespace std;
int n,k,x,sum;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>k;
	for(reg int i=1;i<=n;i++)
	{
		cin>>x;
		if(x>=k)sum++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
def func(n):
    p = 0
    while True:
        if 4*p > n:
            return 'No'
        q = 0
        while True:
            s = 4*p + 7*q
            if s > n:
                break
            elif s == n:
                return 'Yes'
            q += 1
        p += 1

print(func(n))

Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int t = int.Parse(Console.ReadLine());
        long[] a = new long[t];
        long[] b = new long[t];
        long[] c = new long[t];
        long[] d = new long[t];
        for (int i = 0; i < t; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            a[i] = long.Parse(input[0]);
            b[i] = long.Parse(input[1]);
            c[i] = long.Parse(input[2]);
            d[i] = long.Parse(input[3]);
        }

        for (int i = 0; i < t; i++)
        {
            if(a[i] < b[i])
            {
                Console.WriteLine("No");
                continue;
            }
            if (b[i] > d[i])
            {
                Console.WriteLine("No");
                continue;
            }
            long gcd = Gcd(b[i], d[i]);
            long tmp = a[i] % b[i];
            if (gcd + c[i] >= b[i] && tmp <= c[i])
            {
                Console.WriteLine("Yes");
                continue;
            }
            else
            {
                Console.WriteLine("No");
                continue;
            }
        }
    }
    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readH(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readH(String str) {
		if (N == 1) {
			System.out.println(0);
			return;
		}

		String[] strArr = str.split("\\s+");
		H = new int[N];
		for (int i = 0; i < N; i++)
			H[i] = Integer.parseInt(strArr[i]);

		int cnt = 0;
		int max = 0;
		for (int i = N - 2; i >= 0; i--) {
			if (H[i] >= H[i + 1]) {
				cnt++;
				if (cnt > max)
					max = cnt;

			} else {
				cnt = 0;
			}
		}
		System.out.println(max);
	}

	int[] H;

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 44556
n = input()

d = [-1 for i in xrange(n + 1)]
Q = []

color = ['WHITE' for i in xrange(n + 1)]

graph_map = [[0 for j in xrange(n + 1)] for i in xrange(n + 1)]

for i in xrange(1, n + 1):
    tmp = map(int, raw_input().split())
    for j in xrange(tmp[1]):
        graph_map[i][tmp[j + 2]] = 1

color[1] = 'GRAY'
d[1] = 0
Q.append(1)

while len(Q) != 0:
    u = Q.pop(0)
    for v in xrange(1, n + 1):
        if graph_map[u][v] == 1 and color[v] == 'WHITE':
            color[v] = 'GRAY'
            d[v] = d[u] + 1
            Q.append(v)
    color[u] = 'BLACK'

for i in xrange(1, n + 1):
    print "%d %d" % (i, d[i])

Measured memory_bytes: 6416
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define F first
#define S second
using namespace std;

typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<ld> vld;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;

int main()
{
    ll t, i, j, k, ans, n, m, sum = 0, x;

    //cin>>t;
    t = 1;
    while (t--)
    {
        string s1,s2;
        cin>>s1>>s2;
        if(s1<s2)rep(p,0,(s2[0]-'0'))cout<<s1;
        else rep(p,0,(s1[0]-'0'))cout<<s2;
    }

    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;

    ll x;

    if(b-1 <= n) x = b-1;
    else         x = n;

    cout << floor(a*x/b) - a*floor(x/b) << endl;

    return 0;
}

Measured memory_bytes: 3260
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      var n = readLine.split(" ").map(_.toInt)
      while( n(0) != 0 || n(1) != 0) {
        println("#"*n(1))

        (2 to n(0)-1).foreach(s=> { print("#");print("."*(n(1)-2));print("#\n") })

        if(n(0)>1) {
          println("#"*n(1))
        }
        println("")
        n = readLine.split(" ").map(_.toInt)
      }
  }
}

Measured memory_bytes: 44528
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int a; cin >> a;
  long ans=1,x;
  for(long i=1;i<a+1;i++) {x=i%1000000007; ans=ans*x%1000000007;}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int k;cin >> k;
	int now = 0;
	rep(i,11000000){
		now = now*10 + 7;
		now %= k;
		if(now == 0){
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3620
import sys
h,w = map(int,input().split())
ls = ["0"*(w+2)]
ls += ["0" + str(input()) + "0" for _ in range(h)]
ls += ["0"*(w+2)]
di = [["0"]*w for _ in range(h)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if ls[i][j] == ".":
            new = ls[i-1][j-1:j+2] + ls[i][j-1] + ls[i][j+1] + ls[i+1][j-1:j+2]
            k = new.count("#")
            k = str(k)
            di[i-1][j-1] = k
        else:
            di[i-1][j-1] = "#"
for p in range(h):
    print("".join(di[p]))

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

int main(void){
  int n;
  vector<int> a(100);

  cin >> n;
  for(int i = 0; i < n; i ++)
    cin >> a.at(i);

  cout << *max_element(a.begin(), a.begin()+n) - *min_element(a.begin(), a.begin()+n) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string.h>
#include <map>
using namespace std;
long long fpmax(long long a,long long b,long long c){
	if(a<=b&&b<=c)return c-a;
	if(a<=c&&c<=b)return b-a;
	if(b<=c&&c<=a)return a-b;
	if(b<=a&&a<=c)return c-b;
	if(c<=b&&b<=a)return a-c;
	return b-c;
}
int main(){
	long long H,W;
	long long a[2],b[2],c[2],d[2];
	cin>>H>>W;
	d[0]=W/3;
	if(W%3==2)d[0]++;
	d[1]=H/3;
	if(H%3==2)d[1]++;
	a[0]=d[0]*H;
	b[0]=max((W-d[0])*(H/2),(W-d[0])/2*H);
	c[0]=H*W-a[0]-b[0];
	a[1]=d[1]*W;
	b[1]=max((H-d[1])*(W/2),(H-d[1])/2*W);
	c[1]=H*W-a[1]-b[1];
	//cout<<a[1]<<" "<<b[1]<<" "<<c[1]<<endl;
	cout<<min(fpmax(a[0],b[0],c[0]),fpmax(a[1],b[1],c[1]))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

short imos[3010][3010];
short a[3010][3010];

int dfs(int x,int y){
	if(a[x][y])return 0;
	a[x][y]=1;
	rep(i,4)dfs(x+dre_4[i][0],y+dre_4[i][1]);
	return 1;
}

int main(){
	while(1){
		int w,h,n;
		int x1[1010],y1[1010],x2[1010],y2[1010];
		scanf("%d%d",&w,&h); if(w==0&&h==0)break;
		scanf("%d",&n);
		rep(i,n)scanf("%d%d%d%d",&x1[i],&y1[i],&x2[i],&y2[i]);
		
		vector<int> R,C;
		R.pb(0); R.pb(w);
		C.pb(0); C.pb(h);
		rep(i,n){
			R.pb(x1[i]); R.pb(x2[i]);
			C.pb(y1[i]); C.pb(y2[i]);
		}
		sor(R); uniq(R);
		sor(C); uniq(C);
		
		w=lb(R,w)-R.begin(); h=lb(C,h)-C.begin();
		rep(i,n){
			x1[i]=lb(R,x1[i])-R.begin();
			y1[i]=lb(C,y1[i])-C.begin();
			x2[i]=lb(R,x2[i])-R.begin();
			y2[i]=lb(C,y2[i])-C.begin();
		}
		
		rep(i,3010)rep(j,3010)imos[i][j]=0;
		rep(i,3010)rep(j,3010)a[i][j]=1;
		
		rep(i,n){
			imos[x1[i]][y1[i]]++;
			imos[x1[i]][y2[i]]--;
			imos[x2[i]][y1[i]]--;
			imos[x2[i]][y2[i]]++;
		}
		
		rep(i,3010)rep1(j,3009)imos[i][j]+=imos[i][j-1];
		rep1(i,3009)rep(j,3010)imos[i][j]+=imos[i-1][j];
		
		rep1(i,R.size()-1)rep1(j,C.size()-1)a[i][j]=imos[i-1][j-1];
		
		/*rep(i,20){
			rep(j,10){
				printf("%d",a[i][j]);
			}
			puts("");
		}*/
		
		int cnt=0;
		rep(i,3010)rep(j,3010)cnt+=dfs(i,j);
		
		printf("%d\n",cnt);
	}
}

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

signed main() {
  string O, E; cin >> O >> E;
  for(int i = 0; i < O.length(); i++) {
    cout << O[i];
    if(i < E.length()) cout << E[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N;
	cin >> N;
	int count = 0;
	while (N != 0) {
		int a;
		a = N % 10;
		if (a == 2)count++;
		N /= 10;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
K = int(input())

N_ = str(N)
n = len(N_)

dp = [[[0]*2 for i in range(5)] for j in range(110)]

dp[0][0][0] = 1
dp[0][0][1] = 0

for i in range(n):
  for j in range(4):
    for k in range(2):
      nd = int(N_[i])
      for d in range(10):
        ni = i+1
        nj = j
        nk = k
        if d != 0:
          nj += 1
        if nj >3:
          continue
        if k == 0:
          if d > nd:
            continue
          elif d < nd:
            nk = 1
          else:
            pass
        dp[ni][nj][nk] += dp[i][j][k]
        
print(sum(dp[n][K]))

Measured memory_bytes: 41200
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll h[100010];
ll A, B, N;

bool check(ll x) {
	ll t = x;
	for(int i = 0; i < N; i++) {
		ll rem = h[i] - B * x;
		if(rem <= 0) continue;
		t -= (rem + (A - B - 1)) / (A - B);
	}
	return t >= 0;
}


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

	cin >> N >> A >> B;
	for(int i = 0; i < N; i++) {
		cin >> h[i];
	}

	check(2);

	ll ng = 0, ok = 1e9 + 10;
	while(abs(ng - ok) > 1) {
		ll mid = (ng + ok) / 2;
		if(check(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <sstream>
#include <functional>
#include <algorithm>
using namespace std;

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const int MOD=1e8;
const int N=2e5+5;
const ll maxn=5e4;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    IO;
    ll x,y;
    while(cin>>x>>y)
    {
        if(x%y==0) cout<<-1<<endl;
        else cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = input()
    if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
        print("hon")
    elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
        print("pon")
    else:
        print("bon")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9124
n = gets.to_i

n.times do
  out = 0
  score = 0
  runner = [false,false,false]

  until out == 3
    case gets.chomp
    when 'HIT'
      if runner[2]
        score += 1
      end
      runner[2] = runner[1]
      runner[1] = runner[0]
      runner[0] = true
    when 'OUT'
      out += 1
    when 'HOMERUN'
      score += runner.select{|x|x}.count + 1
      runner = [false,false,false]
    end
  end

  puts score
end

Measured memory_bytes: 6100
#include<stdio.h>

#define LEN 100000

int binarySearch(int A[], int n, int key)
{
	int mid,left = 0, right = n;
	while (right > left)
	{
		mid = (right + left) / 2;
		if (A[mid] == key) return 1;
		else if (A[mid] > key)
			right = mid;
		else
			left = mid + 1;
	}
	return 0;
}
int main()
{
	int n, p,sum=0;
	int A[LEN],key;

	scanf("%d",&n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &A[0]+i);
	}
	scanf("%d", &p);
	for (int i = 0; i < p; i++)
	{
		scanf("%d", &key);
		if (binarySearch(A, n, key))
			sum++;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>
int n,A[200];
int Ren(int x,int y);

int main(){
    int q,m,i;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&m);
        if(Ren(0,m))
        printf("yes\n");
        else printf("no\n");
    }
return 0;
}


int Ren(int x,int y){
if(y==0) return 1;
if(x>=n) return 0;
int res=Ren(x+1,y)||Ren(x+1,y-A[x]);
return res;
}


Measured memory_bytes: 2144
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    double s[1000], a = 0, m = 0;
    for (int i=0;i<n;i++) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    for (int i=0;i<n;i++)
      a += pow(s[i] - m, 2);
    a /= n;
    a = pow(a, 0.5);
    cout << fixed << setprecision(10) << a << endl;
  }
}



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

using namespace std;

int main() {

    int a,b,c;
    cin>>a>>b>>c;
    int n=a*100+b*10+c;
    if(n%4==0)
        cout<<"YES";
    else
        cout<<"NO";
    cout<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, M;
vector<int> g[10];

int dfs(int u, bool used[], int cnt)
{
  if(used[u]) return 0;
  if(cnt == N-1) return 1;
  used[u] = true;
  int ret = 0;
  for(int v : g[u]) {
    ret += dfs(v, used, cnt+1);
  }
  used[u] = false;
  return ret;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;

  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool used[N] = {};
  cout << dfs(0, used, 0) << endl;

  return 0;
}


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

int main(){
  int K ; 
  cin >> K ; 
  int64_t T = 7 ; 
  int64_t   i = 1 ; 
  int cnt = 1 ;

  while( cnt   < 10000000 ){
   // cout << i  ; 
    

    if(T%K == 0){
     // cout << endl ; 
      cout << cnt  << endl ; 
      return 0 ; 
    }
    else if(T > K ){
      T = T%K ; 
    }    
    
    
    i = i * 10 ;     
    cnt++ ; 
    T = T*10 + 7 ; 
   // cout << " "<< T << endl ; 

  }

  
  
  cout << "-1" << endl ; 
  
}

Measured memory_bytes: 3596
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
cnt = 0
for i in range(N - 1):
    if x >= a[i]:
        x -= a[i]
        cnt += 1
    else:
        break
if x == a[-1]:
    cnt += 1

print(cnt)

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

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

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long A;
    std::cin >> A;
    long long B;
    std::cin >> B;

    if (A == 1) A = 15;
    if (B == 1) B = 15;
    if (A > B)
        cout << "Alice" << endl;
    else if (A < B)
        cout << "Bob" << endl;
    else
        cout << "Draw" << endl;

    return 0;
}


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

using namespace std;

int main()
{
	int A, B, K;
	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			//高橋君
			if (A % 2 == 1) {
				A -= 1;

			}
			A = A / 2;
			B += A;
		}
		else {
			//青木君
			if (B % 2 == 1) {
				B -= 1;

			}
			B = B / 2;
			A += B;
		}
	}
	cout << A << " " << B << endl;
	
}

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

int main(){
    using namespace std;
    unsigned long L, R;
    cin >> L >> R;
    if(L / 2019 != R / 2019)return 0 & puts("0");
    L %= 2019;
    R %= 2019;
    unsigned long ans{2018};
    for(unsigned long j = L + 1; j <= R; ++j)for(unsigned long i = L; i < j; ++i)ans = min(ans, i * j % 2019);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,n,i,j,k,s=0;
	cin>>a>>b>>c>>n;
	for(i=0;i<=a;i++)
	{
		if(500*i>n) a=i;
		for(j=0;j<=b;j++)
		{
			if(100*j>n) b=j;
			for(k=0;k<=c;k++)
			{
				if(500*i+100*j+50*k==n) s++;
			}
		}
	}
	cout<<s;
	return 0;
 } 

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

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

    long L, R;

    cin >> L >> R;

    if ((R - L >= 2019) || ((R % 2019) < (L % 2019))) {
        cout << 0 << "\n";
    } else {
        int ans_max = 2019;
        int L_remain = L % 2019;
        int R_remain = R % 2019;
        for (int l = L_remain; l < R_remain; l++) {
            for (int r = R_remain; r > l; r--) {
                int rem = (l * r) % 2019;
                if (rem < ans_max) {
                    ans_max = rem;
                }
            }
        }

        cout << ans_max << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a[100010];
    cin >> n;
    rep(i,n){
        cin>>a[i];
    }
    multiset<ll> se;
    rep(i,n)
    {
        if (se.lower_bound(a[i]) != se.begin())
        {
            se.erase(prev(se.lower_bound(a[i])));
        }
        se.insert(a[i]);
    }
    cout << se.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
# 初期入力
N,K = (int(x) for x in input().split())
S = input()

#
count_Lr =0 #不幸な人 LR
count_Rl =0 #不幸な人 RL
haji =0
for i in range(N-1):
    s =S[i:i+2]
    if s =="LR":
        count_Lr +=1
    if s =="RL":
        count_Rl +=1
#幸福な人 = 人と人の間の数 -不幸な人
happy_start =len(S) -1 -count_Lr -count_Rl 

change_kanou_num = min(count_Lr,count_Rl,K)
increase = change_kanou_num *2 
if change_kanou_num <K:         #Kが余っていれば、全員同じ向きを向く
    increase += abs(count_Lr -count_Rl)

happy_finsh = happy_start + increase
print(happy_finsh)

Measured memory_bytes: 3316
import * as fs from 'fs'

function Main(input: string) {
  const S = input.trim()
  const weather = ['Sunny', 'Cloudy', 'Rainy']

  switch (S) {
    case weather[0]:
      console.log(weather[1])
      break
    case weather[1]:
      console.log(weather[2])
      break
    case weather[2]:
      console.log(weather[0])
      break
  }
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static List<List<Integer>> edge;
    private static int[] score;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int q = Integer.parseInt(scan.next());

        edge = new ArrayList<List<Integer>>();
        for (int i = 0; i < n; i++) {
            edge.add(new ArrayList<Integer>());
        }
        for (int i = 0; i < n - 1; i++) {
            int a = Integer.parseInt(scan.next());
            int b = Integer.parseInt(scan.next());
            a--;
            b--;
            edge.get(a).add(b);
            edge.get(b).add(a);
        }

        score = new int[n];
        for (int i = 0; i < q; i++) {
            int p = Integer.parseInt(scan.next());
            int x = Integer.parseInt(scan.next());
            p--;
            score[p] += x;
        }
        scan.close();

        dfs(0, 0);

        StringBuilder sb = new StringBuilder();
        sb.append(score[0]);
        for (int i = 1; i < n; i++) {
            sb.append(" ");
            sb.append(score[i]);
        }
        System.out.println(sb.toString());
    }

    private static void dfs(int node, int parent) {
        for (int i : edge.get(node)) {
            if (i == parent) {
                continue;
            }
            score[i] += score[node];
            dfs(i, node);
        }
    }

}


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

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

    if(a.size() > b.size()) cout << "GREATER" << endl;
    else if(a.size() < b.size()) cout << "LESS" << endl;
    else{
        rep(i,a.size()){
            if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }else if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
}


Measured memory_bytes: 256