akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

char l[5005][5005], r[5005][5005];
int n, k, a[5005];

int main(){
	cin >> n >> k;
	for(int i=1; i<=n; i++) cin >> a[i];
	l[0][0] = 1;
	for(int i=1; i<=n; i++){
		for(int j=0; j<=k; j++){
			l[i][j] = l[i-1][j];
			if(j >= a[i]) l[i][j] |= l[i-1][j-a[i]];
		}
	}
	r[n+1][0] = 1;
	for(int i=n; i; i--){
		for(int j=0; j<=k; j++){
			r[i][j] = r[i+1][j];
			if(j >= a[i]) r[i][j] |= r[i+1][j-a[i]];
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		int ps[5005] = {};
		for(int j=0; j<=k; j++){
			if(l[i-1][j]) ps[j]++;
			if(j) ps[j] += ps[j-1];
		}
		auto getsum = [&](int s, int e){
			int ret = (e >= 0 ? ps[e] : 0);
			ret -= (s > 0 ? ps[s-1] : 0);
			return ret;
		};
		int s = max(k - a[i], 0), e = k-1;
		for(int j=0; j<=k; j++){
			if(r[i+1][j] && getsum(s-j, e-j)){
				ans++;
				break;
			}
		}
	}
	cout << n-ans << endl;
}


Measured memory_bytes: 49152
// HowManyWays.cc
// 1 から n までの数の中から、重複無しで３つの数を選び、
// それらの合計が x となる組み合わせの数を求めるプログラムを作成して下さい。
//
// 例えば、1 から 5 までの数から３つを選んでそれらの合計が 9 となる組み合わせは、
//
// ・1 + 3 + 5 = 9
// ・2 + 3 + 4 = 9
//
// の２通りがあります。
// 【入力】
// 複数のデータセットが入力として与えられます。
// 各データセットでは、空白で区切られた n、x が 1 行に与えられます。
//
// n、x がともに 0 のとき入力の終わりとします。
// 【出力】
// 各データセットについて、組み合わせの数を１行に出力して下さい。
// 【制約】
// ・3 ≤ n ≤ 100
// ・0 ≤ x ≤ 300
// 【例】
// 入力：
// 5 9
// 0 0
// 出力：
// 2
#include<iostream>
using namespace std;

int main( void) {
  int n, x;

  while ( true) {
    cin >> n >> x;

    if ( n == 0 && x == 0) break;

    int counter = 0;
    for ( int i = 1 ; i <= n; i++) {
      for ( int j = i + 1; j <= n; j++) {
	for ( int k = j + 1; k <= n; k++) {
	  if ( i + j + k == x) counter++;
	}
      }
    }

    cout << counter << endl;
  }

  return 0;
}



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

using namespace std;

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

    vector<int> vt(n);
    for (int i = 0; i < n; ++i) {
        cin >> vt[i];
    }

    int tmp = vt[0];
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        tmp = min(tmp, vt[i]);
        if (vt[i] == tmp) {
            ans++;
        }
    }

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 1000000007
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/

