akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	ans := 999
	for i := 0; i < len(s)-2; i++ {
		n, _ := strconv.Atoi(s[i : i+3])
		ans = min(ans, abs(n-753))
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 640
a,b,c=map(int,input().split())
l=sorted([int(input()) for i in range(a)])
ans=0
now=l[0]
cur=1
for i in range(1,a):
  x=l[i]
  if cur==b:
    now=x
    cur=1
    ans+=1
  elif x-now>c:
    now=x
    ans+=1
    cur=1
  else:
    cur+=1
print(ans+1)

Measured memory_bytes: 51032
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    int n,m;
    cin>>n>>m;
    unordered_map<int,int> bad;
    vi h(n+1);
    for (int i = 1; i <= n; i++)
    {
        cin>>h[i];
    }
    for (int i = 0; i < m; i++)
    {
        int x,y;
        cin>>x>>y;
        if(h[x]<h[y])
        {
            bad[x]++;
        }
        else if(h[x]>h[y])
        {
            bad[y]++;
        }
        else
        {
            bad[x]++;
            bad[y]++;
        }
    }
    int ans = n-bad.size();
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 6000
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
  int n, m;
  scanf("%d %d", &n, &m);

  int k[11], s[11][11], p[11];
  int si, mi, ki;
  for (mi = 0; mi < m; mi++)
  {
    scanf("%d", &k[mi]);
    for (ki = 0; ki < k[mi]; ki++)
      scanf("%d", &s[mi][ki]);
  }

  for (mi = 0; mi < m; mi++)
    scanf("%d", &p[mi]);

  int on, switch_onoff, count = 0;
  bool judge;
  for (si = 0; si < pow(2, n); si++)
  {
    judge = true;
    for (mi = 0; mi < m; mi++)
    {
      on = 0;
      for (ki = 0; ki < k[mi]; ki++)
      {
        switch_onoff = 1 << (s[mi][ki] - 1);
        on += (si & switch_onoff) / switch_onoff;
      }
      if (on % 2 != p[mi])
      {
        judge = false;
        break;
      }
    }
    if (judge)
      count++;
  }

  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 384
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    string s;
    scan(s);
    if (s == "AAA" || s == "BBB") {
        print("No");
    } else {
        print("Yes");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();


			long count = 0;

			for(int i = 1;i<=N-1;i++) {
				count+=(long)((N-1)/i);
			}
			System.out.println(count);

		}


	}


}


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

const double PI = 3.14159265358979323846;
#define DUMP(x) cerr << #x << " = " << (x) << endl;

