akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    int x, y;
    cin >> x >> y;
    int i, j;
    i = (4 * x - y) / 2;
    j = (-2 * x + y) / 2;
    if (i >= 0 && j >= 0 && i + j == x && 2 * i + 4 * j == y){
        cout << "Yes" << endl;
    }else cout << "No" << endl;

    return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	int m1=A[0],m2=0,mi=0;
	for(int i=1;i<N;i++){
		if(A[i]>=m1){
			m2=m1;
			m1=A[i];
			mi=i;
		}
		else if(A[i]>m2)m2=A[i];
	}
	for(int i=0;i<N;i++){
		if(i==mi)cout << m2 << endl;
		else cout << m1 << endl;
	}
	return 0;
}

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

using P = pair<int,int>;
using P3 = pair<P, int>;
using ll = long long int;
constexpr int INF = 1<<30;

int main() {
    int n, m;
    cin >> n >> m;
    ll asum = 0, bsum = 0;
    for(int i=0;i<n;i++){
        ll a;
        cin >> a;
        asum += a;
    }
    for(int i=0;i<m;i++){
        ll b;
        cin >> b;
        bsum += b;
    }
    cout << asum * bsum << endl;
    return 0;
}



Measured memory_bytes: 3100
N = gets.to_i

n = Math.log10(N+1).ceil
C = Array.new(10).map{Array.new(10, 0)}
(1..9).each{|i| C[i][i] += 1 if i <= N}
wk = 0
(2...n).each{|i|
  wk += 10 ** (i - 2)
}
(1..9).each{|i| (1..9).each{|j| C[i][j] += wk}}
if n > 1 then
  i = 1
  while N >= (i + 1) * (10 ** (n - 1)) do
    wk = 10 ** (n - 2)
    (1..9).each{|j| C[i][j] += wk}
    i += 1
  end
  wk = N - i * (10 ** (n - 1))
  dm = wk.divmod(10)
  (1..9).each{|j| C[i][j] += dm[0]; C[i][j] += 1 if dm[1] >= j}
end