int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	ll n=read(),ans=0,s=0;
	for(int i=1;i<=n;i++) {
		ll x;
		cin>>x;
		(ans+=s*x%mod)%=mod;
		(s+=x)%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3584
import java.util.*;

class Main
{
  public static void main(String [] args)
  {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    int [] arr = new int [n];
    
    for(int i = 0; i < n;i++)
      	arr[i] = s.nextInt();
    
    Arrays.sort(arr);
    
    int ans = 0;
    
    for(int i = 0; i < k; i++)
      ans += arr[i];
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 39068
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU

-- Input: s t
-- Output: arr
--   arr!(i,j) == length of lcs of (take i s, take j t)
lcsTable :: BS.ByteString -> BS.ByteString -> V.Vector (VU.Vector Int)
lcsTable xs ys = V.scanl step (VU.replicate (m+1) 0) xs'
  where
    n = BS.length xs; m = BS.length ys
    xs' = V.generate n $ BS.index xs :: V.Vector Char
    ys' = VU.generate m $ BS.index ys :: VU.Vector Char
    step :: VU.Vector Int -> Char -> VU.Vector Int
    step v x
      = VU.scanl innerStep 0 (VU.zip3 v (VU.tail v) ys')
      where
        innerStep :: Int -> (Int, Int, Char) -> Int
        innerStep a (b,c,y) | x == y    = 1 + b
                            | otherwise = max a c

solve :: BS.ByteString -> BS.ByteString -> String
solve !s !t = let !table = lcsTable s t
                  !n = BS.length s
                  !m = BS.length t
                  recon !i !j acc | i == 0 || j == 0 = acc
                                  | x == y = recon (i-1) (j-1) (x : acc)
                                  | table V.! (i-1) VU.! j >= table V.! i VU.! (j-1) = recon (i-1) j acc
                                  | otherwise = recon i (j-1) acc
                    where x = BS.index s (i-1)
                          y = BS.index t (j-1)
              in recon n m []

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  putStrLn (solve s t)


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  int x;
  cin >> x;
  
  int kekka = x;
  bool hantei = false;
  
  while(hantei == false){
    hantei = IsPrime(kekka);
    if(hantei == true)cout << kekka << endl;
    else kekka ++;
  }
}

Measured memory_bytes: 3680
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int main() {
	int N, a, b, c, d;
	cin >> N >> a >> b >> c >> d;

	rep(i, N) {
		ll u = (ll)(N - 1) * d - (ll)i*(d + c);
		ll l = (ll)(N - 1) * c - (ll)i*(d + c);
		if (l <= b - a && b - a <= u) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	for (int i = 1; i < 10; ++i) {
		if (n % i == 0 && n / i < 10) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		int check=0;
		for(int i=1;i<=9;i++) {
			for(int j=1;j<=9;j++) {
				if(n==i*j) {
					check=1;
					break;
				}
			}
		}
		System.out.println((check==1)? "Yes":"No");
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a, b, c, d, e, X, Y ,r;
  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld", &a);
  for(i=1;i<a+1;i++){
    if(i%3==0||i%5==0);
    else sum=sum+i;
  }
  printf("%lld\n",sum);
  
return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(int, c);
    Cin(int, d);
    Cout(a*a-b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<lli,lli>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N; 
  Vec(P,pint,N,pint(0,0));
  rep(i,0,N){
    cin >> P[i].first;
    P[i].second=i+1;
  } 
  Sort(P);
  rep(i,0,N)Out(P[i].second);
}

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

int main(){
  int n;
  cin >> n;
  if(n%10==3){
    cout << "bon"<<endl;
  }
  else if(n%10==1 || n%10==0||n%10==6||n%10==8){
    cout << "pon" << endl;
  }
  else cout << "hon"<< endl;
  return 0;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String []args){

		Scanner sc=new Scanner(System.in);

		while(sc.hasNext()){
			String[] line=sc.nextLine().split(" ");

			int a=Integer.parseInt(line[0]);
			int b=Integer.parseInt(line[1]);

			int sum=a+b;

			System.out.println(String.valueOf(sum).length());
		}

	}
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n; --n;
	vector<int>c(n),s(n),f(n);
	for(int i=0;i<n;++i)cin>>c.at(i)>>s.at(i)>>f.at(i);
	for(int i=0;i<n;++i){
		int ans=c.at(i)+s.at(i);
		for(int j=i+1;j<n;++j){
			if(ans<s.at(j))ans=s.at(j);
			else if(ans%f.at(j))ans+=f.at(j)-ans%f.at(j);
			ans+=c.at(j);
		}
		cout<<ans<<"\n"s;
	}
	cout<<0<<"\n"s;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<fstream>
#include<string>
#include<set>
using namespace std;

int main() {
 int n; cin >> n;
 int a[100000];
 int b[100000];
 int rec = 1;
 for (int i = 0; i < n; i++) {
  cin >> a[i];
  b[a[i]-1]= i + 1;
 }
 for (int i = 0; i < n; i++) {
  cout << b[i] << " ";
 }
 cout << endl;
}

Measured memory_bytes: 1536
def MAP(): return list(map(int,input().split()))

n = int(input())
a = MAP()
b = MAP()
c = MAP()

ans=b[a[0]-1]
for i in range(1,n):
    ans += b[a[i]-1]
    if a[i-1]+1==a[i]:
        ans+=c[a[i-1]-1]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, d, N, ans=0;
    vector<int> v(3);
    vector<char> L(3);
    char tmp, tmp2;
    string S, S2, S3;
    bool flag=true;
    
    cin >> a >> b;

    ans = max(max(a+b, a*b), a-b);
    cout << ans << endl;
    // ans = a<=b ? a:a-1;

    
    // ans = min(A, B) + min(C, D);
    // cout << ans<< endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(abs(a-b) <=d && (b-c) <=d ||abs(c-a)<=d)
    // 	puts("Yes");
    // else
    // 	puts("No");
}



Measured memory_bytes: 256
l = input().split()
N = int(l[0])

XY = []

for i in range(N):
    l = input().split()
    XY.append((int(l[0]), int(l[1])))

# print(N, XY)

diffs = []

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        diff = (XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])
        if diff not in diffs:
            diffs.append(diff)

# print(diffs)

def same_diff(d1, d2):
    return d1[0] == d2[0] and d1[1] == d2[1]

max_count = 0
for diff in diffs:
    count = 0
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            d = (XY[i][0] - XY[j][0], XY[i][1] - XY[j][1])
            if d == diff:
                count += 1
                # print(diff, i, j, count)
    max_count = max(max_count, count)

print(N - max_count)


Measured memory_bytes: 41812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define PB push_back
#define ALL(_v) (_v).begin(), (_v).end()
#define SZ size()
typedef long long LL;

using namespace std;

struct xyz {
    int a;
    int b;
};

int main()
{
    int n, m;
    cin >> n >> m;
    
    vector<xyz> v(m);
    for(int i = 0; i < m; i++) {
        cin >> v[i].a >> v[i].b;
    }
    
    int ans = 0;
    for(int i = 0; i < m; i++) {
        bool flag[n][n];
        
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                flag[j][k] = false;
            }
        }
        
        for(int j = 0; j < n; j++) {
            vector<int> ad(1, j);
            flag[j][j] = true;
            
            while(ad.empty() == false) {
                int last = ad[ad.size() - 1];
                ad.pop_back();
                for(int k = 0; k < m; k++) {
                    if(i != k) {
                        if(v[k].a - 1 == last && flag[j][v[k].b - 1] == false) {
                            flag[j][v[k].b - 1] = true;
                            ad.PB(v[k].b - 1);
                        }
                        if(v[k].b - 1 == last && flag[j][v[k].a - 1] == false) {
                            flag[j][v[k].a - 1] = true;
                            ad.PB(v[k].a - 1);
                        }
                    }
                }
            }
        }
        
        bool check = false;
        for(int j = 0; j < n; j++) {
            for(int k = 0; k < n; k++) {
                if(flag[j][k] == false) {
                    check = true;
                    ans++;
                    break;
                }
            }
            if(check == true) {
                break;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 998244353;
const int MX = (int)2e5;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n, m, k;
	cin >> n >> m >> k;
	vector<string> vec(n);
	for(auto &str : vec){
		cin >> str;
	}

	int res = 0;

	for(int r_msk = 0; r_msk < (1 << n); ++r_msk){
		for(int c_msk = 0; c_msk < (1 << m); ++c_msk){
			vector<string> tmp = vec;
			for(int row = 0; row < n; ++row){
				if((r_msk >> row) & 1){
					for(int c = 0; c < m; ++c)
						tmp[row][c] = 'r';
				}
			}
			for(int col = 0; col < m; ++col){
				if((c_msk >> col) & 1){
					for(int r = 0; r < n; ++r)
						tmp[r][col] = 'r';
				}	
			}

			int cnt = 0;
			for(auto &s : tmp)
				for(auto &c : s)
					cnt += (c == '#');

			res += (k == cnt);
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3660
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

K = I()
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
if K % 7 == 0:
    K //= 7

A = [1]
for i in range(K+2):
    A.append((A[-1]*10) % K)

a = 1
i = 1
while True:
    if a % K == 0:
        print(i)
        break
    else:
        a += A[i]
        a %= K
        i += 1


Measured memory_bytes: 141392
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        K: usize,
        R: i64,
        S: i64,
        P: i64,
        T: String,
    }

    let mut my_hands: Vec<char> = vec![' '; N];
    let mut ans: i64 = 0;

    // とりあえずK回目までは好きなように出す
    for i in 0..K {
        match &T[i..=i] {
            "r" => {
                my_hands[i] = 'p';
                ans += P;
            }
            "s" => {
                my_hands[i] = 'r';
                ans += R;
            }
            "p" => {
                my_hands[i] = 's';
                ans += S;
            }
            _ => {}
        }
    }

    // K回目以降は、得するように適宜過去を改変する
    for i in K..N {
        match &T[i..=i] {
            "r" => {
                if my_hands[i - K] == 'p' {
                } else {
                    my_hands[i] = 'p';
                    ans += P;
                }
            }
            "s" => {
                if my_hands[i - K] == 'r' {
                } else {
                    my_hands[i] = 'r';
                    ans += R;
                }
            }
            "p" => {
                if my_hands[i - K] == 's' {
                } else {
                    my_hands[i] = 's';
                    ans += S;
                }
            }
            _ => {}
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2612
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());
		
		long ans = 0;
		
		for(int i = 1 ; i <= n ; i++) {
			if(i % 3 == 0) {
				continue;
			}
			if(i % 5 == 0) {
				continue;
			}
			ans += (long)i;
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 27092
#include<iostream>
#include<vector>
#include<algorithm>
#define U 0
#define R 1
#define D 2
#define L 3
using namespace std;
int direct(int prex,int prey,int x,int y)
{
	if (prex < x)
	{
		return R;
	}
	else if (prex > x)
	{
		return L;
	}
	else if (prey < y)
	{
		return U;
	}
	else
	{
		return D;
	}
}

int diff(int direct,int prex,int prey,int x,int y)
{
	if (direct == U)
	{
		return abs(y - prey);
	}
	else if (direct == R)
	{
		return abs(x - prex);
	}
	else if (direct == D)
	{
		return abs(prey - y);
	}
	else
	{
		return abs(prex - x);
	}
}
int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		vector<pair<int,int> > a;
		int m1,prex1,prey1;
		cin >> m1;
		for (int i = 0; i < m1; i++)
		{
			int x, y;
			cin >> x >> y;
			if (i != 0)
			{
				int d = direct(prex1, prey1, x, y);
				int dd = diff(d, prex1, prey1, x, y);
				a.push_back(make_pair(d, dd));
			}
			prex1 = x;
			prey1 = y;
		}
		for (int i = 1; i <= n; i++)
		{
			int m2;
			cin >> m2;

			vector<pair<int,int> > b;
			int prex2 = 0;
			int prey2 = 0;
			for (int j = 0; j < m2; j++)
			{
				int x, y;
				cin >> x >> y;
				if (j != 0)
				{
					int d = direct(prex2, prey2, x, y);
					int dd = diff(d, prex2, prey2, x, y);
					b.push_back(make_pair(d,dd));
				}
				prex2 = x;
				prey2 = y;
			}
			if (m1 != m2)continue;
			bool ok = false;
			for (int k = 0; k < 4; k++)
			{
				bool ook = true;
				for (int l = 0; l < m2 - 1; l++)
				{
					if (a[l].first == (b[l].first + k) % 4 && a[l].second == b[l].second)continue;
					ook = false;
					break;
				}
				if (ook)
				{
					ok = true;
					break;
				}

				ook = true;
				for (int l = 0; l < m2 - 1; l++)
				{
					if (a[m2 - 2 - l].first == (b[l].first + k) % 4 && a[m2 - 2 - l].second == b[l].second)continue;
					ook = false;
					break;
				}

				if (ook)
				{
					ok = true;
					break;
				}
			}

			if (ok)
			{
				cout << i << endl;
			}
		}
		cout << "+++++" << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin >> h >> w;
    bool c[h*w]={};
    int dist[h*w];
    int cnt=0;
    for(int i = 0; i < h; i++) {
        string tmp;
        cin >> tmp;
        for(int j = 0; j < w; j++) {
            if(tmp[j]=='.'){
                c[i*w+j]=true;
                dist[i*w+j]=-1;
                cnt++;
            }
        }
    }

    queue<int> que;
    int s=0;
    dist[s]=0;
    que.push(s);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        if(v%w!=w-1 && c[v+1] && dist[v+1]==-1){
            dist[v+1]=dist[v]+1;
            que.push(v+1);
        }
        if(v%w!=0 && c[v-1] && dist[v-1]==-1){
            dist[v-1]=dist[v]+1;
            que.push(v-1);
        }
        if(v/w!=h-1 && c[v+w] && dist[v+w]==-1){
            dist[v+w]=dist[v]+1;
            que.push(v+w);
        }
        if(v/w!=0 && c[v-w] && dist[v-w]==-1){
            dist[v-w]=dist[v]+1;
            que.push(v-w);
        }
    }
    int ans;
    if(dist[h*w-1]==-1) ans=-1;
    else ans=cnt-1-dist[h*w-1];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
//Bismillah hirrahmanir Rahim
        #include<bits/stdc++.h>
        #define ll long long
        #define pb push_back
        #define dbug printf("I am here\n");
        #define Fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        using namespace std;
     
    main() {
        Fast
     string a;
     cin>>a;
     int cnt=0;
     for(int i=0;i<a.size();i++){
        if(a[i]=='7'){
                cnt++;
                cout<<"Yes"<<endl;
               break;
         }
     }
      if(cnt==0) cout<<"No"<<endl;
    	return 0;
    }

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <string>
#include <math.h>
using namespace std;


int main() {

    int i=0;
    int N,R;
    cin >> N >> R;
    if(N<10){
    int ans = R+100*(10-N);
    cout << ans << endl;
    }else{
        cout << R << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
/*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
stack push pop top
queue push pop front
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////
string key[3] =
{
  "the",
  "this",
  "that"
};
/////
int caeser(string S)
{
  int n = S.length();
  REP(i,26)
  {
    string tmp;
    REP(j,n)
    {
      if(S[j] == '.') continue;
      tmp += ((S[j]-'a'+i)%26)+'a';
    }
    REP(k,3) if(tmp == key[k]) return i;
  }
  return -1;
}

void decode(string &S,int t)
{
  if(t < 0) return;
  int n = S.length();
  REP(i,n)
  {
    if(S[i] == '.') continue;
    S[i] = ((S[i]-'a'+t)%26)+'a';
  }
}

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

  string str;
  while(getline(cin,str))
  {
    int t, n;
    string tmp;
    vector<string> data;
    istringstream stream(str);
    while(getline(stream,tmp,' ')) data.push_back(tmp);
    n = data.size();
    REP(i,n) if((t=caeser(data[i]))!=-1) break;
    REP(i,n) decode(data[i],t);
    REP(i,n)
    {
      printf("%s",data[i].c_str());
      printf("%s",(i!=n-1)?" ":"\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  map<string ,ll> m;
  rep(i,n){
    string s;cin >> s;
    m[s]++;
  }
  ll ma = 0;
  for(auto i : m){
    ma = max(ma, i.second);
  }
  vector<string> v;
  for(auto i : m){
    if(i.second==ma)v.push_back(i.first);
  }
  sort(all(v));
  rep(i,v.size()){
    cout << v[i] << endl;
  }
}

Measured memory_bytes: 25584
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,s;
    auto dp = vectors(11,1001,0LL);
    // dp[i][j] := used i number, and the SUM is j
    dp[0][0] = 1;
    for(int num = 0; num <= 100;num++){
        for(int k = 9; k>= 0;--k){
            for(int crt = 0; crt <= 1000;crt++){
                if(dp[k][crt] != 0 and crt + num <= 1000){
                    dp[k+1][crt + num] += dp[k][crt];
                }
            }
        }
    }
    while(cin >> n >> s,n+s){
        cout << dp[n][s] << endl;
    }
}





Measured memory_bytes: 3236
using System;

class Transfer{
    public static void Main(String[] args){
        int A, B, C;
        string[] input;

        input = Console.ReadLine().Split(' ');
        A = int.Parse(input[0]);
        B = int.Parse(input[1]);
        C = int.Parse(input[2]);
        
        A = A - B;
        C = C - A;

        if(C <= 0 ){
            Console.WriteLine('0');
        }else{
            Console.WriteLine(C);
        }
    }
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  rep(i,n) cin >> a[i];
  ll ans = 0;
  ll sums = 0;
  rep(i,n)
  {
    if(a[i] == 0)
    {
      ans += sums/2;
      sums = 0;
    }
    else sums += a[i];
  }
  ans += sums/2;
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.awt.*;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int x=sc.nextInt(),rem=x%500;
        System.out.println(1000*(x/500)+5*(rem/5));
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 22868
#!/usr/bin/env python3
import sys, heapq


def solve(N: int, K: int, t: "List[int]", d: "List[int]"):
    group = {}
    for i in range(N):
        k = t[i]
        v = d[i]
        if k in group:
            group[k].append(v)
        else:
            group[k] = [v]
    groups = list(group.values())
    for g in groups:
        g.sort(reverse=True)
    groups.sort(reverse=True, key=lambda x: x[0])
    h = []
    ret = 0
    base = 0
    #print(groups)
    for i in range(min(len(groups), K)):
        g = groups[i]
        bonus = (i + 1) ** 2
        for j, v in enumerate(g):
            if j == 0:
                if len(h) > K - (i + 1):
                    remove = heapq.heappop(h)
                else:
                    remove = 0
                base = base - remove + v
            elif len(h) < K - (i + 1):
                heapq.heappush(h, v)
                base += v
            elif len(h) > 0 and h[0] < v:
                base += v - h[0]
                heapq.heapreplace(h, v)
            ret = max(ret, base + bonus)
            #print(h)
            #print("bonus : %d, base : %d, ret : %d" % (bonus, base, ret))
            #print(' --- ')
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    t = [int()] * (N)  # type: "List[int]" 
    d = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        t[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, K, t, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28960
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
#define io  ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main(){
        int t,x;
        cin>>t>>x;
        if(t>x) cout<<"safe"<<endl;
        else cout<<"unsafe"<<endl;
return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  vector<int> t(n);
  REP(i,n) cin >> t[i];
  int m;
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  REP(i,m) cin >> p[i] >> x[i];
  REP(i,m) p[i]--;

  ll sum = 0;
  REP(i,n) sum += (ll)t[i];

  REP(i,m){
    ll ans = sum;
    ans -= (ll)t[p[i]];
    ans += (ll)x[i];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main()
{
    int N; cin >> N;
    int *A = new int[N];
    int *B = new int[N];
    int *C = new int[N-1];
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N-1; i++) cin >> C[i];

    int sum = 0;
    for (int i = 0; i < N-1; i++) {
        int dish = A[i];
        sum += B[dish-1];
        if (A[i+1] == dish + 1) {
            sum += C[dish-1];
        }
    }

    sum += B[A[N-1]-1];

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て

int		main(void)
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B && B == C)
	{
		if (A%2 == 0 && B%2 == 0 && C%2 == 0)
		{
			puts("-1");
			return (0);
		}
	}
	int cnt = 0;
	while (A%2 == 0 && B%2 == 0 && C%2 == 0)
	{
		int	a = A;
		int	b = B;
		int	c = C;
		A = b/2 + c/2;
		B = a/2 + c/2;
		C = a/2 + b/2;
		cnt++;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int sum = 0;
  int non_ten_min = 101;
  for (int i = 0; i < n; ++i) {
    int s;
    std::cin >> s;
    sum += s;
    if (s % 10 != 0 && s < non_ten_min)
      non_ten_min = s;
  }
  if (sum % 10 != 0)
    std::cout << sum << std::endl;
  else if (non_ten_min != 101)
    std::cout << sum - non_ten_min << std::endl;
  else
    std::cout << 0 << std::endl; 
}


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

int main() {

	int a, b; cin >> a >> b;
	string ans;
	if (a == b) ans = "Draw";
	else if (a == 1) ans = "Alice";
	else if (b == 1) ans = "Bob";
	else if (a < b) ans = "Bob";
	else if (b < a) ans = "Alice";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
	"log"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc148d(N int){
	blocks := make([]int,N)
	current := 0
	count := 0
	for i := 0; i < N; i++{
		fmt.Scan(&blocks[i])
		if blocks[i] == current+1{
			current = blocks[i]
		}else{
			count+=1
		}
	}
	if count < N{
		fmt.Println(count)
	}else{
		fmt.Println("-1")
	}
}
 
func main(){
	N := 0
	fmt.Scan(&N)
	abc148d(N)
}

//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}

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

int N, M;

struct bomb{
	int x, b;
	bool operator <(const bomb& t)const{
		if (x != t.x) return x < t.x;
		return b < t.b;
	}
}B[100100];
bool P[100100], C[100100];

vector<pair<int, int> > G[100100];
vector<int> A;

void go(int x)
{
	C[x] = 1;
	for (auto e : G[x]) if (!C[e.first]){
		go(e.first);
		if (P[e.first]){
			P[e.first] ^= 1;
			P[x] ^= 1;
			A.push_back(e.second);
		}
	}
}

int main()
{
	scanf ("%d %d", &N, &M);

	for (int i = 1; i <= N; i++) scanf ("%d %d", &B[i].x, &B[i].b);
	sort(B + 1, B + 1 + N);
	for (int i = 1; i <= N; i++){
		P[i - 1] ^= B[i].b;
		P[i] ^= B[i].b;
	}

	for (int i = 1; i <= M; i++){
		int l, r;
		scanf ("%d %d", &l, &r);
		l = lower_bound(B + 1, B + 1 + N, bomb { l, 0 }) - B - 1;
		r = upper_bound(B + 1, B + 1 + N, bomb { r, 1 }) - B - 1;
		if (l < r){
			G[l].emplace_back(r, i);
			G[r].emplace_back(l, i);
		}
	}

	for (int i = 0; i <= N; i++) if (!C[i]){
		go(i);
		if (P[i]){
			puts("-1");
			return 0;
		}
	}

	sort(A.begin(), A.end());
	printf ("%d\n", A.size());
	for (int i = 0; i < A.size(); i++) printf ("%d%c", A[i], i + 1 < A.size() ? ' ' : '\n');
	return 0;
}


Measured memory_bytes: 13820
X, Y = map(int, input().split())

ans = 0
for i in [X, Y]:
    if i == 3:
        ans += 100000
    if i == 2:
        ans += 200000
    if i == 1:
        ans += 300000

if [1, 1] == [X, Y]:
    ans += 400000

print(ans)

Measured memory_bytes: 3060
import math
while True:
    n = int(input())
    if n == 0:
        break
    s = list(map(float,input().split()))
    m = sum(s) / n
    a = 0
    for i in range(n):
        a += (s[i]-m)**2
    print('{:.8f}'.format(math.sqrt(a/n)))



Measured memory_bytes: 5780
#define _DEBUG 1
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll L) {
  double s = double(L) / 3.0;

  cout << std::fixed;
  cout << pow(s, 3) << endl;
}

int main() {
  ll L;
  scanf("%lld", &L);
  solve(L);
  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, end) for (int i = begin; i > end; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N, K;
int V[200];

int main()
{
    cin >> N >> K;
    rep(i, 0, N)
    {
        cin >> V[i];
    }

    ll ans = -1;
    for (int a = 0; a <= min(N, K); a++)
    {
        for (int b = 0; b <= min(N, K); b++)
        {
            if (a + b > min(N, K))
            {
                break;
            }
            priority_queue<int, vector<int>, greater<int>> have;
            for (int i = 0; i < a; i++)
            {
                have.push(V[i]);
            }
            for (int i = 0; i < b; i++)
            {
                have.push(V[N - 1 - i]);
            }
            ll sum = 0;
            for (int i = 0; i < K - a - b; i++)
            {
                if (have.empty())
                {
                    break;
                }
                if (have.top() >= 0)
                {
                    break;
                }
                have.pop();
            }
            while (!have.empty())
            {
                sum += have.top();
                have.pop();
            }
            ans = max(ans, sum);
        }
    }

    printf("%lld", ans);
}

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

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

    for(i = 0; i < n-k; i++) {
        if (a[i] < a[i+k]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
double memo[301][301][301];
double calc(int i, int j, int k) {
	if (memo[i][j][k] >= 0) return memo[i][j][k];
	int kei = i + j + k;
	double hazure = 1.0 * N / kei;
	double ret = 0;
	if (i) ret += calc(i - 1, j, k) * i / kei;
	if (j) ret += calc(i + 1, j - 1, k) * j / kei;
	if (k) ret += calc(i, j + 1, k - 1) * k / kei;
	return memo[i][j][k] = ret + hazure;
}


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


	cin >> N;
	int kazu[4] = {};
	rep(i, N) {
		int a;
		cin >> a;
		kazu[a]++;
	}
	rep(i, 301) rep(j, 301) rep(k, 301) memo[i][j][k] = -1;
	memo[0][0][0] = 0;

	cout << setprecision(12) << calc(kazu[1], kazu[2], kazu[3]) << endl;

	Would you please return 0;
}

Measured memory_bytes: 213376
#include <bits/stdc++.h>
#define SIZE 5005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int dp[2][SIZE][SIZE];

int main()
{
	int n;
	int MOD;
	scanf("%d %d",&n,&MOD);
	int pos=0;
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++) dp[pos][n-i+1][i]=1;
	for(int i=2;i<n-i+2;i++)
	{
		pos^=1;
		int lim=n/(i-1)+1;
		lim=min(lim,n);
		for(int j=1;j<=min(n,lim*2);j++)
		{
			for(int k=1;k<=n;k++)
			{
				dp[pos][j][k]=0;
			}
		}
		for(int k=1;k<=n;k++)
		{
			ll sum=0,sum2=0;
			for(int j=lim;j>=1;j--)
			{
				sum2+=dp[pos^1][j][k];
				if(sum2>=MOD) sum2-=MOD;
				sum+=sum2;
				if(sum>=MOD) sum-=MOD;
				if(k-(j-1)>0)
				{
					dp[pos][j][k-j+1]+=sum;
					if(dp[pos][j][k-j+1]>=MOD) dp[pos][j][k-j+1]-=MOD;
				}
			}
		}
	}
	ll ret=0;
	if(n%2==1)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				ret+=dp[pos][i][j];
				if(ret>=MOD) ret-=MOD;
			}
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				ret+=(ll) dp[pos][i][j]*(ll) i%MOD;
				if(ret>=MOD) ret-=MOD;
			}
		}
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 195968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a,b,c,d,l,r;
int main(void){
    cin>>a>>b>>c>>d;
    l=a+b; r=c+d;
    if(l==r){
        cout<<"Balanced"<<endl;
    }else if(l<r){
        cout<<"Right"<<endl;
    }else{
        cout<<"Left"<<endl;
    }
    
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000

vector<int> A(MAX);

bool win(int h) {
    for (int a : A) {
        h -= a;
        if (h <= 0) {
            return true;
        }
    }

    return false;
}

int main() {
    int h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> A.at(i);
    }

    cout << (win(h) ? "Yes" : "No") << endl;
}

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

int main() {
	
	int a;

	cin >> a;

	if (a % 10 == 3) {
		cout << "bon" << endl;
	}

	if ((a % 10 == 0) || (a % 10 == 1) || (a % 10 == 6) || (a % 10 == 8)) {
		cout << "pon" << endl;
	}

	if ((a % 10 == 2) || (a % 10 == 4) || (a % 10 == 5) || (a % 10 == 7) || (a % 10 == 9)) {
		cout << "hon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
import sys
import copy

def solve(N: int, x: int, a: "List[int]"):
    cost = sum(a)
    for i in range(N):
        a = [a[j-1] if a[j] > a[j-1] else a[j] for j in range(N)]
        cost = min([cost, sum(a) + x * (i + 1)])
    print(cost)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3700