akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n, d, x;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> d >> x;
  FOR(i, 0, n){
    int a;
    cin >> a;
    x += 1+(d-1)/a;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int d[n+1][n+1];
  for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)d[i][j]=-1;
  int s[n+1][n+1];
  for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)s[i][j]=10000000;
  int a[m],b[m],c[m];
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
    d[a[i]][b[i]]=c[i];
    d[b[i]][a[i]]=c[i];
  }
  for(int i=1;i<=n;i++){
    s[i][i]=0;
    bool used[n+1];
    for(int j=0;j<=n;j++)used[j]=false;
    for(;;){
      int v=0;
      s[i][0]=10000000;
      for(int j=1;j<=n;j++){
        if(used[j]==false)if(s[i][j]<s[i][v])v=j;
      }
      if(v==0)break;
      used[v]=true;
      for(int j=1;j<=n;j++){
        if(d[v][j]>=0){
          s[i][j]=min(s[i][j],s[i][v]+d[v][j]);
        }
      }
    }
  }
  int ans=0;
  for(int i=0;i<m;i++){
    int f=a[i];
    int se=b[i];
    for(int j=1;j<=n;j++){
      if(s[f][j]+s[j][se]<c[i]){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 384
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string day;
    cin >> day;
    if (day == "SUN" ) cout << "7" << endl;
    if (day == "MON") cout << "6" << endl;
    if (day == "TUE") cout << "5" << endl;
    if (day == "WED") cout << "4" << endl;
    if (day == "THU") cout << "3" << endl;
    if (day == "FRI") cout << "2" << endl;
    if (day == "SAT") cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define s second
#define f first
using namespace std;
typedef pair<int,int> P;

struct D{
  int num,used,color;
  D(){};
  D(int a,int b,int c){
    num=a,used=b,color=c;
  }
};
map<P,D> Futon;
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};
char dir;
bool ans;

void dfs(int y,int x){
  map<P,D>::iterator F=Futon.find(P(y,x));
  (*F).s.used=1;
  for(int i=0;i<4;i++){
    int ny=y+dy[i],nx=x+dx[i];
    if(!Futon.count(P(ny,nx)))continue;
    map<P,D>::iterator F1=Futon.find(P(ny,nx));
    if((*F1).s.color==-1){
      if((*F1).s.num==(*F).s.num)
	(*F1).s.color=!(*F).s.color;
      else
	(*F1).s.color=(*F).s.color;
    }else{
      if((*F1).s.num==(*F).s.num){
	if((*F1).s.color==(*F).s.color)
	  ans=false;
      }
      else if((*F1).s.color!=(*F).s.color)
	ans=false;
    }
    if(!(*F1).s.used)dfs(ny,nx);
  }
}

int main(){
  int n,x,y;
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>x>>y>>dir;
      Futon[P(y,x)]=D(i,0,-1);
      if(dir=='x')Futon[P(y,x+1)]=D(i,0,-1);
      else Futon[P(y+1,x)]=D(i,0,-1);
    }
    ans=true;
    map<P,D>::iterator ite=Futon.begin();
    while(ite!=Futon.end()){
      if(!(*ite).s.used){
	(*ite).s.color=0;
	dfs((*ite).f.f,(*ite).f.s);
      }
      ite++;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    Futon.clear();
  }
  return 0;
}

Measured memory_bytes: 8712
//#include <atcoder/mincostflow>
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

//constexpr int INF = 100 * 100;

typedef pair<int,ll> PIL;
const int MAXV=2550;
const int MAXE=MAXV * 5;
const int INF=(int)1e9+10;
const ll cINF=(ll)1e18+10;
// ^ config those things

struct E {
	int to,ca,cost;//capacity, cost
	E(int t=0,int c=0,int co=0):to(t),ca(c),cost(co) {}
}eg[2*MAXE];
int N, M;

// source:0  sink:n-1
struct Flow {
	VI e[MAXV];
	int ei,n;
	void init(int n_) {
		n=n_;
		ei=0;
		for(int i=0;i<n;i++)
			e[i]=VI();
	}
	void add(int a,int b,int c,int d) {
          debug("%d (%d, %d) -> %d (%d, %d)  %d %d\n", a, (a - 1) / M, (a - 1) % M, b, (b - 1) / M, (b - 1) % M, c, d);
		//a to b ,maxflow=c, cost=d
		eg[ei]=E(b,c,d);
		e[a].PB(ei);
		ei++;
		eg[ei]=E(a,0,-d);
		e[b].PB(ei);
		ei++;
	}
	
	PII d[MAXV]={};
	bool inq[MAXV]={};
	queue<int> que;
	VI pe;
	bool SPFA() {
		fill(d, d+n, MP(INF,INF));
		d[0]=MP(0,0);
		que.push(0);
		inq[0]=1;
		while(!que.empty()) {
			int v=que.front(); que.pop();
			inq[v]=0;
			for(int id:e[v]) {
				if(eg[id].ca>0 && MP(d[v].F+eg[id].cost,d[v].S+1)<d[eg[id].to]) {
					d[eg[id].to]=MP(d[v].F+eg[id].cost,d[v].S+1);
					if(!inq[eg[id].to]) {
						que.push(eg[id].to);
						inq[eg[id].to]=1;
					}
				}
			}
		}
		return d[n-1].F<INF;
	}
	PIL go(ll cb=cINF) {
		// cost_bound
		if(!SPFA()) return MP(0,0);
		pe.clear();
		int fl=INF;
		for(int v=n-1;v!=0;) {
			for(int id:e[v]) {
				int u=eg[id].to;
				const E& t=eg[id^1];
				if(t.ca>0 && MP(d[u].F+t.cost,d[u].S+1)==d[v]) {
					fl=min(fl, t.ca);
					v=u;
					pe.PB(id^1);
					break;
				}
			}
		}
		if(d[n-1].F>0) fl=min(1ll*fl, cb/d[n-1].F);
		for(int id:pe) {
			eg[id].ca-=fl;
			eg[id^1].ca+=fl;
		}
		return MP(fl, 1ll*fl*d[n-1].F);
	}
	PIL max_flow() {
		PIL ans=MP(0,0),temp;
		while((temp=go()).F>0) {
			ans.F+=temp.F;
			ans.S+=temp.S;
		}
		return ans;
	}
} flow;

int main() {
  scanf("%d%d", &N, &M);
  vector<string> in;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    in.PB(S);
  }
  //atcoder::mcf_graph<int, int> g(N * M + 2);
  flow.init(N * M + 2);
  const int s = 0;
  const int t = N * M + 1;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      debug("---- %d, %d\n", i, j);
      if (in[i][j] == '#')
        continue;
      const int id = i * M + j + 1;
      if (in[i][j] == 'o') {
        flow.add(s, id, 1, 0);
        cnt++;
      }
      flow.add(id, t, 1, 0);
      if (i + 1 < N && in[i + 1][j] != '#')
        flow.add(id, (i + 1) * M + j + 1, INF, -1);
      if (j + 1 < M && in[i][j + 1] != '#')
        flow.add(id, i * M + (j + 1) + 1, INF, -1);
    }
  }
  auto res = flow.max_flow();
  assert(res.F == cnt);
  printf("%d\n", -res.S);
  return 0;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;

    }

    public static string Solve()
    {
        string[] S = Read().Split('/');
        int yyyy = int.Parse(S[0]);
        int mm = int.Parse(S[1]);
        int dd = int.Parse(S[2]);
        if(yyyy<=2019 && mm <= 4 && dd <= 30)
        {
            return "Heisei";
        }
        return "TBD";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define mod 1000000007
#define inf 1000000000000000000
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll x,a;
	cin>>x>>a;
	if(x<a)
		cout<<0<<endl;
	else
		cout<<10<<endl;
	return 0;
}





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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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;
}
int gcd(int x, int y) { return (y == 0 ? x : gcd(y, x % y)); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;
  if (N == 1 and M == 1) {
    cout << (S == T ? 1 : -1) << endl;
    return 0;
  }
  int L = lcm(N, M);
  dump(L);
  int a = L / N, b = L / M;
  int l = lcm(a, b);
  for (int i = 0; i * l / a + 1 < N and i * l / b + 1 < M; i++) {
    if (S[i * l / a] != T[i * l / b]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << L << endl;

  return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_A

??§????????¨?°????????????\?????????

????????????????????????????°?????????¨??§???????????\????????????????????°????????????????????????????????????
"""

if __name__ == '__main__':
    # ???????????????????????\???
    raw_input = input()

    # ??§??????????°????????????\??????????????????
    print(raw_input.swapcase())

Measured memory_bytes: 7320
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
int main() {
    ll n, k, a[15], sum, ans = INF; cin >> n >> k;
    rep(i, n) cin >> a[i];
    rep(i, (1 << n)) {
        int cnt = 0;
        rep(j, n) {
            if (i & (1 << j))cnt++;
        }
        if (cnt == k) {
            sum = 0; ll h = a[0];
            req(l, n - 1) {
                if (i & (1 << l)) {
                    sum += max((ll)0, h - a[l] + 1);
                    h = max(h + 1, a[l]);
                }
                else h = max(h, a[l]);
            }
            ans = min(ans, sum);
        }
    }cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//forとか代入しない場合は++iでもi++でも同じ


int N;
ll W,weight[110],value[110];

// DP テーブル
ll dp[110][100100] = {0};//maxがほしいのでdp[0]の部分は0で初期化

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> weight[i] >> value[i];
    }

    for (int i = 0; i < N; i++)
    {
        
        //これはweightを小さい方から求めることによってsubproblemに分解してる

        //縦軸がiで横がWeightだとすると、個数固定して、weightをひとまず最後まで上げてる
        for (int sum_w = 0; sum_w <= W; sum_w++)
        {
            //常にsum_wを超えないように選ぶ
        
            //i番目の品物を選ぶ
            if(sum_w - weight[i] >= 0){
                //この条件はsum_wを超えないという条件
                //現在i+1目で、重さsum_w条件のが欲しい、sum_wになるためにはi個目から、追加しないか、追加するならweightはsum_w-weight[i]からweight[i]をたすことになる
                chmax(dp[i+1][sum_w],dp[i][sum_w -weight[i]] + value[i]);
            }
            //選ばない
            chmax(dp[i+1][sum_w],dp[i][sum_w]);
        }
        
    }
    cout << dp[N][W] << endl;
    
    
}




Measured memory_bytes: 79360
#include<stdio.h>
int main(void){
  int S,a,b,c,d;
  scanf("%d",&S);
  a=S/1000;
  b=(S%1000)/100;
  c=(S%100)/10;
  d=(S%10);
  if(a==b)printf("Bad");
  else if(b==c)printf("Bad");
  else if(c==d)printf("Bad");
  else printf("Good");
  
 return 0;
} 

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  int count = 0;
  vector<int> tmp(n);
  bool finished = false;
  while (true) {
    for (int i = 0; i < n; i++) {
      tmp.at(i) = vec.at(i) % 2;
      if (tmp.at(i) != 0) {
        finished = true;
        break;
      }
    }
    if (finished) {
      break;
    }
    count++;
    for (int i = 0; i < n; i++) {
      vec.at(i) /= 2;
      //cout << vec.at(i) << endl;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
use std::io::{BufRead, Write};
use std::io;
use std::cmp;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let n = s.trim().parse::<u64>().unwrap();
    for i in (1..(n as f64).sqrt().floor() as u64 + 1).rev() {
        if n % i == 0 {
            writeln!(output,
                     "{}",
                     cmp::max((i as f64).log10() as u64 + 1,
                              ((n / i) as f64).log10() as u64 + 1))
                    .unwrap();
            break;
        }
    }
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("10000\n", "3\n");
    }
    #[test]
    fn case2() {
        test("1000003\n", "7\n");
    }
    #[test]
    fn case3() {
        test("9876543210\n", "6\n");
    }
}


Measured memory_bytes: 4352
import java.math.BigInteger;
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    static BigInteger dp[][] = new BigInteger[901][901];

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        PriorityQueue<Integer> set = new PriorityQueue<>(N, Integer::compareTo);
        for (int i :IntStream.range(0, N).toArray()){
            int tmp = scan.nextInt();
            if (tmp == K) {
                System.out.println("POSSIBLE");
                return;
            }
            set.add(tmp);
        }
        List<Integer> A = new ArrayList<>();
        while (!set.isEmpty()) {
            A.add(set.poll());
        }
        if(A.get(A.size() - 1) < K) {
            System.out.println("IMPOSSIBLE");
            return;
        }

        int min = A.get(0);
        if(min == 1) {
            System.out.println("POSSIBLE");
            return;
        }

        for (int i :IntStream.range(1, N).toArray()){
            if (f(A.get(i), min, K) != 0) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }

    static int f(int x, int y, int ans) {
        int tmp = x % y;
        if (tmp == 0) {
            if (ans % y == 0) {
                return 1;
            }
            return 0;
        }
        if (tmp == 1) {
            return 1;
        }
        if (tmp == ans) {
            return 1;
        }
        return f(y, tmp, ans);
    }

}


Measured memory_bytes: 65148
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)


count=0
ans=[]
flag=0
for i in range(1,n):
    if a[i]==a[i-1] and flag==1:
        flag=0


    elif a[i]==a[i-1] and flag==0:
        count += 1
        ans.append(a[i])
        flag=1

    elif a[i] != a[i-1]:
        flag=0

    if count==2:
        print(ans[0]*ans[1])
        exit()


print(0)

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

using ll = long long;

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

    ll N;
    cin >> N;
    ll res = 0;
    for (ll i = 1; i * i < N; ++i) {
        ll dev = (N - i) / i;
        if ((N - i) % i == 0 && dev != i) {
            res += dev;
        }
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int keta(int num) {
    int t;
    t = 0;
    while (0<num) {
        t += num % 10;
        num /= 10;
    }
    return t;
}

int main(void) {
    int n, a, b, s, total;
    cin >> n >> a >> b;
    total = 0;
    for (int i = 1; i <= n; i++) {
        s = keta(i);
        if (s >= a && s <= b) {
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}


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


long long int  func(long long int n, long long int r) 
{ 

 
  long long int p = 1, k = 1; 

  
  if (n - r < r) 
    r = n - r; 

  if (r != 0) { 
    while (r) { 
      p = 1LL*p*n; 
      k = 1LL*k*r; 

      // gcd of p, k 
      long long int m = __gcd(p, k); 

      // dividing by gcd, to simplify product 
      // division by their gcd saves from the overflow 
      p /= m; 
      k /= m; 

      n--; 
      r--; 
    } 
  } 

  else
    p = 1; 

   return p;
} 


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    
    long long int num;
    cin>>num;

      long long int ans=0;
      for(int i=2;i<1000010;i++)
      {
        int curr=0;
        while(num%i==0)
        {
          curr++;
          num/=i;
        }
        for(int j=1;j<=1000;j++)
        {
          if(curr<j)break;
          ans++;
          curr-=j;
        }
      }
      if(num>1)ans++;
      cout<<ans<<endl;

    //cout<<ans2<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,k,m=1e9;
    cin>>n>>k;
    vector<ll> h(n);
    for(ll i=0;i<n;i++) cin>>h[i];
    sort(all(h));
    for(ll i=0;i+k-1<n;i++){
        m=min(m,h[i+k-1]-h[i]);
    }
    cout<<m<<endl;
    return 0;
}

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

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define MODADDSET(d) if ((d) >= MOD) d -= MOD;
#define MODADDWHILESET(d) while ((d) >= MOD) d -= MOD;

#define cint(d) scanf("%d", &d)
#define cint2(a, b) scanf("%d %d", &a, &b)
#define cint3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define cint4(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)

#define clong(d) scanf("%lld", &d)
#define clong2(a, b) scanf("%lld %lld", &a, &b)
#define clong3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define clong4(a, b, c, d) scanf("%lld %lld %lld %lld", &a, &b, &c, &d)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

using namespace std;

typedef long long int slong;

#define MAXN 100000
#define LOGN 16

long long int power(int base, int exp)
{
	if (exp == 0)
	{
		return 1;
	}
	else
	{
		long long int ans;
		
		if (exp % 2)
		{
			ans = base*power(base, exp - 1);
		}
		else
		{
			ans = power(base, exp/2);
			ans *= ans;
		}
		
		MODSET(ans);
		
		return ans;
	}
}

long long int power(int base, int exp, long long int mod)
{
	if (exp == 0)
	{
		return 1;
	}
	else
	{
		long long int ans;
		
		if (exp % 2)
		{
			ans = base*power(base, exp - 1, mod);
		}
		else
		{
			ans = power(base, exp/2, mod);
			ans *= ans;
		}
		
		if (ans >= mod)
		{
			ans %= mod;
		}
		
		return ans;
	}
}

int arr[MAXN+5];

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int k, i, j, d, ans;
	string str;
	
	cin >> str;
	cint(k);
	
	for (i = 0; i < str.size() - 1; i++)
	{		
		if (str[i] == 'a')
		{
			continue;
		}
		
		//to move to a
		int moves = ('z' - str[i] + 1);
		
		if (k >= moves)
		{
			k -= moves;
			str[i] = 'a';
		}
	}
	
	str[str.size() - 1] = ((str[str.size() - 1] - 'a') + k) % 26 + 'a';
	
	cout << str;
	
    return 0;
}


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

int main() {
	int L;
	cin >> L;
	int N = 20;
	vector<pair<pair<int, int>, int>> edges;
	for (int i = 2; i + 1 <= N; i++) {
		edges.emplace_back(pair<int, int>(i, i + 1), 0);
		edges.emplace_back(pair<int, int>(i, i + 1), 1 << (N - i - 1));
	}
	int st = 0;
	for (int i = 2; i <= N; i++) {
		while ((L - st) >= (1 << (N - i))) {
			edges.emplace_back(pair<int, int>(1, i), st);
			st += (1 << (N - i));
		}
	}
	cout << N << ' ' << edges.size() << '\n';
	for (auto it : edges) {
		assert(it.first.first < it.first.second);
		cout << it.first.first << ' ' << it.first.second << ' ' << it.second << '\n';
	}

	return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  unordered_map<ll, int> count;
  ll a;
  REP(i, N) {
    cin >> a;
    if (count.find(a) == count.end()) {
      count.insert(make_pair(a, 1));
    } else {
      ++count.at(a);
    }
  }

  int ans = 0;
  for (auto const &it : count) {
    if (it.second % 2 == 1) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4388
n = int(input())
a = list(map(int, input().split()))
cnt1 = 0
s = 0
swc = 1
for i in a:
	s += i
	if swc == 1:
		swc = 0
		if s > 0:
			continue
		else:
			cnt1 += 1-s
			s = 1
	else:
		swc = 1
		if s < 0:
			continue
		else:
			cnt1 += s+1
			s = -1
swc = 0
cnt2 = 0
s= 0
for i in a:
	s += i
	if swc == 1:
		swc = 0
		if s > 0:
			continue
		else:
			cnt2 += 1-s
			s = 1
	else:
		swc = 1
		if s < 0:
			continue
		else:
			cnt2 += s+1
			s = -1
print (min(cnt1, cnt2))


Measured memory_bytes: 14468
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <functional>
#include <cstring>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <iomanip>
#include <fstream>
#include <string>
#include <iterator>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, N) FOR(i, 0, N)
#define SZ(x) ((int)(x).size())

const int MAXN = 2007, INF = 1007;

int main()
{
	int H, W, a[MAXN][MAXN], dp[MAXN][MAXN], d1[MAXN][MAXN], d2[MAXN][MAXN], ans;
	string S[MAXN];
	stack <int> s;
	cin >> H >> W;
	REP(i, H) cin >> S[i];
	REP(i, MAXN) REP(j, MAXN){
		a[i][j] = 1;
		dp[i][j] = 0;
	}
	REP(i, H - 1) REP(j, W - 1){
		int cb = 0;
		REP(di, 2) REP(dj, 2)
			if (S[i + di][j + dj] == '#') ++cb;
		a[i + 1][j + 1] = (cb & 1);
	}
	FOR(i, 1, H) FOR(j, 1, W){
		if (a[i][j] == 0)
			dp[i][j] = dp[i - 1][j] + 1;
	}
	FOR(i, 1, H){
		while (!s.empty()) s.pop();
		FOR(j, 1, W){
			while (!s.empty() && dp[i][s.top()] >= dp[i][j])
				s.pop();
			if (s.empty()) d1[i][j] = 0;
			else d1[i][j] = s.top();
			s.push(j);
		}
		while (!s.empty()) s.pop();
		for (int j = W - 1; j >= 1; --j){
			while (!s.empty() && dp[i][s.top()] >= dp[i][j])
				s.pop();
			if (s.empty()) d2[i][j] = W;
			else d2[i][j] = s.top();
			s.push(j);
		}
	}
	ans = H;
	FOR(i, 1, H) FOR(j, 1, W)
		ans = max(ans, (dp[i][j] + 1)*(d2[i][j] - d1[i][j]));
	cout << ans;
	//cout << endl; system("pause");//please
	return 0;
}

Measured memory_bytes: 67200
# coding:utf-8

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


def inpl(): return list(map(int, input().split()))


# aのp乗を求めるアルゴリズム
# MOD版
# O(logp)
def pow_mod(a, p):
    if p == 0: return 1
    if p % 2 == 0:
        half_p = p // 2
        half = pow_mod(a, half_p)

        return half * half % MOD
    else:
        return a * pow_mod(a, p - 1) % MOD


# 組み合わせnCrを求めるアルゴリズム
# 逆元を使って計算
# MOD版
def cmb_mod(n, r):
    # 5C3 -> 5C2
    if r > n - r: return cmb_mod(n, n - r)
    ans_mul = 1
    ans_div = 1
    for i in range(r):
        ans_mul *= n - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD

    # ans_mul / ans_divをしたい
    # ans_divの逆元を使って求める
    ans = ans_mul * pow_mod(ans_div, MOD - 2) % MOD
    return ans


N, M = inpl()
ans = 1
i = 2
while i * i <= M:
    if M % i == 0:
        cnt = 0
        while M % i == 0:
            cnt += 1
            M //= i
        ans *= cmb_mod(N - 1 + cnt, cnt)
        ans %= MOD
    i += 1

if M != 1:
    ans *= cmb_mod(N - 1 + 1, 1)
    ans %= MOD
print(ans)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        List<Integer> x = IntStream.range(0, n)
                .map(i -> scanner.nextInt())
                .boxed()
                .collect(Collectors.toList());

        List<Integer> xSorted = new ArrayList<>(x);
        Collections.sort(xSorted);

        int m1 = xSorted.get(n / 2 - 1), m2 = xSorted.get(n / 2);
        for (Integer i : x)
            System.out.println(i > m1 ? m1 : m2);
    }
}

Measured memory_bytes: 97096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000;
int n, m, co[maxn + 10], cnt[2], tot;
vector<int> g[maxn + 10];

bool dfs(int p) {
	bool fd = 0;
	for (int i = 0; i < (int)g[p].size(); ++i) {
		int e = g[p][i];
		if (!co[e]) {
			co[e] = 3 - co[p]; fd |= dfs(e);
		} else if (co[p] == co[e]) fd = 1;
	}
	return fd;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int l, r; scanf("%d%d", &l, &r);
		g[l].push_back(r);
		g[r].push_back(l);
	}
	for (int i = 1; i <= n; ++i)
		if (!co[i]) {
			if ((int)g[i].size() > 0) {
				co[i] = 1;
				++cnt[dfs(i)];
			} else ++tot;
		}
	printf("%lld", 1ll * tot * tot + 2ll * (n - tot) * tot + 1ll * cnt[0] * cnt[0]  + 1ll * (cnt[0] + cnt[1]) * (cnt[0] + cnt[1]));
}


Measured memory_bytes: 10880
#include <stdio.h>
#define N 100000
#define NIL -1

typedef struct node{
  int parent;
  int left;
  int right;
}Node;

Node T[N];

int n;

int Calc_depth(int x){
  if(T[x].parent == NIL) return 0;
  return Calc_depth(T[x].parent) + 1;
}

void type_pri(int y){
  if(T[y].parent == - 1) printf("root, ");
  else if(T[y].left == NIL) printf("leaf, ");
  else printf("internal node, ");
}

void print_chil(int z){
  int tmp;
  printf("[");
  tmp = T[z].left;
  while(tmp != NIL){
    printf("%d",tmp);
    if(T[tmp].right != NIL) printf(", ");
    tmp = T[tmp].right;
  }
  printf("]");
}

void print(void){
  int i;
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,Calc_depth(i));
    type_pri(i);
    print_chil(i);
    printf("\n");
  }
}

int main()
{
  int i,id,k,j,num,root,l;
  scanf("%d",&n);
  for(i = 0; i < n;i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  for(i = 0; i < n;i++){
    scanf("%d%d",&id,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&num);
      if(j == 0) T[id].left = num;
      else T[l].right = num;
      l = num;
      T[num].parent = id;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == NIL) root = i;
  }
  print();
  return 0;    
}



Measured memory_bytes: 2912
#include <bits/stdc++.h>
#define pb push_back
#define sc1(n) scanf("%lld",&n)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define MX 100000
using namespace std;

typedef long long int ll;
typedef unsigned long long ul;

ll n,w;
ll we[105];
ll val[105];
ll dp[105][100005];
ll need;

ll solve(ll pos,ll sum)
{
    if(sum>=need)
        return 0;
    if(pos>n)
        return INT_MAX;

    if(dp[pos][sum]!=-1)
    {
        return dp[pos][sum];
    }
    ll ret1=0;
    ll ret2=0;
    ret1=we[pos]+solve(pos+1,sum+val[pos]);
    ret2=solve(pos+1,sum);

    return dp[pos][sum]=min(ret1,ret2);
}

int main()
{
    sc2(n,w);
    ll hi=0;
    for(ll i=1; i<=n; i++)
    {
        sc2(we[i],val[i]);
        hi+=val[i];
    }
    ll ans=0;
    ll lo=0;
    while(lo<=hi)
    {
        memset(dp,-1,sizeof dp);
        ll mid=(lo+hi)/2;
        need=mid;
        ll now=solve(1,0);
        //cout<<need<<" "<<now<<endl;
        if(now<=w)
        {
            ans=max(ans,mid);
            lo=mid+1;
        }
        else
            hi=mid-1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 82304
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> al = new ArrayList<>();
		
		double tmp;
		while(sc.hasNext()) {
			tmp = sc.nextDouble();
			
			if(tmp <= 48)		al.add(1);
			else if(tmp <= 51)	al.add(2);
			else if(tmp <= 54)	al.add(3);
			else if(tmp <= 57)	al.add(4);
			else if(tmp <= 60)	al.add(5);
			else if(tmp <= 64)	al.add(6);
			else if(tmp <= 69)	al.add(7);
			else if(tmp <= 75)	al.add(8);
			else if(tmp <= 81)	al.add(9);
			else if(tmp <= 91)	al.add(10);
			else				al.add(11);
			
		}
		
		for(int i : al) {
			if(i == 1)	System.out.println("light fly");
			if(i == 2)	System.out.println("fly");
			if(i == 3)	System.out.println("bantam");
			if(i == 4)	System.out.println("feather");
			if(i == 5)	System.out.println("light");
			if(i == 6)	System.out.println("light welter");
			if(i == 7)	System.out.println("welter");
			if(i == 8)	System.out.println("light middle");
			if(i == 9)	System.out.println("middle");
			if(i == 10)	System.out.println("light heavy");
			if(i == 11)	System.out.println("heavy");
		}
	}
}

Measured memory_bytes: 27996
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int n,d;
  cin>>n>>d;
 
  vector<vector<int>> x(n, vector<int>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>x.at(i).at(j);
    }
  }
  
  int64_t cnt=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int64_t sum=0;
      for(int k=0;k<d;k++){
        sum+=(x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
      }
      int64_t dist = (int64_t)sqrt(sum);
      if(dist*dist==sum)
        cnt++;
    }
  }
  
  cout<<cnt<<endl;
 
  return 0;
}
 

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i);

str = "0"*n
done = Array.new(n,false)

m.times do
  s, c =  gets.chomp.split(" ").map(&:to_i);
  if (s == 1 && c==0 && n>1) || (done[s-1] && str[s-1].to_i != c)
    puts "-1"
    exit 0
  end
  str[s-1] = c.to_s
  done[s-1] = true
end

str[0] = "1" if str[0].to_i == 0 && n > 1

puts str.to_i

Measured memory_bytes: 1788
#include <cstdio>
#include <algorithm>
#define MAX 100000
#define INF 2e9

struct Card{
	char suit;
	int val;
};

Card L[MAX/2+2],R[MAX/2+2];

void merge(Card A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int i,j;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1].val=R[n2].val=INF;
	i=j=0;
	for(int k=left;k<right;k++){
		if(L[i].val<=R[j].val){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	}
}

void mergeSort(Card A[],int n,int left,int right){
	int mid;
	if(left+1<right){
		mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int partition(Card A[],int n,int p,int r){
	Card x=A[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(A[j].val<=x.val){
			i++;
			std::swap(A[i],A[j]);
		}
	}
	std::swap(A[r],A[i+1]);
	return i+1;
}

void quickSort(Card A[],int n,int p,int r){
	if(p<r){
		int q=partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}

int main(void){
	int n,v;
	Card A[MAX],B[MAX];
	char S[10];
	bool flag=true;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s %d",S,&v);
		A[i].suit=B[i].suit=S[0];
		A[i].val=B[i].val=v;
	}
	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);
	for(int i=0;i<n;i++){
		if(A[i].suit!=B[i].suit)flag=false;
	}
	printf("%s\n",flag?"Stable":"Not stable");
	for(int i=0;i<n;i++){
		printf("%c %d\n",B[i].suit,B[i].val);
	}
	return 0;
}


Measured memory_bytes: 4900
// ---------- begin chmin, chmax ----------
trait ChangeMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}

impl<T: PartialOrd> ChangeMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
// ---------- end chmin, chmax ----------

use proconio::*;

fn run() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut dp = vec![1000; n + 1];
    for i in 0..n {
        let v = dp[i];
        let d = v / a[i];
        for j in i..n {
            let v = v - d * a[i] + d * a[j];
            dp[j + 1].chmax(v);
        }
    }
    let ans = dp.into_iter().max().unwrap();
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 2144
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n];
    int hoge[n];
    long long ans=0;
    double b=0.0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        hoge[i] = a[i]-(i+1);
    }
    sort(hoge,hoge+n);
    if(n%2==1) b = hoge[(n-1)/2];
    else b = (hoge[n/2] + hoge[n/2-1])/2;
    for(int j=0;j<n;j++){
        ans += abs(a[j]-((j+1)+b));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int to_num(string s){
	return atoll(s.c_str());
}
string to_str(int num){
	string str = "";
	rep(i,4){
		str.pb((num%10)+'0');
		num /= 10;
	}
	reverse(all(str));
	return str;
}

signed main(){
	while(1){
		string str;
		cin >> str;
		if(str == "0000")break;
		if(str[0] == str[1] and str[1] == str[2] and str[2] == str[3])
		{cout << "NA" << endl;continue;}
		
		int ans = 0;
		while(1){
			if(str == "6174")break;
			string s1 = str, s2 = str;
			sort(all(s1), greater<int>());
			sort(all(s2));
			int num = to_num(s1)-to_num(s2);
			str = to_str(num);
			ans++;
		}
		printf("%lld\n", ans);
		
	}
	return 0;
}





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

int main(){
    int k;
    cin >> k;
    vector<ll>vec(k+1);
    vec[1] = 7%k;
    for(int i=2;i<=k;i++){
        vec[i] = (10*vec[i-1] + 7)%k;
    }

    for(int i=1;i<=k;i++){
        if(vec[i] == 0){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 11112
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
import java.lang.Math;
import java.util.HashMap;
public class Main {
	public static int useBs(int[] arr, int targetValue) {	
		int a =  Arrays.binarySearch(arr, targetValue);
		if(a >=0 && a<arr.length)
			return a;
		else
			return -1;
	}
	public static void printArray(int []a) {
		for(int i=0;i<a.length;i++) {
			System.out.println(a[i]+" ");
		}
		System.out.println();
	}
	public static void printArrayLong(long []a) {
		for(int i=0;i<a.length;i++) {
			System.out.println(a[i]+" ");
		}
		System.out.println();
	}
	static boolean isPalindrome(String s) {
		int l=s.length();
		for(int i=0;i<l/2;i++)
		{
			if(s.charAt(i)!=s.charAt(l-i-1))
				return false;
		}
		return true;
	}
	static String revString(String str)
	{
		return new StringBuffer(str).reverse().toString();
	}
	static String sortString(String s) {
		char a[]=s.toCharArray();
		Arrays.sort(a);
		return new String(a);
	}
	static int sumList(List<Integer>a) {
		return a.stream().mapToInt(Integer::intValue).sum();
	}
	static int sumArray(int []a) {
		int sum=0;
		for(int i=0;i<a.length;i++) {
			sum+=a[i];
		}
		return sum;
	}
    public static void main(String[]args) throws java.lang.Exception{
    	Scanner sc=new Scanner(System.in);
    	int t=1;
    	while(t-->0) {
    		int a[]=new int[5],ans=0;
    		for(int i=0;i<5;i++) {
    			a[i]=sc.nextInt();
    			if(a[i]==0)ans=i+1;
    		}
    		System.out.println(ans);
    	}
    	
    	
    }
}


Measured memory_bytes: 27052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

int main()
{
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      int k = N - i - j;
      if (10000*i + 5000*j + 1000*k == Y) {
        cout << i << ' ' << j << ' ' << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int>> *adj;
int *d;

void dijkstra() {
    priority_queue<pair<int, int>> PQ;
    int d[n], color[n];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0;
    PQ.push(make_pair(0, 0));

    while (!PQ.empty()) {
        pair<int, int> f = PQ.top();
        PQ.pop();

        int u = f.second;
        color[u] = BLACK;

        if (d[u] < f.first * (-1)) { continue; }

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) { continue; }
            if (d[u] + adj[u][j].second < d[v]) {
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        printf("%d %d\n", i, d[i]);
    }
}

int main() {
    scanf("%d", &n);
    adj = new vector<pair<int, int>>[n];
    for (int i = 0; i < n; i++) {
        int u, k;
        scanf("%d %d", &u, &k);
        for (int j = 0; j < k; j++) {
            int v, c;
            scanf("%d %d", &v, &c);
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 7552
import sys
sys.setrecursionlimit(10**9)

def main():
    N,K = map(int,input().split())
    A = [0] + sorted(list(map(int,input().split())))
    MOD = 10**9+7

    def get_fact(maxim,mod):
        maxim += 1
        fact = [0]*maxim

        fact[0] = 1
        for i in range(1,maxim):
            fact[i] = fact[i-1] * i % mod

        invfact = [0]*maxim
        invfact[maxim-1] =  pow(fact[maxim-1],mod-2,mod)

        for i in reversed(range(maxim-1)):
            invfact[i] = invfact[i+1] * (i+1) % mod

        return fact, invfact

    def powerful_comb(n,r,mod,fact,invfact):
        if n < 0 or n < r: return 0
        return fact[n] * invfact[r] * invfact[n-r] % mod

    ans = 0
    fact,invfact = get_fact(N,MOD)
    for i in range(K,N+1):
        ans += ((A[i]-A[N-i+1]) * powerful_comb(i-1,K-1,MOD,fact,invfact)) % MOD

    print(ans % MOD)
    # print(A)

if __name__ == "__main__":
  main()

Measured memory_bytes: 63472
A0 = list(map(int, input().split(" ")))
A1 = list(map(int, input().split(" ")))
A2 = list(map(int, input().split(" ")))

A = [A0, A1, A2]

M = [
    [False, False, False],
    [False, False, False],
    [False, False, False],
]

N = int(input())
for _ in range(N):
    b = int(input())
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if col == b:
                M[i][j] = True

flag = False
for row in M:
    if all(row):
        flag = True

for i in range(3):
    col = []
    for j in range(3):
        col.append(M[j][i])

    if all(col):
        flag = True

dia0 = []
dia1 = []
for i in range(3):
    dia0.append(M[i][i])
    dia1.append(M[i][2 - i])

if all(dia0):
    flag = True

if all(dia1):
    flag = True

if flag:
    print("Yes")
else:
    print("No")




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

int main() {
    lint n,l; cin >> n >> l;
    lint a[100100];
    lint aSum = 0;
    rep(i,n) {
        cin >> a[i];
        aSum += a[i];
    }
    vector<int> ans;
    /*
    deque<lint> dq;
    rep(i,n) dq.push_back(a[i]);
    lint dqLeft = 1;
    lint dqRight = n-1;
    lint cnt = n-1;
    lint cc = aSum;
    vector<lint> ans;
    while (cc >= l && cnt > 0) {
        lint f,b;
        f = dq.front();
        b = dq.back();
        if (f < b) {
            cc -= f;
            ans.push_back(dqLeft);
            dqLeft ++;
            dq.pop_front();
        }
        else {
            cc -= b;
            ans.push_back(dqRight);
            dqRight --;
            dq.pop_back();
        }
        cnt --;
    }
    */
    rep(i,n-1) {
        if (a[i] + a[i+1] >= l) {
            for (int j=0; j<i; j++) {
                ans.push_back(j+1);
            }
            for (int j=n-2; j>i; j--) {
                ans.push_back(j+1);
            }
            ans.push_back(i+1);
            break;
        }
    }
    if (ans.size() == 0) cout << "Impossible" << endl;
    else {
        cout << "Possible" << endl;
        for (auto i: ans) cout << i << endl; 
    }
    
}

Measured memory_bytes: 4604
import math
from collections import deque

s=input().split(" ")
a=s[0]
b=s[1]

s1=int(s[0])*s[1]
s2=int(s[1])*s[0]


if int(s[0])>int(s[1]):
    print(s1)
else:
    print(s2)

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

using namespace std;

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

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

//==================================

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

    ll N, K;
    cin >> N >> K;

    Vl H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    sort(H.begin(), H.end(), greater<ll>());

    ll ans = 0;

    for (int i = K; i < N; i++) {
        ans += H[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
def partsum(n,k):
  ret1 = n*(n+1)/2
  ret2 = (n-k+1)*(n-k)/2
  return ret1 - ret2

N, K = map(int,input().split())
ret  = 0
for k in range(K, N+2):
  ret += partsum(N,k) - partsum(k-1,k) + 1
print(int(ret)%(10**9+7))


Measured memory_bytes: 9132
n,k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(n):
    p[i] = (p[i] + 1)/2
ans = 0
tmp = 0
for i in range(k):
    tmp += p[i]
    ans += p[i]
for i in range(1,n - k + 1):
    tmp = tmp - p[i - 1] + p[i + k - 1]
    if ans < tmp:
        ans = tmp
print("{:.12f}".format(ans))


Measured memory_bytes: 25604
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e12+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

ll N, M;
//s N c M
//cを2K個K個のsに変換するとして

//s N+K c M-2K
//この時 min(N+K,(M-2K)/2)個ができる

//(N+K) * 2 = M-2K
//4K = M - 2N

//if (M <= 2N) M/2

int main() {
    cin >> N >> M;
    if (M <= 2 * N) {
        cout << M/2 << endl;
        return 0;
    }
    ll K = (M - 2 * N) / 4;

    cout << min(N+K,(M-2*K)/2) << endl;

}


Measured memory_bytes: 256
n = int(input())
t = 0
res = True
x, y = 0, 0
for i in range(n):
    t2, x2, y2 = map(int, input().split())
    dt = t2 - t
    #print("cur {0} {1} {2}".format(t, x, y))
    #print("d {0} {1} {2}".format(dt, x2, y2))
    #print("ju {0} {1} {2} {3}".format(abs(x-x2) + abs(y-y2), dt, (abs(x-x2) + abs(y-y2) - dt) % 2, 1))

    if abs(x-x2) + abs(y-y2) > dt or (abs(x-x2) + abs(y-y2) - dt) % 2 == 1:
        res = False
    t, x, y = t2, x2, y2
print("Yes" if res else "No")

Measured memory_bytes: 46312