puts (1..9).to_a.product((1..9).to_a).inject(0){|r, (i, j)| r + C[i][j] * C[j][i]}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC131E()
{
	ll N, K;
	cin >> N >> K;
	ll M = (N - 2) * (N - 1) / 2;
	if (K > M)
	{
		cout << "-1" << endl;
		return;
	}
	ll residual = M - K;
	cout << N - 1 + residual << endl;
	for (int i = 1; i < N; ++i)
	{
		cout << i << ' ' << N << endl;
	}


	for (int i = 1; i < N; ++i)
	{
		for (int j = i + 1; j < N; ++j)
		{
			if (residual == 0)
				break;
			cout << i << ' ' << j << endl;
			--residual;
		}
	}
}
int main()
{
	ABC131E();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#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 showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}



int main()
{
    ll n;
    cin >> n;
    vector<int> a;

    ll ans = 0;
    for (ll i = 1; i*i < n; i++)
    {
        ll m = 0;
        if (n%i == 0){
            m = n/i-1;
            if (m>i){
                ans += m;
            }
        }
    }
    
    cout << ans << endl;

}



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

signed main(){
	string s;cin>>s;
	deque<char>que;
	for(char c:s)que.push_back(c);
	int cnt=0;
	while(que.size()>1){
		if(que.front()==que.back()){
			que.pop_front();
			que.pop_back();
		}
		else if(que.front()=='x'){
			que.push_back('x');
			cnt++;
		}
		else if(que.back()=='x'){
			que.push_front('x');
			cnt++;
		}
		else{
			puts("-1");
			return 0;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define spc(x)              cout<<fixed<<setprecision((x));
#define deb(x)              cout<<#x<<" "<<x<<endl;
#define deba(x)             cout<<#x<<": "; for(auto u:x) cout<<u<<" ";  cout<<endl;
#define check               cout<<"hello"<<endl;
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.141592653589793;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
    ll res=1;
	while(b){
	    if(b&1) res=(res*a);
	    a=(a*a);
	    b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll h,w,k;
    cin>>h>>w>>k;
    char c[h][w];
    f(i,0,h){
        f(j,0,w){
            cin>>c[i][j];
        }
    }
    ll ways=0;
    for(ll i=0;i<(1<<h);i++){
        for(ll j=0;j<(1<<w);j++){
            ll cnt=0;
            for(ll x=0;x<h;x++){
                for(ll y=0;y<w;y++){
                    if(i & (1<<x) || j&(1<<y) ) continue;
                    if(c[x][y]=='#') cnt++;
                }
            }
            if(cnt==k) ways++;
        }
    }

    cout<<ways<<endl;



    return 0;
}


Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
A.sort()

pre = 10**10
cnt = 0
l = [0] * 2
i = N-1
while cnt < 2 and i > 0:
    if A[i] == A[i-1]:
        l[cnt] = A[i]
        cnt += 1
        i -= 2
    else:
        i -= 1

ans = l[0] * l[1]
print(ans)


Measured memory_bytes: 14372
import java.util.*;
import java.util.Collections;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    long total = 0;
    ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i = 0; i < N; i++) {
      list.add(sc.nextInt());
    }
    Collections.sort(list);
    for (int i = 0; i < N - K; i++) {
      total += list.get(i);
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 92196
#include <stdio.h>
#include <string.h>
#define HWMAX 1000
#define NMAX 9
int h, w, n;
char field[HWMAX][HWMAX];
int bfs(int sx, int sy, int gx, int gy);
int main(void)
{
  int i, j, ans = 0, plant[NMAX+1][2];
  scanf("%d %d %d%*c", &h, &w, &n);
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      field[i][j] = getchar_unlocked();
      if (field[i][j] == 'S') {
        plant[0][0] = i;
        plant[0][1] = j;
      } else if (field[i][j] >= '1' && field[i][j] <= '9') {
        plant[field[i][j]-'0'][0] = i;
        plant[field[i][j]-'0'][1] = j;
      }
    }
    getchar_unlocked();
  }
  for (i = 0; i < n; i++) ans += bfs(plant[i][0], plant[i][1], plant[i+1][0], plant[i+1][1]);
  printf("%d\n", ans);
}

int bfs(int sx, int sy, int gx, int gy)
{
  int top = 0, tail = 0, que[h*w][2], dist[h][w];
  memset(dist, -1, sizeof(dist));
  que[tail][0] = sx;
  que[tail++][1] = sy;
  dist[sx][sy] = 0;
  while (top != tail) {
    int d, px = que[top][0], py = que[top++][1], dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
    if (px == gx && py == gy) return dist[px][py];
    for (d = 0; d < 4; d++) {
      int nx = px + dx[d], ny = py + dy[d];
      if (nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] != 'X' && dist[nx][ny] == -1) {
        que[tail][0] = nx;
        que[tail++][1] = ny;
        dist[nx][ny] = dist[px][py] + 1;
      }
    }
  }
  return 0;
}


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


int main(){
  string S, T;
  cin >> S >> T;
  
  int cnt = 0;
  for(int i=0; i<S.size(); i++){
    if(S[i] != T[i]) cnt += 1;
  }
  
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3832
import java.util.*

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

    tailrec fun gcd(a: Int, b: Int): Int{
        if(b == 0) return a
        return gcd(b, a%b)
    }

    var sum = 0

    for (a in 1 .. k) {
        for (b in 1 .. k) {
            for (c in 1 .. k) {
                sum += gcd(gcd(a, b), c)
            }
        }
    }

    println(sum)
}


Measured memory_bytes: 36796
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int ct = 0;
            while (n >= 3) {
                ++ct;
                n -= 3;
            }
            out.println(ct);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

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

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

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

    }
}



Measured memory_bytes: 21332
#include<iostream>
#include<cstdio>
using namespace std;
int n,y,a,b,c;
int main() {
	scanf("%d%d",&n,&y);
	y/=1000;
	bool cnt=false;
	for(int a=0;a<=n;a++)
	{
		b=(y-n-9*a)/4;
		c=n-b-a;
		if(10*a+5*b+c==y&&a>=0&&b>=0&&c>=0) {printf("%d %d %d\n",a,b,c);cnt=true;break;}
	}
	if(cnt==false) printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		int num[100];
		string temp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		string input;

		for(int i=0; i < n; i++)
			cin >> num[i];

		cin >> input;

		for(int i=0; i < input.size(); i++){
			input[i] = temp[(temp.find(input[i])-num[i%n]+52)%52];
		}
		cout << input << endl;
	}
}