int main(void)
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    int mi = h * 60 + m;
    int aa = mi % 720;
    int bb = mi % 60;
    printf("%.10lf", sqrt(a * a + b * b - 2 * a * b * cos(abs((aa - 12 * bb) * PI / 360))));
    return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main() {
    int N , T;
    cin >> N >> T;
    vector <int> c(N);
    vector <int> t(N);
    int ans = 1e9;
    for(int i = 0; i < N; i++){
        cin >> c.at(i) >> t.at(i);
        if(t.at(i) <= T){
            ans = min(ans , c.at(i));
        }
    }
    if(ans == 1e9){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX 200000
#define SENTINEL 2000000000

typedef long long llong;

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

llong merge(int A[], int n, int left, int mid, int right) {
    llong cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    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] = R[n2] = SENTINEL;

    int i = 0, j = 0;

    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

llong mergeSort(int A[], int n, int left, int right) {
    int mid;
    llong v1, v2, v3;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }
    return 0;
}

int main() {
    int A[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    long ans = mergeSort(A, n, 0, n);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4644
main :-
	read_num(X),
        read_num(K),
        read_num(D),

        AbsX = abs(X),

        find_location(AbsX, K, D, L),

        write(L),
        nl,
        halt.

find_location(X, K, D, L) :-    %　K回移動しても原点まで行けない場合
        X >= K * D,
        !,
        L is X - K * D.
find_location(X, K, D, L) :-    % K回までに原点を飛び越える場合
        FirstOverNumberOfTimes is ceiling(X / D),
        RemainNumberOfTimes is K - FirstOverNumberOfTimes,
        RemainNumberOfTimes mod 2 =:= 0, % -側
        !,
        L is abs(X - FirstOverNumberOfTimes * D).
find_location(X, K, D, L) :-    % +側
        OverOriginDistance is abs(X - ceiling(X / D) * D), % -側の点の絶対値
        L is abs(OverOriginDistance - D).                  % +側の点の絶対値


read_str(S) :-
        read_string(current_input, ' \n', '', _, S).

read_num(N) :-
	read_str(S),
	number_string(N, S).


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

using namespace std;

#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()

typedef long long tint;

const tint MOD = 1000000007;

int main(){
	int n; cin >> n; vector<double> a (n);
	forn(i, n) cin >> a[i];
	sort(a.rbegin(), a.rend());
	while(a.size() > 1){
		double x = (a[a.size()-1]+a[a.size()-2])/2;
		a.pop_back(); a.pop_back();
		a.push_back(x);
	}
	cout << a[0] << endl;
}



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

int main(){
  int n;
  cin>>n;
  int a[9]={1,2,3,5,6,9,10,13,17};
  int c=1;
  for(int i=0;i<9;i++){
    if(n==a[i]){
      c=0;
    }
  }
  if(c==1){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // 1000000000000001 15 digits
    lint n;
    cin >> n;
    lint d   = 0;
    lint al  = 1;
    lint alt = 0;
    for (int i = 1; i < 1000; ++i) {
        al *= 26;
        alt += al;
        if (alt >= n) {
            d = i;
            alt -= al;
            break;
        }
    }
    n -= alt;
    n -= 1;
    string ret(d, 'a');
    for (int i = 0; i < d; ++i) {
        if (n == 0)
            break;
        ret[d - 1 - i] += n % 26;
        n /= 26;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>



int main(void){
	int K,X,i;
	scanf("%d %d",&K, &X);

	for(i=0;i<(2*K-1);i++){
		if(i != 0){
			printf(" ");
		}
		printf("%d", X-K+1+i);
	}
	printf("\n");


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int func(int ab){
  if(ab<10)ab=1;
  else{
    int tmp=1;
    while(ab>=10){
      ab=ab/10;
      tmp+=1;
    }
    ab=tmp;
  }
  cout<<ab<<endl;
  int a,b;
  a=-12;
  b=-13;
  cin>>a>>b;
  if(a!=-12&&b!=-13)func(a+b);
}
int main(){
  int a,b;
  cin>>a>>b;
  func(a+b);
}

Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  set<int> S[N];
  REP(i,M){
    int s,c;
    cin>>s>>c;
    s--;
    S[s].insert(c);
  }
  lint ans=0;
  REP(i,N){
    ans*=10;
    if(S[i].size()>1){
      cout<<-1<<endl;
      return 0;
    }else if(S[i].size()==1){
      if(N!=1 and i==0 and *(S[i].begin())==0){
        cout<<-1<<endl;
        return 0;
      }
      ans+=*(S[i].begin());
    }else {
      if(N!=1 and i==0)ans+=1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;

int main() {
	string s,t;

	cin >> s >> t;

	if (t.substr(0,s.size()) == s)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   int n,k,r,s,p;
   cin >> n >> k >> r >> s >> p;
   string a;cin>> a;
   int ans =0;
   rep(i,n)
   {
      if(a[i]=='r')ans+=p;
      else if(a[i]=='s')ans+=r;
      else if(a[i]=='p')ans+=s;
   }

   rep(i,n-k)
   {
      if(a[i]==a[i+k])
      {
         if(a[i]=='r')ans-=p;
      else if(a[i]=='s')ans-=r;
      else if(a[i]=='p')ans-=s;

      a[i+k]='A';
      }
   }
   cout<<ans<<endl;
   return 0;
}

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

int f(int n, int s, int x)
{
	if (n == 0) {
		if (s == 0) return 1;
		else return 0;
	}
	if (x >= 10) {
		return 0;
	}
	return f(n - 1, s - x, x + 1) + f(n, s, x + 1);
}

int main()
{
	int n, s;
	
	while (1) {
		cin >> n >> s;
		
		if (n == 0 && s == 0) break;
		
		cout << f(n, s, 0) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#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; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
int main(){
  int n;
  cin >> n;
  vector<pii>d(n);
  rep(i, 0, n){
    cin >> d[i].first >> d[i].second;
  }
  rep(i, 2, n){
    if(d[i-2].first==d[i-2].second&&d[i-1].first==d[i-1].second&&d[i].first==d[i].second){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

typedef std::stack<int> IntStack;
typedef std::queue<int> IntQueue;
typedef std::vector<int> IntVector;
typedef std::list<int> IntList;

using namespace std;
  
int main(){
  int H, A;
  cin >> H >> A;
  
  int ans;
  if(H%A == 0) ans = H/A;
  else ans = H/A+1;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import collections
N, W = map(int, input().split())
wv = collections.defaultdict(list)
w = 0
for i in range(N):
    a, b = map(int, input().split())
    wv[a].append(b)
    if i == 0:
        w = a
s = [[0]*(len(wv[w+i])+1) for i in range(4)]

for i in range(4):
    wv[w + i].sort(reverse=True)
    for j, x in enumerate(wv[w + i]):
        s[i][j+1] = s[i][j] + x
ans = 0
L = len(wv[w+3])
for i in range(min(len(wv[w]), N)+1):
    tmp1 = s[0][i]
    weight1 = w * i
    if weight1 > W:
        break
    for j in range(min(len(wv[w+1])+1, N+1 - i)):

        tmp2 = tmp1 + s[1][j]
        weight2 = weight1 + (w+1)*j
        if weight2 > W:
            break
        for k in range(min(len(wv[w+2])+1, N+1 - i - j)):
            tmp3 = tmp2 + s[2][k]
            weight3 = weight2 + (w+2)*k
            if weight3 > W:
                break
            d = W - weight3

            ans = max(ans, tmp3 + s[3][min(L, d//(w+3))])
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int dp[n+10][3]={};
    for(int i=1;i<=n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a);
        dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b);
        dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c);
    }
    int ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<ans<<"\n";
    return(0);
}

Measured memory_bytes: 4788
import java.util.Scanner;

/**
 * https://abc060.contest.atcoder.jp/tasks/abc060_a
 */
public class Main {
	 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		sc.close();
		
		String ans = "NO";
		if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)){
			ans = "YES";
		}

		System.out.println(ans);
 
	}
 
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,m;
    cin>>n>>m;
    vector<queue<int> > vec(n);
    REP(i,n){
        REP(j,m){
            int t;
            cin>>t;
            t--;
            vec[i].push(t);
        }
    }
    vi f(m);
    int ans=INF;
    REP(i,m){
        vi sum(m);
        REP(j,n){
            while(f[vec[j].front()]){
                vec[j].pop();
            }
            sum[vec[j].front()]++;
        }
        int ma=0;
        REP(j,m){
            if(sum[j]>sum[ma]){
                ma=j;
            }
        }
        ans=min(ans,sum[ma]);
        f[ma]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <cstdio>
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x = a*b;
	int y = c*d;
	if (x >= y) printf("%d\n",x);
	else printf("%d\n",y);
	return 0;
}

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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin>>n;
	vec a(n);
	vec b(n-1);
	FOR(i,0,n-1) {
		cin>>b[i];
	}
	a[n-1]=INF;
	for(int i=n-2;i>=0;i--) {
		a[i+1]=min(a[i+1],b[i]);
		a[i]=b[i];
	}
	ll out=0;
	FOR(i,0,n) {
		out+=a[i];
	}
	cout<<out;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;

#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int INF = 1e9+5;
using namespace std;
using ll = unsigned long long int;
const ll mod = 998244353; 
int main() {
	// your code goes here
	
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int k;cin>>k;
	ll total = 0;
	for(int i = 1;i<=k ; i++)
	{
		for(int j = 1;j<=k ; j++)
		{
			for(int l = 1 ; l<=k ; l++)
			{
				int temp = __gcd(j,l);
				total +=__gcd(i,temp);
			}
		}
	}
	cout<<total;	
}

Measured memory_bytes: 3636
N=int(input())
x,y,e=0,0,0
f=True
for _ in range(N):
    a,b,c=map(int,input().split())
    d=(a-e)-(b-x)-(c-y)
    x=b
    y=c
    e=a
    if d%2 or d<0:
        f=False
if f:print("Yes")
else:print("No")    


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main(void) {
	char hanazawa_kana[1024];
	while (scanf("%1023s", hanazawa_kana) == 1 && strcmp(hanazawa_kana, "0") != 0) {
		int horie_yui = 0;
		char *noto_mamiko;
		for (noto_mamiko = hanazawa_kana; *noto_mamiko != '\0'; noto_mamiko++) {
			horie_yui += *noto_mamiko - '0';
		}
		printf("%d\n", horie_yui);
	}
	return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};





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

	int h,w;
	cin >> h >> w;
	vector<vec> a(h);
	vi ngx,ngy;
	rep(i,h){
		int cnt = 0;
		rep(j,w){		 
			char x;
			cin >> x;
			if(x=='.') cnt++;
			a[i].pb(x);
		}
		if(w==cnt) ngy.pb(i);
	}
	rep(i,w){
		int cnt = 0;
		rep(j,h){
			if(a[j][i]=='.')cnt++;
		}
		if(h==cnt) ngx.pb(i);
	}

	rep(i,h){
		bool ok1 = true;
		for(auto it : ngy){
			if(i==it) {ok1 = false;break;}
		}
		if(!ok1) continue;
		rep(j,w){
			bool ok2 = true;
			for(auto itt : ngx){
				if(j==itt) {ok2 = false;break;}
			}
			if(!ok2) continue;
			cout << a[i][j];
		}
		cout << endl;
	}

    return 0;
}


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

using namespace std;
int main(){
    long k,sum=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int x=1;x<=k;x++){
                sum=sum+__gcd(i,__gcd(j,x));
            }
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3632
N, M, K = map(int, input().split())
F = [[] for _ in range(N)]
B = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    F[a-1].append(b-1)
    F[b-1].append(a-1)

for i in range(K):
    c, d = map(int, input().split())
    B[c-1].append(d-1)
    B[d-1].append(c-1)


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


UF = UnionFind(N)
for iam in range(N):
    for friend in F[iam]:
        UF.unite(iam, friend)

ans = [UF.size[UF.find(iam)] - 1 for iam in range(N)]
for iam in range(N):
    ans[iam] -= len(F[iam])

for iam in range(N):
    for block in B[iam]:
        if UF.find(iam) == UF.find(block):
            ans[iam] -= 1

print(*ans, sep=' ')

Measured memory_bytes: 48412
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
static const double pi = 3.141592653589793;
typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-10;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)



D dot(P a, P b) {
  return (conj(a)*b).X;
}
D cross(P a, P b) {
  return (conj(a)*b).Y;
}


int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecSS(P a1, P a2, P b1, P b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

VP crosspointCC(P a, D ar, P b, D br) {
  VP ps;
  P ab = b-a;
  D d = abs(ab);
  D crL = (norm(ab) + ar*ar - br*br) / (2*d);
  if (EQ(d, 0) || ar < abs(crL)) return ps;

  P abN = ab * P(0, sqrt(ar*ar - crL*crL) / d);
  P cp = a + crL/d * ab;
  ps.push_back(cp + abN);
  if (!EQ(norm(abN), 0)) ps.push_back(cp - abN);
  return ps;
}

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

int N;
int main() {
	while(cin >> N, N) {
		vector<pair<P, D>> circls;
		vector<VP> points;
		P ps;
		D dp[110][2];
		rep(i, 101) {
			dp[i][0] = 1e20;
			dp[i][1] = 1e20;
		}
		D x,y,rn;
		D  ans;
		rep(n, N) {
			cin >> x >> y >> rn;
			P pn = P(x, y);
			circls.push_back(make_pair(pn, rn));
			if (n == 0) {
				points.push_back({pn, pn});
				dp[0][0] = 0;
			} else {
				P p1 = get<0>(circls[n - 1]);
				D r1 = get<1>(circls[n - 1]);
				VP vp1 = crosspointCC(pn,rn,p1,r1);
				points.push_back(vp1);
				rep(i,n) {
					rep(k, 2){
						rep(k2, 2) {
							P pr = vp1[k];
							P pl = points[i][k2];
							bool f = true;
							for (int j = i + 1; j < n; j++) {
								P pm1 = points[j][0];
								P pm2 = points[j][1];
								f = f & isecSS(pm1, pm2,pr, pl);
							}
							if(f) dp[n][k] = min(dp[n][k] , dp[i][k2] + abs(pr - pl));
							
						}
					}
					
				}
			}
			ans = 1e22;
			if (n == N - 1) {
				rep(i, N) {
					rep(k2, 2) {
						P pr = pn;
						P pl = points[i][k2];
						bool f = true;
						for (int j = i + 1; j < N; j++) {
							P pm1 = points[j][0];
							P pm2 = points[j][1];
							f = f & isecSS(pm1, pm2,pr, pl);
						}
						if(!f)continue;
						ans = min(ans, dp[i][k2] + abs(pr - pl));
						
					}
				}
			}
		}
		cout << setprecision(20) << ans << endl;
	}
}



Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  string s;
  cin >> s;
  for(int i = 0; i <s.size(); i++){
    if(i == A){
      if(s.at(i)!='-'){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      if(s.at(i)<'0' || s.at(i)>'9'){
        cout << "No" << endl;
        return 0;
      } 
    }
    }
cout << "Yes" << endl;
}

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


def solve(a: int):
    print(a + a**2 + a**3)
    return


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

if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define rep(i, l, n) for (int i = (l); i < n; i++)
#define rep_cs(i, l, n) for (int i = (l); i <= n; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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;
}

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

using Graph = vector<vector<int>>;
Graph G;
vector<bool> seen;
void dfs(const Graph &G, int v)
{
    seen[v] = true;

    for (auto next_v : G[v])
    {
        if (seen[next_v])
            continue;
        dfs(G, next_v);
    }
}

int main()
{
    ll x;
    cin >> x;
    cout << (x + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int S = 0;
  S = N/1000;
  if(N%1000 == 0){
    cout << 0;
  }
  else{
    cout << (S+1)*1000 - N;
  }
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main()
{
  int K;
  long int sum = 0;
  cin >> K;
  for (int i = 1; i <= K; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      for (int k = 1; k <= K; k++)
      {
        sum += gcd(gcd(i, j), k);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d", &a, &b);
	if(a%3==0||b%3==0||(a+b)%3==0)
	printf("Possible\n");
	else
	printf("Impossible\n");
	
	return 0;
}

Measured memory_bytes: 128
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }

    let mut minv = n + 1;
    let mut ans = 0;
    for i in 0..n {
        if p[i] <= minv {
            ans += 1;
            minv = p[i];
        }
    }

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


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    char c;
    string s;
    getline(cin, s);
    for (auto c: s) {
        if (islower(c))         cout<<(char)toupper(c);
        else if (isupper(c))    cout<<(char)tolower(c);
        else                    cout<<c;
    }
    cout<<endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N,perm_index;
int work[8];
bool used[9];
map<int,int> MAP;


void recursive(int index){

	if(index == N){

		int tmp = 0;

		for(int i = 0; i < N; i++){

			tmp = 10*tmp+work[i];
		}

		MAP[tmp] = perm_index++;

		return;
	}

	for(int i = 1; i <= N; i++){

		if(used[i])continue;

		used[i] = true;
		work[index] = i;
		recursive(index+1);
		used[i] = false;
	}
}


int main(){

	scanf("%d",&N);

	for(int i = 1; i <= N; i++){

		used[i] = false;
	}

	perm_index = 0;
	for(int i = 1; i <= N; i++){

		work[0] = i;
		used[i] = true;
		recursive(1);
		used[i] = false;
	}

	int P = 0,tmp;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		P = 10*P+tmp;
	}

	int Q = 0;
	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		Q = 10*Q+tmp;
	}

	printf("%d\n",abs(MAP[P]-MAP[Q]));

	return 0;
}


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

int main() {
long long n;
cin >> n;
long long a[n];
long long ans = 0;
for(int i=0;i<n;i++){
    cin >> a[i];
}
long long sum[n+1];
sum[0]=0;
map<long long,long long> p;
p[0]=1;
for(long long i=0;i<n;i++){
    sum[i+1]=sum[i]+a[i];
}
for(long long i=0;i<n;i++){
    if(p.find(sum[i+1])==p.end()) p[sum[i+1]]=1;
    else p[sum[i+1]]++;
}
for(auto i:p){
    if(i.second>=2){
    ans+=(i.second*(i.second-1))/2;
    }
}
cout << ans << endl;
}


Measured memory_bytes: 15872
N = int(input())
S = input()
flag = False
ans = 0
for i in range(1000):
    p = str(i).zfill(3)
    a = [-1, -1, -1]
    for j in range(len(S)):
        if p[0] == S[j]:
            a[0] = j
            break
    if a[0] != -1:
        for k in range(a[0] + 1, len(S)):
            if p[1] == S[k]:
                a[1] = k
                break
    else:
        continue
    if a[1] != -1:
        for l in range(a[1] + 1, len(S)):
            if p[2] == S[l]:
                a[2] = l
                break
    else:
        continue
    if a[2] != -1:
        ans += 1

print(ans)

Measured memory_bytes: 43228
#include<stdio.h>
#include<string.h>
#include<vector>
#include<map>
using namespace std;
typedef pair<char,int> P;
char s[1000001];
vector<P> seq;
int max(int a,int b){return a>b?a:b;}
int main(){
	scanf(" %s",s);
	int i;
	int n=strlen(s);
	int p=0;
	while(p<n){
		char c=s[p];
		int st=p;
		while(p<n&&s[p]==c)p++;
		seq.push_back(P(c,p-st));
	}
	n=seq.size();
	int ans=0;
	for(i=0;i<n;i++){
		if(seq[i].first!='J')continue;
		if(i<n-2&&seq[i+1].first=='O'&&seq[i+2].first=='I'){
			int a=seq[i].second;
			int b=seq[i+1].second;
			int c=seq[i+2].second;
			if(b>a||b>c)continue;
			ans=max(ans,b);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11676
n, m = map(int, input().split())
lst = [x for x in range(n)]
dic = {}
not_found = False
special_case = False
for i in range(m):
    a, b = map(int, input().split())
    if str(a) not in list(dic.keys()):
        dic[str(a)] = b
    else:
        if dic[str(a)] != b:
            not_found = True
    lst[a - 1] = b
if m == 0:
    special_case = True
if not_found:
    print(-1)
elif special_case:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
else:
    for i in range(n):
        if str(i + 1) not in list(dic.keys()):
            if i + 1 == 1:
                lst[i] = 1
            else:
                lst[i] = 0
    lst = list(map(str, lst))
    res = ''.join(lst)
    if res[0] == '0' and len(res) > 1:
        print(-1)
    else:
        print(int(res))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <regex>
#include <cstdlib>
using namespace std;

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

	int *w = new int[n];
	int *front = new int[n];
	int *back = new int[n];
	int *absolute = new int[n];

	for (int s = 0; s < n; s++) {
		scanf("%d", &w[s]);
		front[s] = { 0 };
		back[s] = { 0 };
		absolute[s] = { 0 };
	}

	int count = 0;

	for (count = 0; count < n; count++) {
		for (int i = 0; i < count; i++) {
			front[count] = front[count] + w[i];
		}

		for (int j = 0; j < n - count; j++) {
			back[count] = back[count] + w[n - j - 1];
		}

		absolute[count] = abs(front[count] - back[count]);
	}

	int culmin = absolute[0];
	for (int mi = 0; mi < n; mi++) {
		if (absolute[mi] < culmin) {
			culmin = absolute[mi];
		}
	}
	printf("%d\n", culmin);

	delete[] w,front,back,absolute;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int n,x[101],y[101],h[101];
int lox,loy,he,ju,p=1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&x[i],&y[i],&h[i]);
	while(h[p]==0) p++;
	for(lox=0;lox<=100;lox++)
		for(loy=0;loy<=100;loy++)
		{
			ju=1;
			he=abs(lox-x[p])+abs(loy-y[p])+h[p];
			for(int i=1;i<=n;i++)
			{
				int r=he-abs(lox-x[i])-abs(loy-y[i]);
				r=r>0?r:0;
				if(r!=h[i])
				{
					ju=0;
					break;
				}
			}
			if(ju==1)
			{
				printf("%d %d %d",lox,loy,he);
				return 0;
			}
		}
}

Measured memory_bytes: 256
import sys
import itertools
input = sys.stdin.readline
 
def SI(): return str(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
   
    H, W, K = MI()
    grid = [SI().rstrip('\n') for _ in range(H)]

    n = H + W
    ans = 0
    
    for i in itertools.product(range(2),repeat = H):
        for j in itertools.product(range(2),repeat = W):
            count = 0
            for k in range(H):
                if i[k] == 1:
                    continue
                for l in range(W):
                    if j[l] == 1:
                        continue
                    if grid[k][l] == "#":
                        count += 1
            if count == K:
                ans +=1
    print(ans)
main()

Measured memory_bytes: 74104
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    ll r = in(), d = in(), x = in();
    REP(i, 10) {
        cout << (x = r * x - d) << endl;
    }
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    ans = 0
    for b in range(1, N+1):
        if K < b:
            tmp = (b-K)*(N//b) + max(N % b - max(K-1, 0), 0)
            ans += tmp
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39152
#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>
 
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;
 
int main() {
 
  string a, b; cin >> a >> b;
  int n = a.size(), m = b.size();
  int da = 0, db = 0;
  int ia = 0, ib = 0;
  while(ia < n) {
    da += (a[ia] == '(') - (a[ia] == ')');
    db += (b[ib] == '(') - (b[ib] == ')');
    while(da < db) {
      ib ++;
      db += (b[ib] == '(') - (b[ib] == ')');
    }
    while(da > db) {
      ia ++;
      da += (a[ia] == '(') - (a[ia] == ')');
    }
    cout << a[ia];
    if(a[ia] == '[') {
      assert(b[ib] == '[');
      ia ++, ib ++;
      int size_a = a.find(']', ia) - ia;
      int size_b = b.find(']', ib) - ib;
      cout << stoi(a.substr(ia, size_a)) + stoi(b.substr(ib, size_b));
      ia += size_a, ib += size_b;
      cout << ']';
    }
    ia ++, ib ++;
  }
  cout << endl;
 
  assert(ia == n && ib == m);
  
  return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n;
	cin >> n;
	vector<int> w(n);
	for(auto& e: w)
		cin >> e;
	int min = 10000;
	for(int i=0; i<n; i++){
		int lsum=0;
		for(int j=i; j>=0; j--)
			lsum+=w[j];
		int rsum=0;
		for(int j=i+1; j<n; j++)
			rsum+=w[j];
		if(abs(lsum-rsum) < min)
			min = abs(lsum-rsum);
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
/*******************
Problem:
Author:CXY1999
Status:Coding
*******************/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<vector>
#include<set>
#include<cmath>
#include<queue>
#include<algorithm>
#define push_back pb
#define begin BG
#define end ED
typedef long long LL;
using namespace std;
int T;
LL a,b,c,d;
LL llgcd(LL a,LL b){return (b==0)?a:llgcd(b,a%b);}
 
int main()
{
	//freopen("a.out","w",stdout);
	cin>>T;
	while(T--)
	{
		cin>>a>>b>>c>>d;
		if(a<b){puts("No");continue;}
		if(d<b){puts("No");continue;}
		if(c>=b){puts("Yes");continue;}
		a%=b;
		d%=b;
		//Ä¤bÒâÒåÏÂ
		LL left=c-a;
		LL right=b-a;
		//[c+1,b-1]
		LL r=llgcd(b,d);
		if(left<0){puts("No");continue;}
		else{
			if((d==0)||((left/r+1)*r>=right)){puts("Yes");continue;}
			else {puts("No");continue;}
		}
	}
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class _0106
{
    public static void Main()
    {
        Dictionary<string, int> index = new Dictionary<string, int>();
        string bar;
        int ans, tans, ca, cb, cc;
        for (int i = 100; i <= 50000; i += 100)
        {
            ans = int.MaxValue;
            for (int a = 0; a <= i / 200; a++ )
                for(int b = 0; b <= (int)((i - a * 200) / 300); b++)
                    for (int c = 0; c <= (int)((i - a * 200 - b * 300) / 500); c++)
                    {
                        if (a * 200 + b * 300 + c * 500 == i)
                        {
                            ca = a % 5; cb = b % 4; cc = c % 3;
                            tans = (int)(380 * (a - ca) * 0.8 + 550 * (b - cb) * 0.85 + 850 * (c - cc) * 0.88)
                                    + 380 * ca + 550 * cb + 850 * cc;
                            if (tans < ans) ans = tans;
                        }
                    }
            index[i.ToString()] = ans;
        }
        while ((bar = Console.ReadLine()) != null && bar[0] != '0')
            Console.WriteLine(index[bar].ToString());
    }
}

Measured memory_bytes: 5788
#include <stdio.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main() {
    long long n, a, b;
    scanf("%lld %lld %lld", &n, &a, &b);
    long long x = n / (a + b);
    long long y = n % (a + b);
    printf("%lld", a * x + MIN(a, y));
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  String s=sc.next();
  char[] c=s.toCharArray();
  int i=0,j=n-1;
  int count=0;
  while(i<=j){
if(c[i]=='W'&&c[j]=='R'){
   char temp=c[i];
   c[i]=c[j];
   c[j]=temp;
   i++;j--;
   count++;
   }else if(c[i]=='R'&&c[j]=='R'){
i++;
   }else{
j--;
   }
   }
   System.out.println(count);
   }
   }
   

Measured memory_bytes: 40908
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val s = sc.next()
    val a = s.filter { it == 'a' }.count()
    val b = s.filter { it == 'b' }.count()
    val c = s.filter { it == 'c' }.count()

    val x = listOf(a, b, c).sorted()
    println(if (x[2] - x[0] <= 1) "YES" else "NO")


}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 33804