akhauriyash/Code-Regression huggingface dataset:
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
import numpy as np
from collections import deque
from itertools import combinations
import bisect
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
    n,m,x=ints()
    ca=[]
    val=[]
    for _ in range(n):
        inp=ints()
        ca.append(inp)
        flg=1
        for i in range(1,m+1):
            if inp[i]<x:
                flg = 0
        val.append(inp[0]) if flg==1 else None
    for num in range(2,n+1):
        for v in combinations(ca,num):
            vnp = np.array(v)
            s=vnp.sum(axis=0)
            flg=1
            for i in range(1,m+1):
                if s[i]<x:
                    flg = 0
            val.append(s[0]) if flg==1 else None
    
    print(-1 if not val else min(val))

if __name__ == '__main__':
    main()

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> r(n,vector<int>(0));
  vector<int> sig(n,200005);
  
  for(int i=0;i<m;i++){
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    r[a-1].push_back(b);
    r[b-1].push_back(a);
  }
  
  queue<int> p;
  p.push(1);
  
  while(p.size()){
    int s=p.front();
    p.pop();
    for(int i=0;i<r[s-1].size();i++){
      if(sig[r[s-1][i]-1]==200005){
        sig[r[s-1][i]-1]=s;
        p.push(r[s-1][i]);
      }
    }
  }

  cout << "Yes" << endl;

  for(int i=1;i<n;i++){
    cout << sig[i] << endl;
  }
}

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