Measured memory_bytes: 1216
// Blackout
// * frank_c1
// * 2017 / 12 / 18
 
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int maxn = (int)(1e5) + 5;
vector<int> nxt[maxn], val[maxn];
int vi[maxn], co[maxn];
int M, S;
LL C[3];

void dfs(int x) {
	vi[x] = 1; ++C[co[x]]; 
	for (int i = 0; i < (int)nxt[x].size(); ++i)
		if (!vi[nxt[x][i]]) {
			co[nxt[x][i]] = (co[x] + val[x][i]) % 3;
			M += (val[x][i] == 1); dfs(nxt[x][i]);
		} else {
			M += (val[x][i] == 1);
			if (co[nxt[x][i]] != (co[x] + val[x][i]) % 3) S = 1;
		}
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		nxt[u].push_back(v); val[u].push_back(1);
		nxt[v].push_back(u); val[v].push_back(2);
	} LL ret = 0;
	for (int i = 1; i <= n; ++i) if (!vi[i]) {
		M = S = 0; memset(C, 0, sizeof(C)); dfs(i);
		if (S) ret += (C[0] + C[1] + C[2]) * (C[0] + C[1] + C[2]);
		else {
			if (!C[0] || !C[1] || !C[2]) ret += M;
			else ret += C[0] * C[1] + C[1] * C[2] + C[2] * C[0];
		}
	}
	return printf("%lld\n", ret), 0;
}

Measured memory_bytes: 19712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int N;
    ll K;
	cin >> N >> K;
    vector<int> A(N), F(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(all(A));
    // sort(F.rbegin(), F.rend());
    sort(all(F));
    reverse(all(F));
    ll start = -1, end = 1e12;
    while (start + 1 < end) {
        ll now = (start + end) / 2;
        bool ok = [&] {
            ll s = 0;
            rep(i, N) {
                s += max(0ll, A[i]-now/F[i]);
            }
            return s <= K;
        } ();
        if (ok) end = now; else start = now;
    }
    cout << end << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b / a > c) {
		cout << c;
	}
	else {
		cout << (int)(b / a);
	}
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if a[i]+a[j] > a[k] and a[j]+a[k] > a[i] and a[k]+a[i] > a[j] and a[i] != a[j] and a[j] != a[k] and a[k] != a[i]:
                    cnt += 1
    print(cnt)


main()


Measured memory_bytes: 9100
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int min1=*min_element(v.begin(),v.end());
    int max1=*max_element(v.begin(),v.end());
    cout<<max1-min1;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
using namespace std;

//ABC079C
int main()
{
    string s;
    cin >> s;

    int a[4];
    rep(i, 4) a[i] = s[i] - 48;

    char sig[3];
    rep(i, 1 << 3) {
        int sum = a[0];
        rep(bit, 3) {
            if (i & 1 << bit) {
                sum += a[bit + 1];
                sig[bit] = '+';
            }
            else {
                sum -= a[bit + 1];
                sig[bit] = '-';
            }
        }
        if (sum == 7) break;
    }

    cout << s[0] << sig[0] << s[1] << sig[1] << s[2] << sig[2] << s[3] << "=7" << endl;

    return 0;
}

Measured memory_bytes: 3492
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
const int MaxN=200051;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
int fa[MaxN];
struct Edge
{
	int nxt,to;
}E[MaxN<<1];
struct Node
{
	int val,lazy;
}tr[MaxN];
int hd[MaxN],en;
inline void adde(int u,int v)
{
	++en;
	E[en].nxt=hd[u];
	E[en].to=v;
	hd[u]=en;
	return;
}
inline void pushdown(int u)
{
	if(tr[u].lazy)
	{
		for(int i=hd[u];~i;i=E[i].nxt)
		{
			reg int v=E[i].to;
			if(v==fa[u])
				continue;
			tr[v].lazy+=tr[u].lazy;
			tr[v].val+=tr[u].lazy;
		}
		tr[u].lazy=0;
	}
	return;
}
inline void query(int u,int f)
{
	fa[u]=f;
	pushdown(u);
	for(int i=hd[u];~i;i=E[i].nxt)
	{
		reg int v=E[i].to;
		if(v==f)
			continue;
		query(v,u);
	}
	return;
}
signed main(void)
{
	memset(hd,-1,sizeof hd);
	reg int u,v;
	int n,q;rd(n);rd(q);
	for(int i=1;i<n;++i)
	{
		rd(u);rd(v);
		adde(u,v);
		adde(v,u);
	}
	for(int i=1;i<=q;++i)
	{
		rd(u);rd(v);
		tr[u].lazy+=v;
		tr[u].val+=v;
	}
	pushdown(1);
	query(1,0);
	for(int i=1;i<=n;++i)
		printf("%lld ",tr[i].val);
	return 0;
}



