akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for (ll i=a;i<n;i++)
#define loopm(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define Graph(n) vector < vector < ll > > (n,vector < ll >(0,0))
#define tr(container,it)\
for(auto it=container.begin();it!=container.end();it++)
#define SZ(x) ((int)(x).size())
typedef vector<long long> VI;
typedef long long ll;
typedef vector < vector < ll > > VII;
typedef pair<ll,ll> PII;
typedef double db;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    VI v(250);
    for(ll i=-125;i<125;i++)
    {
        v[i+125]=i*i*i*i*i;
       // cout<<v[i+125]<<"\n";;
    }
  //  cout<<121*121*121*121*121<<"\n";
    ll x;
    cin>>x;


    loop(i,0,v.size())
    {
         loop(j,0,v.size())
         {
            if(v[i]-v[j]==x)
            {
                cout<<(i-125)<<" "<<(j-125)<<"\n";
               goto here;
            }
         }
    }
    here:
        cout<<"";

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

double degreeToRadian(const double &degree) { return degree * PI / 180.0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double p = (double)(h * 60 + m) * 0.5;
    double q = (double)(h * 60 + m) * 6;
    double x = fabs(p - q);
    x = min(360.0 - x, x);
    double ans =
        (double)(a * a + b * b) - (double)(2 * a * b) * cos(degreeToRadian(x));
    ans = sqrt(ans);
    cout << fixed << setprecision(15);
    cout << ans << endl;
}

Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


int main(void) {
  ll i, j, k;
  
  ll a, b;
  cin >> a >> b;
  
  if(a*b%2==0) pt("Even");
  else pt("Odd");
  
  
  
}




Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int A, B, C; cin >> A >> B >> C;

    vi a(3); 
    a[0] = A; a[1] = B; a[2] = C;
    sort(a.begin(), a.end());

    int ans = 0;
    int d = a[2] - a[1];
    a[0] += d; a[1] += d;
    ans += d;
    d = a[1] - a[0];
    if (d % 2 == 0) ans += d / 2;
    else ans += d / 2 + 1 + 1;

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

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    char s[12]={};
    scanf("%s",s);
    int len=0;
    while(s[len]!=0)len++;
    int flag=1;
    REP(i,len){
        if(i%2==0)if(s[i]!='h')flag=0;
        if(i%2==1)if(s[i]!='i')flag=0;
    }
    if(len%2!=0)flag=0;
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import itertools
import sys


class CumulativeSum(object):

    def __init__(self, sequence):
        self.cumulative_sum = [0]
        self.cumulative_sum.extend(itertools.accumulate(sequence))

    def partial_sum(self, first, last):
        return self.cumulative_sum[last + 1] - self.cumulative_sum[first]


def div_ceil(a, b):
    return (a + b - 1) // b


def solve(n, xs):
    cs = CumulativeSum(xs)
    res = sys.maxsize // 10
    for p in range(n):
        left_sum = cs.partial_sum(0, p - 1)
        right_sum = cs.partial_sum(p, n - 1)
        res = min(res, abs(right_sum - left_sum))
    return res


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    res = solve(n, xs)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25896
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int l=1;
	if(a+b==60) l=60;
	for(int i=2;i<=30;i++){
		if(l%i==0&&(a+b)%i==0) l=i;
	}
	int shu=-1;
	for(int i=0;i<=60/l;i++){
		if((60*i+c)%(a+b)>0&&(60*i+c)%(a+b)<=a){
			shu=i;
			break;
		}
	}
	if(shu==-1) cout<<-1<<endl;
	else cout<<60*shu+c<<endl;
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

ll res=0;

void dfs(int &N, ll m){
    for(int i=3; i<=7; i+=2){
        m+=i;
        if(m > N){
            m-=i;
            continue;
        }
        ll tmp=m;
        vector<bool> ok(3, 0);
        while(tmp > 0){
            ok[(tmp%10-3)/2]=true;
            tmp/=10;
        }
        if(ok[0] && ok[1] && ok[2]){
            res++;
        }
        if(m*10 < N) dfs(N, m*10);
        m-=i;
    }
}