typedef long long ll;

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

    int N;
    cin >> N;

    if(N == 1) {
        cout << "Hello World" << endl;
        return 0;
    }

    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h = S / 3600;
    m = (S - h * 3600) / 60;
    s = S % 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 1992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, L := nextInt(), nextInt()
	sumL := N * (L + L + N - 1) / 2
	if L > 0 {
		sumL -= L
	} else if L+N-1 < 0 {
		sumL -= (L + N - 1)
	}
	fmt.Println(sumL)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int, b int) int {
	if a > b {
		return a - b
	} else {
		return b - a
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int main() {
	int n;
	bool p[1000000];

	p[0] = 0;
	p[1] = 0;

	for(int i = 2; i <= 999999; i++) {
		p[i] = true;
	}

	for(int i = 2; i * i <= 999999; i++) {
		for(int j = i; j * i <= 999999; j++) {
			p[j * i] = false;
		}
	}

	while(cin >> n) {
		int count = 0;
		for(int i = 2; i <= n; i++) {
			if(p[i] == true) {
				count++;
			}
		}

		cout << count << endl;
	}
}

Measured memory_bytes: 2132
#include<string.h>
#include<stdio.h>
int main()
{
  char s[11],t[12];
  scanf("%s%s",s,t);
  int f=1;
  int n=strlen(s);
  for(int i=0;i<n;++i)
  {
    if(s[i]!=t[i])
    {f=0;break;}
  }
  if(f)
    printf("Yes");
  else
    printf("No");
  return 0;
}


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

int main(){
  int n,a;
  cin>>n;
  vector<int> v;
  for(int i=0; i<n; ++i){
    cin>>a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  int vs;
  vs=v.size();
  int b,c;
  b=v[0];
  c=v[vs-1];
  int x,y;
  x=INT_MAX;
  for(int i=b; i<=c; ++i){
    y=0;
    for(int j=0; j<vs; ++j){
      y+=pow(v[j]-i,2);
    }
    if(x>y) x=y;
  }
  cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

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

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

int main(){
    int N, Z, W;
    cin >> N >> Z >> W;

    vi scores = input<int>(N);

    ll score1 = abs(scores[N - 1] - W);
    ll score2 = abs(scores[N - 1] - scores[N - 2]);
    if (N == 1) {
        score2 = 0;
    }

    cout << max(score1, score2) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int d = distance(lower_bound(L.begin(), L.end(), L[i] + L[j]), L.end());
      ans += (N - 1 - j) - d;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int a[110];
  int sum = 0;
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  int ans = 10000000;
  rep(t,n) {
    int n1 = 0;
    int n2 = 0;
    rep(i,t) n1 += a[i];
    n2 = sum - n1;
    ans = min(ans, abs(n1 - n2));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
bool check(int i, vector<int> trust, vector<int> lie) {
  for (int k : trust)
    if (!(i & (1 << k))) return false;
  for (int k : lie)
    if (i & (1 << k)) return false;
  return true;
}

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<vector<int>> trust(n, vector<int>(0));
  vector<vector<int>> lie(n, vector<int>(0));
  rep(i, n) {
    int a;
    cin >> a;
    rep(j, a) {
      int x, y;
      cin >> x >> y;
      x--;
      if (y == 1)
        trust[i].push_back(x);
      else
        lie[i].push_back(x);
    }
  }
  rep(i, n) {
    debug(i);
    for (auto j : trust[i]) debug("trust", j);
    for (auto j : lie[i]) debug("lie", j);
  }
  int res = 0;
  for (int i = 0; i < (1 << n); i++) {
    // cout << bitset<8>(i) << endl;
    int temp = 0;
    bool flag = true;
    rep(j, n) {
      if (i & (1 << j)) {
        flag &= check(i, trust[j], lie[j]);
      }
    }
    if (flag) temp = __builtin_popcount(i);
    res = max(res, temp);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
 
  // ここにプログラムを追記
  if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o") {
    
   cout << "vowel" << endl; 
    
  }
  else {
    
    cout << "consonant" << endl;
    
  }
}

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

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

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

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

    set<int> st;
    for(int i = 0 ; i < n ; ++i){
        int a;
        cin >> a;
        if(st.count(a)){
            st.erase(a);
        }else{
            st.insert(a);
        }
    }

    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

main() {
  int W, H, N; cin >> W >> H >> N;
  P X(0, W), Y(0, H);
  for (int i = 0; i < N; i++) {
    int x, y, a; cin >> x >> y >> a;
    if (a == 1) X.first = max(X.first, x);
    if (a == 2) X.second = min(X.second, x);
    if (a == 3) Y.first = max(Y.first, y);
    if (a == 4) Y.second = min(Y.second, y);
  }
  cout << max(0, Y.second - Y.first) * max(0, X.second - X.first) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;

    vvl c(n, vl(3));
    rep(i, n) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }
    
    ll ans = -INF;
    rep(b, 1<<3) {

        vl v(n);
        rep(i, n) {
            rep(j, 3) {
                if(b & (1<<j)) {
                    v[i] += c[i][j];
                }
                else {
                    v[i] += -c[i][j];
                }
            }
        }

        sort(rall(v));
        
        ll now = 0;
        rep(i, m) {
            now += v[i];
        }

        chmax(ans, now);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
from functools import lru_cache


CHECK = False

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

MOD = 10 ** 9 + 7


@lru_cache(maxsize=None)
def modInverse(a, p):
    # Fermat's little theorem, a**(p-1) = 1 mod p
    return pow(a, p - 2, p)


if N - 1 <= K or CHECK:
    fact = [1]
    for i in range(1, 2 * N + 1):
        fact.append((fact[-1] * i) % MOD)

    def nCr(n, r, p=MOD):
        # Modulo binomial coefficients
        return (fact[n] * modInverse(fact[r], p) * modInverse(fact[n - r], p)) % p


if N - 1 <= K:
    # Any combo is achievable so this is stars and bars
    # N people into N rooms, which means N - 1 dividers
    stars = N
    bars = N - 1
    print(nCr(stars + bars, bars))
else:
    # Group by number of empty rooms
    # With K moves there can only be at most K empty rooms
    # Max of N - 1 empty rooms in general
    assert K + 1 < N
    tot = 0
    comb1 = 1
    comb2 = 1
    for numEmpty in range(K + 1):
        way3 = comb1 * comb2
        if CHECK:
            numNonEmpty = N - numEmpty
            stars = numEmpty  # Everyone moving into an occupied room
            bars = numNonEmpty - 1  # Number of dividers
            way1 = nCr(stars + bars, bars) * nCr(N, numEmpty)

            way2 = nCr(N, numEmpty) * nCr(N - 1, numEmpty)

            assert way1 % MOD == way2 % MOD == way3 % MOD
        tot += way3

        j = numEmpty + 1
        invJ = modInverse(j, MOD)
        comb1 = (N + 1 - j) * comb1 * invJ % MOD
        comb2 = (N - j) * comb2 * invJ % MOD
    print(tot % MOD)


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S, T; cin >> S >> T;
    ll ans = 0;
    REP(i, S.length()) {
        if(S[i] != T[i]) {
            ans++;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3756
#include <iostream>
using namespace std;
const int maxn = 1e5 + 5;

int H, W;
char s[maxn];

int main(){
    cin>>H>>W;
    for(int i = 0; i < W + 2; i ++)cout<<'#';
    cout<<endl;
    for(int i = 0; i < H; i ++){
        cin>>s;
        cout<<'#'<<s<<'#'<<endl;
    }
    for(int i = 0; i < W + 2; i ++)cout<<'#';
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
	ll ans = 1;
	rep(i,n){
		ans *= (i+1);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    while(1){
        string x;
        cin >> x;
        if(x == "0"){ break; }
        ll ans = 0;
        for(char c : x){
            ans += c - '0';
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a != c)
    {
        cout << c;
    } 
    else if(a == c && a != b)
    {
        cout << b;
    }
    else
    {
        cout << a;
    }

    return 0;
}

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

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

	int ans = abs( A + B ) / 2;
	if( abs( A + B ) % 2 ) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace::std;

int main(){

  int w;
  int n;
  int i;
  int a;
  int b;
  int number[32] = {};

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

  for(i = 1; i <= w; i++){
    number[i] = i;
  }

  for(i = 0; i < n; i++){
    scanf("%d,%d", &a, &b);
    swap(number[a], number[b]);
  }
  for(i = 1; i <= w; i++){
    cout<<number[i]<<endl;
  }


  return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
const int size=10000;
int main(){
  int i,k,n;
  int data[size];
  for(i=2;i<size;i++){
    data[i]=1;
  }
  for(i=2;i<size;i++){
    if(data[i]){
      for(k=2*i;k<=size;k+=i){
        data[k]=0;
      }
    }
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=n;i>=0;i--){
      if(data[i]==1 && data[i-2]==1){
        break;
      }
    }
    printf("%d %d\n",i-2,i);
  }
  return 0;
}

Measured memory_bytes: 2716
N, C, K = gets.split.map(&:to_i)
T = N.times.map { gets.to_i }.sort

ans = 0

until T.empty?
  t = T.shift
  limit = t + K
  cnt = 1

  while T.size > 0 && T.first <= limit && cnt < C
    T.shift
    cnt += 1
  end

  ans += 1
end

puts ans


Measured memory_bytes: 4656
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(a * b + " " + 2 * (a + b));

		sc.close();

	}

}

Measured memory_bytes: 26344
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

from collections import deque
def main():
    S = input()
    queue = deque(list(S))
    Q = INT()
    reverse_flag = False

    for _ in range(Q):
        query = list(input().split())
        if len(query) == 3:
            F = int(query[1])
            C = query[2]
            if F == 1:
                if reverse_flag:
                    queue.append(C)
                else:
                    queue.appendleft(C)
            elif F == 2:
                if reverse_flag:
                    queue .appendleft(C)
                else:
                    queue.append(C)
        else:
            if reverse_flag:
                reverse_flag = False
            else:
                reverse_flag = True
    answer = ''.join(queue)
    if reverse_flag:
        answer = answer[::-1]
    print(answer)
    return
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 8540
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(ALL(l));
    ll ans = 0;
    rep(i, n-2){
        rep2(j, i+1, n-1){
            int a, b;
            a = l[i];
            b = l[j];
            int it = lower_bound(ALL(l), a+b) - l.begin();
            if(it == n+1) continue;

            ans += it - j - 1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        if(n == 0) {
            System.out.println(x);
            return;
        }
        int[]p = new int [101];
        for(int i=0; i<n; i++) {
            p[sc.nextInt()] = 1;
        }
        for(int i=0; i<101; i++) {
            if(x-i >= 0) {
                if(0 == p[x-i]) {
                    System.out.println(x-i);
                    return;
                }
            } 
            if(x+i <101) {
                if(0 == p[x+i]) {
                    System.out.println(x+i);
                    return;
                }
            }else {
                System.out.println(101);
                return;
            }
        }
    }
}

Measured memory_bytes: 36056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define TEST cout << "ococo" << endl;
using namespace std;

//memo;998244353

int main(void){
	int n;
	long long answer = 1;
	cin >> n;
	vector<int> d(n);
	vector<int> count(100001,0);
	for(int i = 0; i != n; i++){
		cin >> d[i];
		count[d[i]]++;
	}
	int max = *max_element(d.begin(),d.end());


	if (d[0] != 0 || count[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i != max; i++) {
		if (count[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	for (int i = 0; i != max; i++) {
		long long temp = 1;
		for(int j = 0; j != count[i + 1]; j++){
			temp *= count[i];
			temp %= 998244353;
		}
		answer *= temp;
		answer %= 998244353;
	}
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 1024
n, p = map(int, input().split())
S = input()

m = [0 for i in range(p)]

ans = 0
m[0] = 1

if p == 2 or p == 5:
    for i in range(n):
        if int(S[i]) % p == 0:
            ans += i+1

else:
    cnt = 10 % p
    for i in range(n):
        s = int(S[n-1-i])
        if i == 0:
            r = s%p
        else:
            r = (cnt*s+r) % p
            cnt = cnt * 10 % p
        if m[r] >= 1:
            ans += m[r]
        m[r] += 1

print(ans) 


Measured memory_bytes: 3500
# coding: utf-8

def main():
    N = int(input())
    d = sorted(list(map(int, input().split())))
    ans = 0
    if d[N // 2] != d[N // 2 - 1]:
        ans = d[N // 2] - d[N // 2 - 1]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20684
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,l,r,m,now,ans
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    call merge_sort(a,1,n)
    ans=0
    do i=1,n-2
        do j=i+1,n-1
            now = a(i)+a(j)
            l=j
            r=n+1

            do while (r-l > 1)
                m = (l+r)/2
                if (a(m) < now) then
                    l=m
                else
                    r=m
                end if
            end do
            ans=ans+l-j
        end do
    end do
    print'(i0)', ans
contains
    recursive subroutine merge_sort(ar, fst, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst,lst
        integer(int32):: mdl

        if (lst-fst < 2) then
            if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
            return
        end if

        mdl = (fst+lst)/2
        call merge_sort(ar, fst, mdl)
        call merge_sort(ar, mdl+1, lst)
        call merge_(ar, fst, mdl, lst)
    end subroutine

    subroutine merge_(ar, fst, mdl, lst)
        integer(int32),intent(inout):: ar(:)
        integer(int32),intent(in):: fst, mdl, lst
        integer(int32),allocatable:: tmp(:)
        integer(int32):: li, ri, ti

        allocate(tmp(lst-fst+1))

        li=fst
        ri=mdl+1   
        ti=1

        do while (li <= mdl .and. ri <= lst)
            if (ar(li) <= ar(ri)) then
                tmp(ti) = ar(li)
                li=li+1
            else
                tmp(ti) = ar(ri)
                ri=ri+1
            end if
            ti=ti+1
        end do

        if (li <= mdl) then
            tmp(ti:) = ar(li:mdl)
        else
            tmp(ti:) = ar(ri:lst)
        end if

        ar(fst:lst) = tmp(:)
        deallocate(tmp)
    end subroutine

    subroutine swap(x,y)
        integer(int32),intent(inout):: x,y
        integer(int32):: tmp
        tmp = x
        x = y
        y = tmp
    end subroutine
end program name

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[100010];
bool take[100010];
int main() {
    cin >> n;
    int ans = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum ^= a[i];
    }
    for (int i = 30; i >= 0; i--) {
        if (!(sum >> i) & 1) continue;
        bool f = 0;
        for (int j = 0; j < n; j++) {
            if (take[j]) continue;
            int k = a[j];
            if ((k & -k) == (1 << i)) {
                take[j] = 1;
                sum ^= (1 << (i+1))-1;
                ans++;
                f = 1;
                break;
            }
        }
        if (!f) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4024
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e,f,s;
	cin>>a>>b>>c>>d>>e>>f;

	if(a<b){swap(a,b);}
	if(b<c){swap(c,b);}
	if(c<d){swap(c,d);}
	if(a<b){swap(a,b);}
	if(b<c){swap(c,b);}

	if(e<f){swap(e,f);}
	
	s=a+b+c+e;
	cout<<s<<endl;

	return 0;
}




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

int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    bool rev = false;
    string head = "", tail = "";
    for (int z = 0; z < Q; z++) {
        int T;
        cin >> T;
        if (T == 1){
            rev = !rev;
        }
        if (T == 2) {
            int F;
            cin >> F;
            char c;
            cin >> c;
            if ((F == 1) == (!rev)) {
                head += c;
            }else {
                tail += c;
            }
        }
    }
    reverse(head.begin(), head.end());
    if (!rev) {
        cout << head << S << tail << endl;
    }else {
        reverse(head.begin(), head.end());
        reverse(S.begin(), S.end());
        reverse(tail.begin(), tail.end());
        cout << tail << S << head << endl;
    }
    return 0;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
#define lli long long int
#define ll long long
using namespace std;
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,k,i;
    cin>>n>>k;
    lli a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
        cout<<"Yes"<<"\n";
        else
        cout<<"No"<<"\n";
    }
 }

Measured memory_bytes: 5180
/*
我爱你，不知道你是否也爱我呢 
						--愿此代码上无bug										
*/ 
#include <bits/stdc++.h>
using namespace std;

#define INF 0x3f3f3f3f
#define CLR(x,y) memset(x,y,sizeof(x))
#define LC(x) (x<<1)
#define RC(x) (x<<|1)
#define MID(x,y) ((x+y)>>1)
const int N = 1e6+10;
const double PI = acos(-1.0);
priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > >que;
vector<char>v;
map<char,int>mpr;
map<char,int>mpd;
map<int,char>mprl;
map<int,char>mpud;
pair<int,int>ans[107][107];
/*----------------------------------------------------  */
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

/*------------------------------------------------------*/
int n, arr[N], dp[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 0;i < n; i++) 
		cin>>arr[i];
	int ans, res;
	for(int i = 0;i < n; i++) {
		dp[i+1] = INF;
		if(i>=1 && arr[i-1]>arr[i]) ans = i;
		else dp[i+1] = dp[ans]+1;
		if(i>=1 && arr[i-1]<arr[i]) res = i;
		else dp[i+1] = min(dp[i+1],dp[res]+1); 
	}
	cout<<dp[n]<<endl;	
return 0;
}

Measured memory_bytes: 4736
c=[list(map(int,input().split()))for _ in range(3)]
for i in range(c[0][0]+1):
    b=[c[0][0]-i,c[0][1]-i,c[0][2]-i]
    a=[i,c[1][0]-b[0],c[2][0]-b[0]]
    t=1
    for j in range(3):
        for k in range(3):
            if c[j][k]!=a[j]+b[k]:
                t=0
                break
    if t:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
s=input()
if s[0]=="0":exit(print(-1))
if s[-1]=="1":exit(print(-1))
for i in range(len(s)-1):
  if s[i]!=s[(len(s)-1)-(i+1)]:exit(print(-1))
ans=[]
for i in range(len(s)-1):
  if s[i]=="1":
    for j in ans:print(j+1,i+1)
    ans=[]
  ans.append(i)
for j in ans:print(j+1,len(s))

Measured memory_bytes: 12976
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];
    ll fi=0;ll se=0;
    
    sort(a.begin(),a.end());

    rep(i,n){
        if(a[i]==a[i+1]){
            i++;
            swap(fi,se);
            fi=a[i];
        }
    }

cout<<fi*se<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template<typename T, typename E>
struct segment_tree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;

  vector<T> data;
  vector<E> lazy;

  F f;
  G g;
  H h;

  int n;

  T tid;
  E eid;

  P p;
  segment_tree(int size, F f, G g, H h, T tid, E eid, P p=[](E a, int b){b=0;return a+b;}):f(f),g(g),h(h),tid(tid),eid(eid),p(p){
    n = 1;
    while(n<size) n<<=1;
    data.assign(2*n-1,tid), lazy.assign(2*n-1,eid);
  }
  segment_tree(vector<T> v,F f, G g, H h, T tid, E eid, P p=[](E a, int b){return a;}):f(f),g(g),h(h),tid(tid),eid(eid),p(p){
    int size = v.size();
    n = 1;
    while(n<size) n<<=1;
    assign(v);
  }
  void assign(vector<T> v){
    assert((int)v.size()<=n);
    for(size_t i=0;i<v.size();++i) data[i+n-1] = v[i];
    for(int i=v.size();i<n;++i) data[i+n-1] = tid;
    for(int i=n-2;i>=0;--i) data[i] = f(data[2*i+1],data[2*i+2]);
    lazy.assign(2*n-1,eid);
  }
  inline void eval(int k, int len){
    if(lazy[k]!=eid){
      data[k] = g(data[k],p(lazy[k],len));
      // k has children.
      if(len > 1){
        lazy[2*k+1] = h(lazy[2*k+1],lazy[k]);
        lazy[2*k+2] = h(lazy[2*k+2],lazy[k]);
      }
      lazy[k] = eid;
    }
  }
  void update(int i, E x){
    update(i,i+1,x,0,0,n);
  }
  void update(int a,int b,E x){
    update(a,b,x,0,0,n);
  }
  void update(int a, int b, E x,int k, int l, int r){
    eval(k,r-l);

    // [l,r) out of [a,b)
    if(b<=l||r<=a) return;
    // [l,r) in [a,b)
    if(a<=l && r<=b){
      lazy[k] = h(lazy[k],x);
      eval(k,r-l);
    }else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      data[k] = f(data[2*k+1],data[2*k+2]);
    }
  }
  T find(int i){
    return find(i,i+1,0,0,n);
  }
  // [a,b)
  T find(int a,int b){
    return find(a,b,0,0,n);
  }
  T find(int a,int b,int k,int l,int r){
    eval(k,r-l);

    // [l,r) out of [a,b)
    if(r<=a||b<=l) return tid;

    // [l,r) in [a,b)
    if(a<=l&&r<=b) return data[k];

    // else
    return f(find(a,b,2*k+1,l,(l+r)/2),find(a,b,2*k+2,(l+r)/2,r));
  }
};
struct range_minimum_query{
  int ui = -1;
  function<int(int,int)> upd8 = [](int a, int b){return b!=-1?b:a;};
  function<int(int,int)> find = [](int a, int b){return min(a,b);};
  int mi = INT_MAX;
  segment_tree<int,int> seg;
  range_minimum_query(int n):seg(n,find,upd8,upd8,mi,ui){}

  int getmin(int a, int b){
    return seg.find(a,b);
  }
  void update(int s,int t, int x){
    return seg.update(s,t,x);
  }
};
int main(){
  int n,q;
  cin >> n >> q;
  range_minimum_query rmq(n);
  for(int i=0;i<q;++i){
    int com,s;
    cin >> com >> s;
    if(com==0){
      int t,x;cin >> t >> x;
      rmq.update(s,t+1,x);
    }else{
      cout << rmq.getmin(s,s+1) << endl;
    }
  }
}



Measured memory_bytes: 4936
class SegmentTree():
    """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する。
    built(array)   := arrayを初期値とするセグメント木を構築する O(N)。
    update(i, val) := i番目の要素をvalに変更する。
    get_val(l, r)  := 区間[l, r)に対する二項演算の畳み込みの結果を返す。
    """
    def __init__(self, n, op, e):
        """要素数、二項演算、単位元を引数として渡す
        例) 区間最小値 SegmentTree(n, min, 10 ** 18)
            区間和     SegmentTree(n, lambda a, b : a + b, 0)
        """
        self.n = n
        self.op = op
        self.e = e
        self.size = 2 ** ((n - 1).bit_length())
        self.node = [self.e] * (2 * self.size)

    def built(self, array):
        """arrayを初期値とするセグメント木を構築する"""
        for i in range(self.n):
            self.node[self.size + i] = array[i]
        for i in range(self.size - 1, 0, -1):
            self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1])

    def update(self, i, val):
        """i番目の要素をvalに変更する"""
        i += self.size
        self.node[i] = val
        while i > 1:
            i >>= 1
            self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1])

    def get_val(self, l, r):
        """[l, r)の畳み込みの結果を返す"""
        l, r = l + self.size, r + self.size
        res_l, res_r = self.e, self.e
        while l < r:
            if l & 1:
                res_l = self.op(res_l, self.node[l])
                l += 1
            if r & 1:
                r -= 1
                res_r = self.op(self.node[r], res_r)
            l, r = l >> 1, r >> 1
        return self.op(res_l, res_r)

n, m = map(int, input().split())
s = input()
INF = 10 ** 18

st = SegmentTree(n + 1, min, INF)
st.update(n, 0)

for i in range(n)[::-1]:
    if s[i] == "1":
        continue
    tmp = st.get_val(i + 1, min(i + 1 + m, n + 1)) + 1
    st.update(i, tmp)

if st.get_val(0, 1) >= INF:
    print(-1)
    exit()

ans = []
ind = 0
for i in range(n + 1):
    if st.get_val(ind, ind + 1) - 1 == st.get_val(i, i + 1):
        ans.append(i - ind)
        ind = i
print(*ans)

Measured memory_bytes: 61404
n = int(input())
a = list(map(int, input().split()))
d = [0]*n
d[0] = a[0] 
for i in range(1,n):
    d[i] = d[i-1] + a[i]
ans = 1e10
for i in range(n-1):
    b = abs(d[n-1]-2*d[i])
    ans = min(ans,b)
print(ans)

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

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

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

    long a[105]={0};

    long i;
    for(i=1; i<=m; i++) {
        scanf("%ld", &(a[i]));
    }
    for(i=1; i<=m; i++) {
        if(x<a[i])
            break;
    }

    printf("%ld\n", MIN(i-1,m-i+1));


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)

int main() {
    int N;
    cin >> N;
    long A[N];
    REP(i, N){
        cin >> A[i];
    }
    sort(A,A+N,greater<>());
    long result = A[0];
    REP(i, N - 2){
        result += A[(i / 2) + 1];
    }
    cout << result << "\n";
    return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll md = 1000000007;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
vl p, fac(2, 1), ifac(2, 1);

ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll mul(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = ((res%mod) * (x%mod))%mod;
        n = (n >> 1);
        x = ((x%mod) * (x%mod))%mod;
    }
    return res;
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(ll n, ll r, ll mod = md) {
    if(n < r) return 0;
    return mul(fac[n], mul(ifac[r], ifac[n-r], mod), mod);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cachefact(2e6+7);
    int r1, r2, c1, c2, res = 0;
    cin >> r1 >> c1 >> r2 >> c2;
    for(int i = r1; i <= r2; i++) {
    	res = add(res, add(C(i+1+c2, i+1), -C(i+c1, i+1)));
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 43356
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	map<long long int, int>m;
	for (int i = 0; i < N; i++) {
		cin >> M;
		m[-M]++;
	}
	long long int st = 1;
	while (st < MOD * 2)st <<= 1;
	int ans = 0;
	for (auto &i : m) {
		for (long long int j = st; j > 1; j >>= 1) {
			if (-i.first > j / 2)break;
			if (-i.first * 2 == j) {
				ans += i.second / 2;
				i.second %= 2;
				break;
			}
			auto it = m.find(-(j + i.first));
			if (it == m.end())continue;
			int add = min(i.second, it->second);
			ans += add;
			i.second -= add;
			it->second -= add;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12800
n = int(input())
a = [i for i in list(map(int, input().split())) if i % 2 == 0]
b = [i for i in a if i % 3 == 0 or i % 5 == 0]
if len(a) == len(b):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int a[12][12];

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    int ans = 1001001001;

    //input
    for(int i=0; i<n; i++) {
        cin >> c[i];
        for(int j=0; j<m; j++) {
            cin >> a[i][j];
        }
    }
    for(int s=0; s < 1<<n; s++) { //n=12の時 0 ~ 4095まで 2のn乗通り
        int cost = 0;
        vector<int> d(m);
        for(int i=0; i<n; i++) {
            if(s>>i&1) { //sのibit目が立っている時
                cost += c[i];
                for(int j=0; j<m; j++) d[j] += a[i][j];
            }
        }
        bool ok = true;
        for(int j=0; j<m; j++) if (d[j]<x) ok=false;
        if(ok) ans = min(ans, cost);
    }
    if(ans == 1001001001) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
n = int(input())
data = {}
for i in range(n):
    b, f, r, v = map(int, input().split())
    if (b,f,r) in data:
        data[(b,f,r)] = data[(b,f,r)] + v
    else:
        data[(b,f,r)] = v
for b in range(1,5):
    for f in range(1,4):
        for r in range(1,11):
            if (b,f,r) in data:
               print(" "+str(data[(b,f,r)]),end="")
            else:
                print(" 0",end="")
        print("")
    if b < 4:
        print("#"*20)

Measured memory_bytes: 7696
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRepsept solver = new CRepsept();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRepsept {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.readInt();
            int st = 7 % k;
            for (int i = 1; i <= k; i++) {
                if (st == 0) {
                    System.out.println(i);

                    return;
                }

                st = (st * 10 + 7) % k;
            }

            System.out.println(-1);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32212
#include <iostream>
#include <map>

using namespace std;

int main(void){
	int n;
	while(cin >> n && n){
		char x,y;
		map<char,char> m;
		for(int i=0;i<n;i++){
			cin >> x >> y;
			m[x] = y;
		}
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> x;
			if(m.find(x) == m.end()){
				cout << x;
			}else{
				cout << m[x];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 900
#include<iostream>
#include<cctype>
#include<stdio.h>
using namespace std;
int main(){
    char s;
    while(scanf("%c", &s) != EOF){

        if(islower(s)){
            s = toupper(s);
        }else if(isupper(s)){
            s = tolower(s);
        }
        cout << s;
    }
    

    return 0;
}


Measured memory_bytes: 3124
A, B, H, M = gets.chomp.split.map(&:to_f)

theta = Math::PI * 2 * (H / 12.0 + ((M / 60.0) / 12.0) - (M / 60.0))

puts Math.sqrt(( A**2 + B**2 - (2 * A * B * Math.cos(theta)) ).abs)

Measured memory_bytes: 14756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(){
	int N;
	cin >> N;
	vector<int> x1(N),y1(N),x2(N),y2(N),x(2*N),y(2*N);
	for(int i=0;i<N;++i){
		cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
		x[2*i] = x1[i];x[2*i+1] = x2[i];
		y[2*i] = y1[i];y[2*i+1] = y2[i];
	}

	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	x.erase(unique(x.begin(),x.end()),x.end());
	y.erase(unique(y.begin(),y.end()),y.end());

	int H = y.size();
	int W = x.size();
	
	int coo[H][W]={};
	for(int i=0;i<N;i++){
		int a1,a2,b1,b2;
		a1 = (lower_bound(x.begin(),x.end(),x1[i])-x.begin());
		b1 = (lower_bound(y.begin(),y.end(),y1[i])-y.begin());
		a2 = (lower_bound(x.begin(),x.end(),x2[i])-x.begin());
		b2 = (lower_bound(y.begin(),y.end(),y2[i])-y.begin());
		coo[b1][a1]++;
		coo[b2][a2]++;
		coo[b2][a1]--;
		coo[b1][a2]--;
	}
	for(int i=0;i<H;i++){
		for(int j=1;j<W;j++){
			coo[i][j] += coo[i][j-1]; 
		}
	}
	for(int i=0;i<W;i++){
		for(int j=1;j<H;j++){
			coo[j][i] += coo[j-1][i]; 
		}
	}
	ll ans = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(coo[i][j]){
				ll xl = x[j+1] - x[j];
				ll yl = y[i+1] - y[i];
				ans += xl*yl;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 65652
#include<iostream>
#include<stdio.h>
#include <algorithm>
using namespace std;
int main(){
  int A,B,C,D,E;
  cin>>A>>B;
  C=A+B;
  D=A-B;
  E=A*B;
  if(C>D){
        swap(C,D);
    }
    if(D>E){
        swap(D,E);
    }
    if(C>D){
        swap(C,D);
    }
  cout<<E<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long maxValue = (long) Math.pow(10, 18);

		int n = sc.nextInt();
		long multi = 1;
		boolean isOk = true;
		boolean isZero = false;
		for (int i = 0; i < n; i++) {
			long m = sc.nextLong();

			if (m == 0) {
				multi = 0;
				isZero = true;
				break;
			} else if (maxValue / m < multi) {
				isOk = false;
			}
			multi *= m;
		}

		if (isOk || isZero) {
			System.out.println(multi);
		} else {
			System.out.println(-1);
		}
	}
}


Measured memory_bytes: 59804
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0 0")) {
            String[] st = input.split(" ");
            int y = Integer.parseInt(st[0]);
            int x = Integer.parseInt(st[1]);
            for (int i = 0; i < y; i++) {
                for (int j = 0; j < x; j++) {
                    if (i == 0 || j == 0 || i == (y - 1) || j == (x - 1)) {
                        bw.append("#");
                    } else {
                        bw.append(".");
                    }
                }
                bw.newLine();
            }
            bw.newLine();
        }
        bw.flush();
    }


}


Measured memory_bytes: 25764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}


int main() {
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2 << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long int M, A, R, C, H;
  M = 0;
  A = 0;
  R = 0;
  C = 0;
  H = 0;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S.at(0) == 'M') M++;
    else if (S.at(0) == 'A') A++;
    else if (S.at(0) == 'R') R++;
    else if (S.at(0) == 'C') C++;
    else if (S.at(0) == 'H') H++;
  }
  long long int ans;
  ans = M * A * R + M * A * C + M * A * H + M * R * C + M * R * H 
    + M * C * H + A * R * C + A * R * H + A * C * H + R * C * H;
  cout << ans << endl;
}

Measured memory_bytes: 256