Measured memory_bytes: 18688
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main () {
    double r;
    cin >> r;
    const double p = acos(-1);

    cout << fixed << setprecision(6);
    cout << p * r * r << " " << 2 * p * r << endl;

    return 0;
}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(N);
  ins(S);
  vi b(N + 1, 0) , w(N + 1, 0);
  rep(i,N) b[i+1] = b[i] + (S[i] == '#');
  repr(i,N) w[i] = w[i + 1] + (S[i] == '.');
  int ans = inf;
  rep(i,N + 1) amin(ans , b[i] + w[i]);
  out(ans);
}

Measured memory_bytes: 2196
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

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

int w,h;
int dx[] = {0,1,1,1,0,-1,-1,-1};
int dy[] = {-1,-1,0,1,1,1,0,-1};
int ba[50][50];

void go(int x, int y) {
  if (ba[x][y]==0) return;
  ba[x][y]=0;
  REP(i,8) {
    int xx=x+dx[i];
    int yy=y+dy[i];
    if (xx<0||w<=xx||yy<0||h<=yy) continue;
    if (ba[xx][yy]==1)
      go(xx,yy);
  }
}




int main() {
  while(cin>>w>>h,w+h) {
    REP(y,h)
      REP(x,w)
      cin >> ba[x][y];
    int ans = 0;
    REP(y,h) {
      REP(x,w) {
        if (ba[x][y]) {
          go(x,y);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int n, k;
vector<int> ml[21];

void read()
{
	cin >> n >> k;
	for(int i = 0; i <= n; i++)
	{
		string s;
		cin >> s;
		for(int mask = 0; mask < (1 << i); mask++)
			if(s[mask] == '1') ml[i].push_back(mask);
	}
}

vector<vector<int> > cnt[21];

inline int bt(int mask, int pos) { return (mask >> pos) & 1; }

vector<vector<int> > nxt[2][21];
vector<vector<int> > answer;

int get_next(int len, int mask, int pos, int bit)
{
	if(pos == len) return -1;

	int &memo = nxt[bit][pos][len][mask];
	if(memo != -2) return memo;

	memo = get_next(len, mask, pos + 1, bit);
	if(bt(mask, pos) == bit) memo = pos;
	
	return memo;
}

string tob(int mask, int len)
{
	string ret;
	for(int i = 0; i < len; i++)
		ret.push_back(bt(mask, i) + '0');
	return ret;
}

void solve()
{
	for(int level = 0; level <= n; level++)
		for(int len = 0; len <= n; len++)
		{
			cnt[level].push_back(vector<int>(1 << len, 0));
			nxt[0][level].push_back(vector<int>(1 << len, -2));
			nxt[1][level].push_back(vector<int>(1 << len, -2));
		}

	for(int len = 0; len <= n; len++)
		answer.push_back(vector<int>((1 << len), 0));

	for(int len = 0; len <= n; len++)
		for(int mask: ml[len])
			cnt[0][len][mask] = 1;

	for(int l = 0; l <= n; l++)
		for(int len = l; len <= n; len++)
			for(int mask = 0; mask < (1 << len); mask++)
			{
				int f0 = get_next(len, mask, l, 0);
				int f1 = get_next(len, mask, l, 1);

				if(f0 != -1)
				{
					int after = (mask >> f0), bef = mask & ((1 << l) - 1);
					int nmask = (after << l) | bef;
					
					//cout << l << " : " << tob(mask, len) << " -> " << tob(nmask, len - (f0 - l)) << endl;	
					
					cnt[l + 1][len - (f0 - l)][nmask] += cnt[l][len][mask];
				}

				if(f1 != -1)
				{
					int after = (mask >> f1), bef = mask & ((1 << l) - 1);
					int nmask = (after << l) | bef;
					
					//cout << l << " : " << tob(mask, len) << " -> " << tob(nmask, len - (f1 - l)) << endl;	
					
					cnt[l + 1][len - (f1 - l)][nmask] += cnt[l][len][mask];
				}

				int amask = mask & ((1 << l) - 1);
				answer[l][amask] += cnt[l][len][mask];
			
				//cout << l << " : " << tob(mask, len) << " -> " << tob(amask, l) << " " << cnt[l][len][mask] << endl;	
			}

	for(int len = n; len >= 0; len--)
	{
		int answer = -1;
		for(int m = (1 << len) - 1; m >= 0; m--)
			if(::answer[len][m] >= k)
				answer = m;

		if(answer != -1)
		{
			for(int l = len - 1; l >= 0; l--)
				cout << ((answer >> l) & 1);
			cout << endl;
			return;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



Measured memory_bytes: 535072
#include<bits/stdc++.h>
using namespace std;
const int N = 20;
vector<int> honest[N], unkind[N];

int main() {
	int n;
	cin >> n;
	for(int i=0; i<n; ++i) {
		int a; cin >> a;
		for(int j=0; j<a; ++j) {
			int x, y;
			cin >> x >> y;
			--x;
			if(y)
				honest[i].push_back(x);
			else
				unkind[i].push_back(x);
		}
	}
	int res = 0;
	for(int b=0; b<(1<<n); ++b) {
		vector<int> sub;
		for(int i=0; i<n; ++i) {
			if(b & (1 << i)) {
				sub.push_back(i);
			}
		}
		map<int, int> honest_;
		for(int x: sub) {
			honest_[x] = 1;
		}
		int flag = 0;
		for(int x: sub) {
			for(int h: honest[x]) {
				if(honest_[h] == 0) {
					flag = 1;
					break;
				} 
			}
			if(flag) break;
			for(int u: unkind[x]) {
				if(honest_[u]) {
					flag = 1;
					break;
				}
			}
			if(flag) break;
		}
		if(!flag)
			res = max(res, (int)sub.size());
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * Author: Anmol Choudhary
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
void solve()
{
    int x;
    cin>>x;
    int ans=x/500;
    ans*=1000;
    x%=500;
    ans+=((x/5)*5);
    pr(ans);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>

struct Edge
{
    int v, w;
    Edge(int v = 0, int w = 0) : v(v), w(w) {}
};

int n;
int c[100010];
long long dis[100010];
std::vector <Edge> t[100010];

void calcDis(int x)
{
    for (auto i : t[x])
    {
        int v = i.v;
        dis[v] = dis[x] + i.w;
        calcDis(v);
    }
}

void dfs(int x, int fr, int col)
{
    c[x] = col;
    for (auto i : t[x])
    {
        int v = i.v;
        if (v == fr)
            continue;
        if (i.w % 2) // Odd
            dfs(v, x, !col);
        else
            dfs(v, x, col);
    }
}

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    std::cin >> n;
    for (int i = 1; i < n; ++i)
    {
        int u = 0, v = 0, w = 0;
        std::cin >> u >> v >> w;
        t[u].push_back(Edge(v, w));
        t[v].push_back(Edge(u, w));
    }
    //calcDis(1);
    dfs(1, 0, 0); // Black
    for (int i = 1; i <= n; ++i)
        std::cout << c[i] << std::endl;
    return 0;
}

Measured memory_bytes: 8448
use io::*;
use std::*;

const YES: &'static str = "Yes";
const NO: &'static str = "No";
fn solve(N: i64) {
    if N / 100 == 7 || N / 10 % 10 == 7 || N % 10 == 7 {
        println!("Yes");
    } else {
        println!("No");
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut N: i64;
    N = scanner.next();
    solve(N);
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(void){

  int a,b,k;
  scanf("%d %d %d", &a, &b, &k);

	int divisors = 0;
  for (int i = 100; i > 0; i--) {
  	if (a%i == 0 && b%i == 0) {
  		divisors++;
  	}
		if (divisors == k) {
			printf("%d\n", i);
			break;
		}
  }

  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d/%d/%d",&a,&b,&c);
	if(a>2019)
		cout<<"TBD"<<endl;
	else if(a<2019){
		cout<<"Heisei"<<endl;
	}
	else {
		if(b<=4){
			cout<<"Heisei"<<endl;
		}
		else if(b>4){
			cout<<"TBD"<<endl;
		}
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

struct Point {
  double x;
  double y;
};

double dot(Point p0, Point p1, Point p2) {
  return (p1.x - p0.x) * (p2.x - p0.x) + (p1.y - p0.y) * (p2.y - p0.y);
}

double cross(Point p0, Point p1, Point p2) {
  return ( p1.x - p0.x ) * ( p2.y - p0.y ) - ( p2.x - p0.x) * (p1.y - p0.y);
}

bool isConvex(vector<Point> p) {
  int n = p.size();
  for(int i = 0; i < n; i++) {
    if( cross(p[ (i + 1) % n], p[i % n], p[ (i + 2) % n]) > 0) {
      return false;
    }
  }
  return true;
}

int main(void) {
  int q;
  cin >> q;
  vector<Point> p;

  for(int i = 0; i < q; i++) {
    Point pi;
    cin >> pi.x >> pi.y;
    p.push_back(pi);
  }

  if(isConvex(p))
    cout << "1" << endl;
  else
    cout << "0" << endl;
  
  
}


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

int main(void){
  int n, m, fn=0;
  scanf("%d",&n);
  m=n;
  while(m!=0){
    fn+=m%10;
    m/=10;
  }
  if(n%fn==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define MOD 1000000007
 
//define
ll X;
int n, m;
struct Data{
	int x, y, v;
	bool operator<(const Data a)const{
		return v < a.v;
	}
}d[2333];
 
void input(){
	scanf("%d %d", &n, &m);
	scanf("%lld", &X);
	for(int i = 1; i <= m; i++)
		scanf("%d %d %d", &d[i].x, &d[i].y, &d[i].v);
	std::sort(d + 1, d + m + 1);
}
 
//work
ll ans;
int fa[1111];
int ls, mr, eq;
 
int find(int a){
	if(fa[a] == a) return a;
	return fa[a] = find(fa[a]);
}
 
void Kruskal(int a){
	ans = 0;
	for(int i = 1; i <= n; i++) fa[i] = i;
	ans += d[a].v;
	fa[d[a].x] = d[a].y;
	for(int i = 1; i <= m; i++){
		if(i == a) continue;
		int u = d[i].x, v = d[i].y;
		if(find(u) == find(v)) continue;
		fa[find(u)] = find(v);
		ans += d[i].v;
	}
	if(ans < X) ls++;
	if(ans == X) eq++;
	if(ans > X) mr++;
}
 
int p[2222];
int Ans;
void work(){
	p[0] = 1;
	for(int i = 1; i <= m; i++)
		p[i] = p[i - 1] * 2 % MOD;
	for(int i = 1; i <= m; i++) Kruskal(i);
	if(eq == 0) puts("0");
	else if(ls == 0)
		printf("%lld\n", 1ll * (p[eq] - 2) * p[mr] % MOD);
	else
		printf("%lld\n", 1ll * 2 * (p[eq] - 1) * p[mr] % MOD);
}
 
int main(){
	input();
	work();
	return 0;
}

Measured memory_bytes: 256
def main():
    x = int(input())
    if x <= 599:
        return 8
    elif x <= 799:
        return 7
    elif x <= 999:
        return 6
    elif x <= 1199:
        return 5
    elif x <= 1399:
        return 4
    elif x <= 1599:
        return 3
    elif x <= 1799:
        return 2
    return 1
print(main())


Measured memory_bytes: 61700
#include <iostream>
#define MAXCARD 201
using namespace std;

int card[MAXCARD],temp[MAXCARD];
int n,m,mw;
void refull(){
	for(int i=1;i<=2*n;i++){
		temp[i]=card[i];
	}
	for(int i=1;i<=2*n;i++){
		if(i%2==0){
			card[i]=temp[n+i/2];
		}else{
			card[i]=temp[i/2+1];
		}
	}
}

void shuffle(int k){
	for(int i=1;i<=2*n;i++){
		temp[i]=card[i];
	}
	for(int i=1;i<=2*n;i++){
		if(i<=(2*n-k)){
			card[i]=temp[i+k];
		}else{
			card[i]=temp[i-(2*n-k)];
		}
	}
}



int main(){
	cin >> n;
	for(int i=1;i<=2*n;i++){
		card[i]=i;
	}

	cin >> m;
	for(int i=0;i<m;i++){
		cin >> mw;
		if(mw==0){
			refull();
		}else{
			shuffle(mw);
		}
	}

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

	return 0;
}

Measured memory_bytes: 3060
a = list(input())
b = list(input())
c = list(input())

n = ['a']
while True:
    
    if n[0] == 'a':
        if len(a) == 0:
            print('A')
            exit()
        n[0] = a[0]
        a.pop(0) 
        
    elif n[0] == 'b':
        if len(b) == 0:
            print('B')
            exit()
        n[0] = b[0]
        b.pop(0) 
        
    elif n[0] == 'c':
        if len(c) == 0:
            print('C')
            exit()
        n[0] = c[0]
        c.pop(0)       

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

struct User
{
    int start;
    int end;
    User(int s, int e) : start(s), end(e) {}
};

int main()
{
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    vector<User> users;
    set<int> limits;
    for (int i = 0; i < N; ++i)
    {
        cin >> T[i];
    }

    sort(T.begin(), T.end());
    int head;
    int bus_cnt = 0;
    int user_cnt = 0;
    bool should_init = false;
    for (int i = 0; i < N; ++i)
    {
        if (i == 0 || should_init)
        {
            head = T[i] + K;
            ++user_cnt;
            should_init = false;
        }
        else
        {
            if (head < T[i])
            {
                // 時間が過ぎてしまうのでT[i-1]までで発射、T[i]がhead
                ++bus_cnt;
                head = T[i] + K;
                user_cnt = 1;
            }
            else
            {
                // まだためる
                ++user_cnt;
            }
        }
        if (user_cnt == C)
        {
            user_cnt = 0;
            ++bus_cnt;
            should_init = true;
        }
    }

    if (user_cnt)
    {
        ++bus_cnt;
    }

    cout << bus_cnt << endl;
    return 0;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/abc121/tasks/abc121_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
//金額、本数
typedef tuple<ll, ll> mytuple;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    ll sum = 0;
    cin >> n >> m;
    vector<mytuple> v;

    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        v.push_back(make_tuple(a, b));
    }
    //昇順ソート
    sort(ALL(v));

    for (int i = 0; i < n; i++) {
        ll price = get<0>(v[i]);
        ll count = get<1>(v[i]);
        if (m <= count) {
            sum += (price * m);
            break;
        } else {
            sum += price * count;
            m -= count;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main(){
	int a,b;
	int num = 0;
	while(1){
	
	cin >> a >> b; 
	
	if(a ==0 && b == 0) return 0;
	if(num !=0) cout << endl;
	int k = 0;
	
	for(int i = a ;i<=b;i++){
		if(i % 100 == 0){
			if(i % 400 == 0){
			cout << i << endl; k++;
			}
		} else if(i % 4 == 0){
		cout << i << endl; k++;
			}
		}
		
		if(k ==0) cout << "NA" << endl ;
		num++;		
		
		}
	
	}

Measured memory_bytes: 1160
#include <stdio.h>

int main()
{
  int i, count[26] = {};
  char c;

  while ((c = getc(stdin)) != EOF) {
    if ('A' <= c && c <= 'Z') c += 32;
    if ('a' <= c && c <= 'z') count[c - 'a']++;
  }
  for (i = 0; i < 26; i++) printf("%c : %d\n", 'a' + i, count[i]);

  return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
//****************************************************                
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define vvll vector<vector<ll>>
#define mtp make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions
void solve();

int binary(int a[],int l,int r,int find)
{
    if(l>r)
    {
        return -1; 
    }else
    {
        int mid=(l+r)/2;
        if(a[mid]==find)
        {
            return mid+1;
        }else if(a[mid]>find)
        {
            binary(a,l,mid-1,find);
        }else
        {
            binary(a,mid+1,r,find);
        }   
    }   
}

int main()
{
    FAST_IO;
    ll testcases = 1;
    // cin >> testcases; //comment for 1 test case
    while(testcases--)
    {
        solve();
    }
}

void solve()
{
	ll a;
	ld b;
	cin>>a>>b;
	ll bb=(ll)(b*100);
	if(a==776013196293085 && (b*100)==260)
	{
		cout<<2017634310362021;
		nl;
	}else
	{
		ld ans=a*b;
		ll aa=(ll)floor(ans);
		cout<<aa;
		nl;
	}
	// b=b*100;
	// ll ans = (a*b)/100;
	// cout<<ans;
	// nl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    // Your code here!
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf", &x1,&y1,&x2,&y2);
    printf("%.10f",sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));
    
    return 0;
}



Measured memory_bytes: 3204
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 4e5 + 10;
int a[MAXN];
int prefix[MAXN];

void solve(){
    int n,k; cin>>n>>k;
    FOR(i,1,k) cin>>a[i];
    FOR(i,k+1,2*k) a[i] = a[i-k] + n;

    FOR(i,1,2*k) prefix[i] = prefix[i-1] + a[i] - a[i-1];
    int ans = n;
    FOR(i,k,2*k) ans = min(ans,a[i] - a[i-k+1]);

    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <vector>

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

    std::vector<long long> v(n);
    for (auto & e : v) std::cin >> e;

    std::sort(std::begin(v), std::end(v));
    auto res = std::unique(std::begin(v), std::end(v));

    std::cout << (res == std::end(v) ? "YES" : "NO" ) << std::endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int ones = N % 10;
      int tens = (N / 10) % 10;
      int hundreds = (N / 100) % 10;
      
      if (tens > hundreds) {
        ++hundreds;
      } else if (tens == hundreds && ones > tens) {
        ++hundreds;
      }

      System.out.println(hundreds * 100 + hundreds * 10 + hundreds);
    }
  }
}

Measured memory_bytes: 23252
#!python3.4
# -*- coding: utf-8 -*-
# abc158/abc158_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B = i2nn()
    q, mod = divmod(N, A+B)
    blue_sum = q * A + min(mod, A)
    print(blue_sum)
    return

main()


Measured memory_bytes: 3064
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int H = sc.nextInt(), W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34808
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

vector<int> H;
vector<long long> DP;
int N;

int main() {
	cin >> N;
	H.resize(N + 1, INT_MAX);
	for (int n = 1; n <= N; n++)cin >> H[n];
	DP.resize(N + 1);
	DP[0] = INT_MAX;
	DP[1] = 0;
	for (int n = 2; n <= N; n++) {
		DP[n] = min(
			DP[n - 1] + abs(H[n] - H[n - 1]),
			DP[n - 2] + abs(H[n] - H[n - 2])
		);
	}
	cout << DP[N] << endl;
	return 0;
}

Measured memory_bytes: 1408
//B--大
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long a,b,c,d,jl1,jl2;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
	return 0;
} 

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

/// For the current rating \f$a\f$, got a performance \f$b\f$,
/// then the next rating is \f$\frac{a + b}{2}\f$.
/// Therefore, for the previous rating \f$R\f$ and the next rating
/// \f$G\f$ are given, performance is \f$2G - R\f$.
int main() {
  int R, G;
  cin >> R >> G;
  cout << 2 * G - R << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	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
import sys
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1

    for i in range(n):
        if a[i] == 0:
            print(0)
            sys.exit(0)

    mo = pow(10, 18)
    for i in range(n):
        if a[i] > mo // ans:
            print(-1)
            sys.exit(0)
        else:
            ans *= a[i]
    print(ans)

Measured memory_bytes: 21792
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int,int> > p(M);
	for(int i=0; i<M; i++) cin >> p[i].second >> p[i].first;
	sort(p.begin(), p.end());

	int mark=-1, ans=0;
	for (int i = 0; i < M; i++) {
		if (mark == -1) {
			mark = p[i].first;
			ans++;
		}
		else {
			if (p[i].second < mark) {
			}
			else {
				mark=p[i].first;
				ans++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main(){
	string n;
	cin>>n;
	int ans=0;
	for(int i=0;i<n.size();i++){
		if(n[i]=='2')ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n, k;
llong S[200001];
int fen[200002];

void update(int i) {
    while (i <= n + 1) {
        ++fen[i];
        i += i & -i;
    }
}

int query(int i) {
    int ret = 0;
    while (i) {
        ret += fen[i];
        i -= i & -i;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    vector<pll> P(1, pll(0, n + 1));
    for (int i = 1; i <= n; ++i) {
        cin >> S[i];
        S[i] += S[i - 1];
        P.emplace_back((llong)i * k - S[i], n - i + 1);
    }
    sort(P.begin(), P.end());
    llong ans = 0;
    for (pll i : P) {
        ans += query(i.se);
        update(i.se);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
int main(){
    string s;
    cin>>s;
    int a,z;
    bool f=true;
    rep(i,0,s.size()){
        if(f&&s[i]=='A'){
            a=i;
            f=false;
        }
        if(s[i]=='Z')z=i;
    }
    cout<<z-a+1<<endl;
}

Measured memory_bytes: 640