int main(){
    int N; cin >> N;
    dfs(N, 0);
    cout << res << endl;
    return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<int> h_flg(H);
  vector<int> w_flg(W);
  vector<vector<char>> data(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char tmp;
      cin >> tmp;
      h_flg.at(i) += (tmp=='#');
      w_flg.at(j) += (tmp=='#');
      data.at(i).at(j) = tmp;
    }
  }
  int new_w = 0;
  for (int j = 0; j < W; j++) {
    if (w_flg.at(j) != 0){
      new_w = j;
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (h_flg.at(i) && w_flg.at(j)){
        cout << data.at(i).at(j);
        if (j == new_w){
          cout << endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = (1 << 29);

int main()
{
  while (1)
  {
    int n, k;
    cin >> n >> k;
    if (n == 0 && k == 0)
      break;
    int a[n];
    rep(i, n) cin >> a[i];
    int s[n + 1];
    s[0] = 0;
    rep(i, n + 1) s[i + 1] = s[i] + a[i];
    int ans = -INF;
    rep(i, n - k) ans = max(ans, s[i + k] - s[i]);
    cout << ans << endl;
  }
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

int main()
{
    ll n, i, cnt;
    cin >> n;
    vector<ll> chk(N, 0), ar(n), ans(n), pre(N, 0);
    for (i = 0; i < n; i++){
        cin >> ar[i];
        chk[ar[i]]++;
    }
    // for (i = 0; i < n; i++){
    //     cout << chk[ar[i]] << " ";
    // }
    ll tot = 0;
    for (i = 0; i < n; i++)
    {
        pre[ar[i]] = chk[ar[i]] * (chk[ar[i]] - 1) / 2;
        //cout << temp << nl;
    }
    for (i = 0; i < N; i++){
        tot += pre[i];
    }
    for (i = 0; i < n; i++){
        ll temp = (tot-pre[ar[i]])+((chk[ar[i]]-1) * (chk[ar[i]] - 2) / 2);
        cout << temp << nl;
    }
        //cout << tot << nl;
}

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

using namespace std;

int main() {
	int max=0;
	while(cin>>max, max!=0){
		int magic_square[max][max];
		for(int i=0; i<max; i++)
			for(int j=0; j<max; j++)
				magic_square[i][j] = 0;

		int element = 1;
		int center = (max/2)+1;
		int index_x = center-1;
		int index_y = center;
		magic_square[index_y][index_x] = element;
		++element;
		index_x += 1;
		index_y += 1;
		
		while(element <= (max*max)){
			if(index_x >= max){
				index_x = 0;
			}else if( index_x < 0){
				index_x = max-1;
			}else if( index_y >= max){
				index_y = 0;
			}else if( magic_square[index_y][index_x] != 0){
				index_x -= 1;
				index_y += 1;
			}else{
				magic_square[index_y][index_x] = element;
				++element;
				index_x += 1;
				index_y += 1;
			}
		
		}
		for(int i=0; i<max; i++){
			for(int j=0; j<max; j++){
				printf("%4d", magic_square[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>

int main(){
    int W=0, H=0, x=0, y=0, r=0;
    std::string output ="No";
    
    // 読み込む
    std::cin >> W >> H >> x >> y >> r;

    if((-100<=x) && (x<=100)
       && (-100<=y) && (y<=100)
       && (0<W) && (W<=300)
       && (0<H) && (H<=300)
       && (0<r) && (r<=300)){
        
            //std::cout << "ここ" << std::endl;
    
        if(!((x-r<0) || (y-r<0) || (x+r>W) || (y+r>H))){
    
            output ="Yes";
        }
    }
    
    // 出力
    std::cout << output << std::endl;
}

//テストケース
/*
 境界値の確認
 ①境界値を超えるケース
 ②境界値ギリギリのケース
 
 
 
 ①出力がYesとNoか
 ②x-rが0より小さい
 
 15 15 2 5 3
 
 x-rが0と同じ
 
 15 15 3 5 3
 
 ③y-rが0より小さい
 
 15 15 5 2 3
 
 y-rが0と同じ
 
 15 15 5 3 3
 
 ④x+rがWより大きい
 
 15 15 13 5 3
 
 x+rがWと同じ
 
 15 15 12 5 3
 
 ⑤y+rがHより大きい
 
 15 15 5 13 3
 
 y+rがHと同じ
 
 15 15 5 12 3
 
 Sample Outputのケース
 
 */


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

namespace {
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define len(x) (int)((x).size())
#define X first
#define Y second

#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;

ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
template<typename T> T sqr(const T& x) { return x*x; }
ll flog(const ll x) { return 63 - __builtin_clzll(x); }
template<typename T> void sort(T& t) { sort(all(t)); }
template<typename T> void undupe(vector<T>& v) { sort(v); v.erase(unique(all(v)), v.end()); }

struct _IOS { _IOS() { ios::sync_with_stdio(0); cin.tie(0); } } _IOS;
}

const ll MOD = 1000000009LL;
const ll INF = 1e15;
const double EPS = 1e-8;

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	
	vvi A(H, vi(W, 1000));
	
	for (int i=h-1; i<H; i+=h) {
	  for (int j=w-1; j<W; j+=w) {
	    A[i][j] = -1000*(h*w - 1) - 1;
	  }
	}
	
	ll total = 0;
	for (int i=0; i<H; i++) {
	  for (int j=0; j<W; j++) {
	    total += A[i][j];
	  }
	}
	
	if (total > 0) {
	  cout << "Yes\n";
	  for (int i=0; i<H; i++) {
	    for (int j=0; j<W; j++) {
	      cout << A[i][j] << (j < W - 1 ? " " : "");
	    }
	    cout << '\n';
	  }
	} else {
	  cout << "No\n";
	}
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

template<class T, class ResultType = long long> vector<ResultType> binary_representation(T x, int const LeastDigit = 0) {if(x == 0) return {0};vector<ResultType> ret;while(x > 0) {ret.push_back(x % 2);x /= 2;}while((int)ret.size() < LeastDigit) {ret.push_back(0);}reverse(all(ret));return ret;}
template<class T> ostream& operator << (ostream& ost, vector<T> && v) { for(auto && e: v) ost << e; return ost; }
template<class T> ostream& operator << (ostream& ost, vector<T> const& v) { ost << "["; rep(i, v.size()) { if(i) ost << ", "; ost << v[i]; } ost << "]"; return ost; }

int main() {

  string pstr;
  rep(i, 10) pstr += '0' + i;
  rep(i, 26) pstr += 'A' + i;
  rep(i, 26) pstr += 'a' + i;

  int N; cin >> N;

  bool ok = 0;

  ll s = 0;
  rep(i, N) {
    ll p; string m; cin >> p >> m;
    ll x = 0;
    ll u = 1;
    reverse(all(m));
    rep(i, m.size()) {
      x += pstr.find(m[i]) * u;
      u *= p;
    }

    auto vx = binary_representation(x);

    int cnt = 0;
    rep(i, vx.size()) {
      if(vx[i] == 0 && cnt > 0) {
        s ^= cnt;
        cnt = 0;
      } else {
        if(vx[i] == 1) {
          ok = 1;
          cnt ++;
        }
      }
    }
    if(cnt) s ^= cnt;
  }

  if(!ok) {
    cout << "lose" << endl;
  } else {
    cout << (s ? "win" : "lose") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3204
if __name__ == '__main__':
    N, M = list(map(int, input().split()))
    A = []
    for i in range(N):
        A.append(list(map(int, input().split())))

    ans = float("inf")
    while len(A[0]) != 0:
        count_list = [0 for i in range(M + 1)]
        for i in range(0, N):
            count_list[A[i][0]] += 1

        max_value = max(count_list)
        for i in range(0, N):
            A[i].remove(count_list.index(max_value))

        if ans > max_value:
            ans = max_value

    print(ans)


Measured memory_bytes: 4268
#include<cstdio>

int main(){
	int n,max,sum,t;
	scanf("%d", &n);
	while(n){
		scanf("%d", &t);
		max = sum = t;
		if(sum < 0){
			sum = 0;
		}
		for(int i = 1; i < n; i++){
			scanf("%d", &t);
			sum += t;
			if(sum > max){
				max = sum;
			}
			if(sum < 0){
				sum = 0;
			}
		}
		printf("%d\n", max);
		scanf("%d", &n);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.*;

public class Main { //クラス名はMain
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		String s = sc.next();
      	String t = sc.next();
        int o=0;
        for(int i =0;i<3;i++){
        	if(s.charAt(i)==t.charAt(i)){
            	o++;
            }
        }
        System.out.println(o);
    }
}

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

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

int main(){
    ll n;cin>>n;
    vector<pair<ll,ll>> p;
    ll a[n],b[n];
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
        p.push_back(make_pair(b[i],a[i]));
    }
    sort(p.begin(),p.end());
    ll t=0;
    ll i=0;
    bool bo=true;
    while(bo && i<n){
        t=t+p[i].second;
        if(t>p[i].first){
            bo=false;
        }
        i++;
    }
    if(bo==true){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 8944
from sys import stdin


def main() -> None:
    n = next_int()
    l = [next_int() for _ in range(2 * n)]
    l.sort()

    ans = 0
    for i in range(n):
        ans += l[2 * i]
    print(ans)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

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

  int d[n];
  for(int i = 0; i < n; i++) cin >> d[i];
  
  int count = 0;
  for(int j = 0; j < n; j++) {
    if(d[j] != 0) {
      for(int k = j+1; k < n; k++) {
        if(d[j] == d[k]) {
          d[k] = 0;
          continue;
        }
      }
	  count++;
    }
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, k;
   cin >> n >> k;
   double ans = 0.0;
   rep(i, 1, n + 1) {
      int score = i;
      double pro = 1.0 / n;
      while (score < k) {
         score *= 2;
         pro /= 2;
      }
      ans += pro;
   }
   printf("%0.10f\n", ans);
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(){
    int n, ans = 0;
    int pow, s = 0;
    cin >> n;

    int a = n;

    int keta = log10(n) + 1;

    for(int i = keta;i > 0;i--){
        pow = 1;
        for(int j = 1;j < i;j++) pow *= 10;
        s += n / pow;
        n = n % pow;
    }

    if(a % s) cout <<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
const int mod = 1000000007;
int n, k, f[ 2001 ];

int qpow( int a,int x )
{
 if( x < 0 )
  return 1;
 int s = 1;
 while( x )
 {
  if( x & 1 )
   s = ( long long ) s * a % mod;
  a = ( long long ) a * a % mod;
  x >>= 1;
 }
 return s;
}

int main()
{
 scanf( "%d%d", &n, &k );
 f[ 0 ] = 1;
 for( int i = 1; i < n; ++i )
 {
  for( int j = i; j; --j )
   f[ j ] = ( f[ j + 1 ] + f[ j - 1 ] ) % mod;
  f[ 0 ] = f[ 1 ];
 }
 printf( "%lld", ( long long ) f[ n - k ] * qpow( 2, n - k - 1 ) % mod );
}

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

int parent[100005];
int frank[100005];
int ans[100005];
int len[100005];

void make_set(int v) {
  parent[v] = v;
  frank[v] = 0;
  len[v] = 1;
}

int find_set(int v) {
  if (v == parent[v])
    return v;
  parent[v] = find_set(parent[v]);
  len[v] = len[parent[v]];
  return parent[v];
}


void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (frank[a] < frank[b])
      swap(a, b);
    parent[b] = a;
    len[a] = len[b] + len[a];
    if (frank[a] == frank[b])
      frank[a]++;
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k, a, b;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) make_set(i);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    union_sets(a, b);
    ans[a]--;
    ans[b]--;
  }
  for (int i = 0; i < k; i++) {
    cin >> a >> b;
    if (find_set(a) == find_set(b)) {
      ans[a]--;
      ans[b]--;
    }
  }
  for (int i = 1; i < n; i++) 
    cout << (len[find_set(i)] - 1 + ans[i]) << " ";
  cout << (len[find_set(n)] - 1 + ans[n]) << '\n';
  return 0;
}

Measured memory_bytes: 2432
#include <vector>
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;

ll N;
ll ans=0;

void dfs(ll a, int flags){
  if(a>N) return;
  if(flags==7) ans++;
  dfs(a*10+3, flags|1);dfs(a*10+5, flags|2);dfs(a*10+7, flags|4);
}

int main(){
  cin>>N;
  dfs(0,0);
  cout<< ans <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int a,b;
    cin >> a >> b;
    if((a < 0 && b < 0 && a%2 != b%2) || (a > 0 && b > 0)) cout <<  "Positive" << endl;
    else if(a < 0 && b < 0 && a%2 == b%2) cout << "Negative" << endl;
    else cout << "Zero" << endl;
    return 0;  
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


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


def read_is(n=1):
    return [read_i() for _ in range(n)]


class Graph:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.edges = [[float('inf')] * n_nodes for _ in range(n_nodes)]

    def add_edge(self, s, t, d=None, undirected=False):
        if d is None:
            d = 1
        self.edges[s][t] = d
        if undirected:
            self.edges[t][s] = d


class FloydWarshall:
    def __init__(self, graph):
        self.graph = graph
        self.distances = [[float('inf')] * graph.n_nodes
                          for _ in range(graph.n_nodes)]
        self.nexts = [[None] * graph.n_nodes for _ in range(graph.n_nodes)]
        self._init()

    def _init(self):
        for x in range(self.graph.n_nodes):
            self.distances[x][x] = 0
        for source in range(self.graph.n_nodes):
            for destination, distance in enumerate(self.graph.edges[source]):
                self.distances[source][destination] = distance
                self.nexts[source][destination] = destination

    def compute_shortest_path_lengths(self):
        for k in range(self.graph.n_nodes):
            for i in range(self.graph.n_nodes):
                for j in range(self.graph.n_nodes):
                    s = self.distances[i][k] + self.distances[k][j]
                    if s < self.distances[i][j]:
                        self.distances[i][j] = s
                        self.nexts[i][j] = self.nexts[i][k]


n, m, l = read_i()
graph = Graph(n)
for _ in range(m):
    a, b, c = read_i()
    if c > l:
        continue
    graph.add_edge(a - 1, b - 1, d=c, undirected=True)
fw = FloydWarshall(graph)
fw.compute_shortest_path_lengths()

graph2 = Graph(n)
for s in range(n):
    for t in range(n):
        if s >= t:
            continue
        if fw.distances[s][t] > l:
            continue
        graph2.add_edge(s, t, d=1, undirected=True)
fw = FloydWarshall(graph2)
fw.compute_shortest_path_lengths()

q = int(input())
for _ in range(q):
    s, t = read_i()
    s -= 1
    t -= 1
    d = fw.distances[s][t] - 1
    if d == float('inf'):
        print(-1)
    else:
        print(d)

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

//long long
using ll = long long;

// pair<int, int>
using PII = pair<int, int>;

//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

// a = max(a, b), a = min(a, b)
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; }

// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}



// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main(){
    string S, T;
    cin >> S >> T;
    int slen = S.length();
    int tlen = T.length();
    vector<string>ans;
    for(int i = slen - tlen; i >= 0; i--){
        string tmp = S;
        REP(j, tlen){
            if(tmp.at(i + j) == T.at(j) ||  tmp.at(i + j) == '?') tmp.at(i + j)= T.at(j);
            else break;
            if(j == tlen - 1){
                REP(k, slen) if(tmp.at(k) == '?') tmp.at(k) = 'a';
                ans.push_back(tmp);
            }
        }
    }
sort(all(ans));
    cout << (ans.size() > 0 ? ans[0] : "UNRESTORABLE") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll f[1005];
int main()
{
    ll n,ans=1;
    scanf("%lld",&n);
    for(ll i=2;i<=n;i++)
    {
        ll x=i;
        for(ll j=2;j<=i;j++)
        {
            if(j>x)break;
            ll cnt=0;
            while(x%j==0)
            {
                x/=j;
                cnt++;
            }
            f[j]+=cnt;
        }
    }
    for(ll i=2;i<=n;i++)
    {
        f[i]++;
        ans=(ans*f[i])%M;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
import itertools
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
s = []
for i, j in itertools.product(range(h), range(w - 1)):
  if a[i][j] % 2 == 1:
    s.append((i + 1, j + 1, i + 1, j + 2))
    a[i][j] -= 1
    a[i][j + 1] += 1
for i in range(h - 1):
  if a[i][w - 1] % 2 == 1:
    s.append((i + 1, w, i + 2, w))
    a[i][w - 1] -= 1
    a[i + 1][w - 1] += 1
print(len(s))
for l in s:
  print(*l)


Measured memory_bytes: 26652
N = int(input())
st = [list(input().split()) for _ in range(N)]
X = input()

ans = 0
I = []
for i in range(N):
  if st[i][0] != X and len(I) == 0:
    continue
  elif st[i][0] == X:
    I.append(i)
  else:
    ans += int(st[i][1])
print(ans)

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

#define MAXN 100010

int dp[MAXN], n, m, vis[MAXN];
vector<int> g[MAXN];

void dfs( int u ) {
	vis[u] = true;
	for( int v : g[u] ) {
		if( !vis[v] ) dfs( v );
		dp[u] = max( dp[u], 1+ dp[v] );
	}
}

int lp() {
	for( int i = 1 ; i <= n ; ++i ) if( !vis[i] ) dfs( i );
	int r = 0;
	for( int i = 1 ; i <= n ; ++i ) r = max( r, dp[i] );
	return r;
}


int main(){
	scanf("%d%d", &n, &m);
	for( int i = 0, u, v; i < m ; ++i ) {
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
	}
	printf("%d\n", lp());
	return 0;
}


Measured memory_bytes: 8576
s = ("","Man","Oku","Cho","Kei","Gai","Jo",
	"Jou","Ko","Kan","Sei","Sai","Gok","Ggs",
	"Asg","Nyt","Fks","Mts")

while True:
	m,n = map(int,input().split())
	if m == 0 and n == 0:
		break
	ans = ""
	for i in range(0,len(str(m**n)),4):
		x = m**n//(10**i)%10000#m^n / 10^i
		if x > 0:
			ans = str(x) + s[i//4] + ans
	print(ans)


Measured memory_bytes: 5600
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n ,a ,b;

void go()
{
	cin >>  n >> a >> b;

	int sum = (n  /( a + b) );
	int rest = (n % ( a+ b ) );
	int ans = 0;

	// bug(sum , rest);

	if( sum == 0 )
	{
		if( n >= a ) ans = a;
		else ans = n;
	}
	else
	{
		ans = sum*a;

		if( rest > a ) ans += a;
		else ans += rest;
	}
	cout << ans << endl;

}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 256
X, K, D = map(int, input().split())

X = abs(X)
ans = 0
if X - K*D >= 0:
  ans = X - K*D
else:
  count = X // D
  K = K - (X // D)
  if K % 2 == 0: 
    ans = X - count*D
  else: 
    ans = D - (X - count*D)
    
print(ans)

Measured memory_bytes: 9172
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<int> i;
vector<int> u;
vector<int> o;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b,c,d=0,e=0,f=0,g;
  string s;
  cin >>a>>s;
  if(a>=3200) cout <<s<<'\n';
  else cout <<"red\n";
  return (0);
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline


class SegmentTree:
    def __init__(self, N, func, I):
        self.N = N
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(1, self.sz)):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b = self.sz * 2 if b == self.N else self.sz + b
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()

Measured memory_bytes: 60528
#include <iostream>
using namespace std;
int i,t;
bool data[31];
int main(){
	for(i=0;i<31;i++){
		data[i]=0;
	}
	for(i=0;i<28;i++){
		cin>>t;
		data[t]=1;
	}
	for(i=1;i<31;i++){
		if(data[i]==0){
			cout<<i<<endl;
		}
	}
	cin>>t;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define N 8
#define FREE -1
#define NOT_FREE 1
using namespace std;
int ki;
bool X[N][N];
char m[N][N];
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void init(){
  for(int i=0;i<N;i++){row[i]=FREE;col[i]=FREE;}
  for(int i=0;i<2*N-1;i++){dpos[i]=FREE;dneg[i]=FREE;}
}

void printBoard(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j)return ;
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout << ( (row[i]==j)?"Q":".");
    }
    cout << endl;
  }
}

void rec(int i){
  if(i==N){
    printBoard();
    return ;
  }
  for(int j=0;j<N;j++){
    if(NOT_FREE==col[j] ||
       NOT_FREE==dpos[i+j] ||
       NOT_FREE==dneg[i-j+N-1])continue;
    row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;

    rec(i+1);
    row[i]=j;col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  init();
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      X[i][j]=false;

  cin >> ki;
  for(int i=0;i<ki;i++){
    int r,c;
    cin >> r >> c;
    X[r][c]=true;
  }

  rec(0);

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define f(x) (x)*(x)

using namespace std;

int n;
int a[1001];
int cnt;
int ans;
int tt=0x7fffffff;

int main()
{
    cin>>n;
    int mi=tt,ma=-tt;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt+=a[i];
        if(a[i]<mi) mi=a[i];
        if(a[i]>ma) ma=a[i];
    }
    int t=cnt/n;
    for(int k=mi;k<=ma;k++)
    {
        ans=0;
        for(int i=1;i<=n;i++)
        {
            ans+=f(a[i]-k);
        }
        if(ans<tt) tt=ans;
    }
    cout<<tt;
    return 0;
}

Measured memory_bytes: 256
package main

import(
    "fmt"
)

func main() {
    var l, r int
    fmt.Scan(&l, &r)

    if r - l >= 2019 {
        fmt.Println(0)
        return
    }

    var min int
    min = 2020
    for i:= l;i <= r-1;i++ {
        for j:= l+1;j <= r; j++ {
            if min > (i*j)%2019 {
                min = (i*j)%2019
            }
        }
    }

    fmt.Println(min)
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n),f(n);
  cin>>a>>f;

  sort(a.begin(),a.end());
  sort(f.begin(),f.end());

  auto ceil = [](ll a,ll b){return (a-1)/b+1;};
  auto chk = [&](ll x)->bool{
    ll cnt=0;
    rep(i,n){
      ll j = n-i-1;
      ll product = a[i]*f[j];
      if(product>x){
        ll dif = product-x;
        cnt += ceil(dif,f[j]);
      }
    }
    return cnt<=k;
  };

  ll low=-1,high=(1e12);
  while(high-low>1){
    ll mid = (high+low)/2;
    if( chk(mid) )high=mid;
    else low=mid;
  }
  cout<<(high)<<endl;

}

Measured memory_bytes: 3456
import Data.List

main = do
  n <- readLn :: IO Int
  xls <- map (map read . words) <$> lines <$> getContents :: IO [[Int]]
  putStrLn $ show $ count $ sortOn snd $ map (\(x: l: _) -> (let b = x - l in if b < 0 then 0 else b, x + l)) xls

foldlState :: (a -> c -> b -> (a, c)) -> a -> c -> [b] -> a
foldlState f a s l = fst $ foldl (\(a, s) -> f a s) (a, s) l

count ys = foldlState step 0 0 ys
    where step a k (b, e)
              | b < k     = (a, k)
              | otherwise = (a + 1, e)


Measured memory_bytes: 39164
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, Q;
    cin >> N >> Q;
    using pii = pair<int, int>;
    vector<pair<pii, int>> schedule;
    vector<int> D(Q);
    rep(i, N) {
        int s, t, x;
        cin >> s >> t >> x;
        schedule.push_back(MP(MP(s - x, x), 1));
        schedule.push_back(MP(MP(t - x, x), 0));
    }
    rep(i, Q) { cin >> D[i]; }
    sort(All(schedule));
    int now = 0;
    set<int> work;
    rep(i, Q) {
        while(schedule[now].first.first <= D[i] && now < schedule.size()) {
            if(schedule[now].second) {
                work.insert(schedule[now].first.second);
            } else {
                work.erase(schedule[now].first.second);
            }
            now++;
        }
        if(work.empty()) {
            cout << -1 << endl;
        } else {
            cout << *work.begin() << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 17004
#include<iostream>
using namespace std;
long long a,b,c;
int main()
{
    cin>>a>>b>>c;
    for(int i=1;i<1926;i++)
    {
        if((a*i)%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)

sum = A.sum
ans = 0
sum -= A[0]

(0...N-1).each do |i|
  ans = (ans + (A[i] * sum)) % (10**9 + 7)
  sum -= A[i+1]
end

puts ans

Measured memory_bytes: 35924
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; }cout << endl; }
const LL LLINF = 1LL << 60;
const int DAYS_OF_A_YEAR = 181;

int main(void) {
	LL N, K;
	cin >> N >> K;

	vector<LL> A(N);
	rep(i, N) cin >> A[i];

	LL count = 1;
	int i = 0;
	while (K + (K - 1) * i < N) {
		count++;
		i++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1024
def main():

    n = int(input())
    adj = [[0 for i in range(n)] for j in range(n)]

    for i in range(n):
        tmp = list(map(int, input().split()))
        u = tmp[0]
        u = u -1
        k = tmp[1]
        v = tmp[2:]
        for j in range(k):
            adj[u][v[j]-1] = 1

    for i in adj:
        print(*i)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8528
/*	[]__________[][][][]____[][][][][]__{}__[][][][]____[][][][][]__[][][][]
    []__________[]______________[]__________[]__________[]__________[]____[]
    []__________[][][][]________[]__________[][][][]____[]__________[]____[]
    []__________[]______________[]________________[]____[]__[][][]__[]____[]
    []__________[]______________[]________________[]____[]______[]__[]____[]
    [][][][]____[][][][]________[]__________[][][][]____[][][][][]__[][][][]
*/
#include <bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define endl '\n'
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define decimal(x) cout<<fixed<<setprecision(x);
bool prime[100005]; 
void Sieve(int n) {
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
} 
void solve()
{
    int n;
    cin>>n;
    int arr[n+1],b[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++)cin>>arr[i],b[i]=arr[i];
    for(int i=2;i<=n;i++)
    arr[i]+=arr[i-1];
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=(((arr[i]-b[i])%mod)*(b[i]%mod))%mod;
        sum=sum%mod;
    }
    cout<<sum<<endl;
}	
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
       //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 6720
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define MAXN (int)1e5
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)
#define inf (int)1e9
int a[MAXN][3];
int dp[MAXN][3];

int sol(int ind,int last_pos){
	if(ind < 0) return 0;

	if(dp[ind][last_pos] != -1)
		return dp[ind][last_pos];

	int max_happiness = -inf;

	for(int i = 0;i < 3;i++){
		if(i == last_pos) continue;

		max_happiness = max(max_happiness, a[ind][i]+sol(ind-1,i));
	}

	dp[ind][last_pos] = max_happiness;
	return dp[ind][last_pos];
}

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

	fo(n){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	int ans = -inf;
	memset(dp,-1,sizeof(dp));

	for(int i = 0;i < 3;i++){
		ans = max(ans, a[n-1][i] + sol(n-2,i));
	}

	cout << ans << endl;

	return 0;
 }	

Measured memory_bytes: 10368
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main() {
	int N;
	cin >> N;
	int *a;
	a = (int*)malloc(sizeof(int)*N);
	for (int i = 0;i < N;i++)cin >> a[i];
	sort(a, a + N);
	cout << a[N - 1] - a[0] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	for(int i=0;i<n;i++){
		cin >> l[i];
	}
	//l[n] = 100000;
	sort(l.begin(),l.end());
	ll ans = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int t = l[i]+l[j];
			int u = l[j]-l[i];
			int d1 = lower_bound(l.begin(),l.end(),t)-l.begin();
			int d2 = upper_bound(l.begin(),l.end(),u)-l.begin();
			//cout << d1 <<" "<<d2 << endl;
			ans += d1-d2-1;
			if(u<l[i]) ans--;
		}
	}

	cout << ans/3 << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, L;
    cin >> N >> L;

    int all = L * N + N * (N - 1) / 2, bestdiff = 100000;
    int sub = 0;
    FOR(i, 0, N) {
        int diff = (L + i);
        if (abs(diff) < abs(bestdiff)) {
            bestdiff = diff;
            sub = L + i;
        }
    }

    cout << all - sub << endl;
    return 0;
};


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c) puts("Yes");
    else puts("No");
}



Measured memory_bytes: 3108
package main

import (
    "fmt"
    "sort"
)

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
    return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
    return len(s)
}

func main() {
    var n int
    fmt.Scan(&n)
    ss := make([]string, n)
    for i := range ss {
        fmt.Scan(&ss[i])
    }

    m := make(map[string]int)
    for i := range ss {
        r := sortRunes([]rune(ss[i]))
        sort.Sort(r)
        m[string(r)]++
    }

    var sum int
    for _, v := range m {
        if v <= 1 {
            continue
        }
        sum += v * (v - 1) / 2
    }

    fmt.Println(sum)
}


Measured memory_bytes: 13440
#include <iostream>

using namespace std;

int main(){
	char* n = (char*)calloc(5, sizeof(char));
	cin >> n;
	if(n[0] == n[1] && n[1] == n[2]) cout << "Yes";
	else if(n[1] == n[2] && n[2] == n[3]) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3596