akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define LL long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    int n,k; cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a, a+n);
    LL sum=0l;
    for(int i=0;i<k;i++) sum+=a[i];
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;
class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int i = 0;
		int j = 0;
		for(i = a ; i <= b ; i++){
			if(c % i ==0){
				j++;
			}
		}
		System.out.println(j);
	}

}

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

int main()
{
    int A, B, ans = 0;
    cin >> A >> B;

    for (int i = 0; i < B && B-i > 1;) {
        i += A-1;
        ans++; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        String str = sc.next();
        
        int[] tmp = new int[3];
        tmp[0] = Integer.parseInt(String.valueOf(str.charAt(0)));
        tmp[1] = Integer.parseInt(String.valueOf(str.charAt(2)));
        tmp[2] = Integer.parseInt(String.valueOf(str.charAt(3)));
        
        long tmpa = a * tmp[0];
        long tmpb = a * tmp[1];
        long tmpc = a * tmp[2];
        
        long tmpb2 = tmpb / 10;
        long tmpc2 = tmpc / 100;
        
        long tmpb3 = (tmpb % 10) * 10;
        long tmpc3 = tmpc % 100;
        
        long tmpx = (tmpb3 + tmpc3) / 100;
        System.out.println(tmpa + tmpb2 + tmpc2 + tmpx);
    }
}


Measured memory_bytes: 35756
import math

N = int(input())

min_length = -1
for A in range(1, int(math.sqrt(N)) + 1, 1):
    if N % A == 0:
        B = int(N / A)
        len_a = len(str(A))
        len_b = len(str(B))
        length = len_a if len_a >= len_b else len_b
        if min_length == -1 or length < min_length:
            # print("len:{}, A:{}, B:{}".format(length, A, B))
            min_length = length
print(min_length)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,K;
    long long i;
    cin>>N>>K;
    long long count=0;
    for(i=K;i<=N+1;i++ ){
    count+=((N+1-i)*i+1);}
    cout<<count%1000000007<<endl;
    }


Measured memory_bytes: 3592
#include <iostream>
#include <queue>
using namespace std;
struct mpo{
  int mp[20][20];
};
int w,h;
int ex,ey;
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
int ans;

void dps(mpo t,int x,int y,int d){
  if(x==ex&&y==ey) ans=min(ans,d);
  else if(d<10){
    for(int i=0;i<4;i++){
      int nx=x+dx[i],ny=y+dy[i];
      if(nx<0||nx>=w||ny<0||ny>=h||t.mp[ny][nx]==1) continue;
      while(1){
	if(nx<0||nx>=w||ny<0||ny>=h) break;
	if(t.mp[ny][nx]==1||t.mp[ny][nx]==3){
	  if(t.mp[ny][nx]==3) dps(t,nx,ny,d+1);
	  else {
	    t.mp[ny][nx]=0;
	    dps(t,nx-dx[i],ny-dy[i],d+1);
	    t.mp[ny][nx]=1;
	  }
	  break;	
	}
	nx+=dx[i],ny+=dy[i];
      }
    }
  }
}

int main (){
  while(cin>>w>>h && (w||h)){
    mpo ba;
    int sx,sy;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	cin >>ba.mp[i][j];
	if(ba.mp[i][j]==2)sx=j,sy=i;
	if(ba.mp[i][j]==3)ex=j,ey=i;
      }
    ans=11;
    dps(ba,sx,sy,0);
    if(ans==11) cout <<-1<<endl;
    else cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int INF=2e+9+1;
int main(){
	int A,B,C,X,Y;
	scan(A);scan(B);scan(C);scan(X);scan(Y);
	if(A+B<2*C){
		prin(A*X+B*Y);
	}
	else{
		int AB2num=min(X,Y);
		int kane=2*C*AB2num;
		X-=AB2num;
		Y-=AB2num;
		kane+=min(A*X+B*Y,2*C*max(X,Y));
		prin(kane);
	}
	return 0;
}


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

using namespace std;

const long long p=1000000007;
int H,W;
long long K,cnt1,cnt2,cnt3,s1,s2;
char str[1002][1002];

struct matrix{
	long long a[2][2];
	matrix(int e=true){memset(a,0,sizeof(a));for(int i=0;i<2;++i)a[i][i]=e;}
	long long* operator[](const int &i){return a[i];}
	matrix& operator*=(matrix &mtx){
		matrix mtx0(false);
		for(int i=0;i<2;++i)for(int j=0;j<2;++j)for(int k=0;k<2;++k)(mtx0[i][j]+=a[i][k]*mtx[k][j]%p)%=p;
		return (*this)=mtx0;
	}
	matrix& operator^=(long long x){
		matrix mtx,mtx0=*this;
		while(x){if(x&1ll)mtx*=mtx0;mtx0*=mtx0;x>>=1;}
		return (*this)=mtx;
	}
};

inline long long qpow(long long a,long long x){
	long long s=1ll;
	while(x){if(x&1ll)(s*=a)%=p;(a*=a)%=p;x>>=1;}
	return s;
}

int main(){
	scanf("%d%d%lld",&H,&W,&K);
	for(int i=1;i<=H;++i){
		scanf("%s",str[i]+1);if(str[i][1]=='#'&&str[i][W]=='#')++cnt1;
		for(int j=1;j<=W;++j)if(str[i][j]=='#'){++cnt3;s1+=str[i][j]==str[i][j-1],s2+=str[i][j]==str[i-1][j];}
	}
	for(int i=1;i<=W;++i)if(str[1][i]=='#'&&str[H][i]=='#')++cnt2;
	if(cnt1&&cnt2)return puts("1"),0;
	if(!cnt1&&!cnt2)return printf("%lld",qpow(cnt3,K-1ll)),0;
	if(!cnt1)swap(cnt1,cnt2),swap(s1,s2);
	matrix A(false);A[0][0]=cnt3,A[1][0]=s1,A[1][1]=cnt1;A^=K-1ll;
	printf("%lld",(A[0][0]-A[1][0]+p)%p);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
using namespace std;

typedef pair<int,int> P;
double eps=1e-8;
int mod=1e9+7;
int inf=1e9;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end() , l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

signed main(){
  vector<P> v[2];
  int n,a[60],c=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>0)v[0].push_back(P(-a[i],i));
    if(a[i]<0)v[1].push_back(P(a[i],i));
    if(a[i]==-2)c++;
  }

  sort(v[0].begin(),v[0].end());
  sort(v[1].begin(),v[1].end());
  vector<int> ans;
  if(c%2){
    if(v[1].size()==c) c--;
    else c++;
  }
  
  for(int i=0;i<v[0].size();i++)if(v[0][i].first==-2)ans.push_back(v[0][i].second);
  for(int i=0;i<v[1].size();i++)if(c)ans.push_back(v[1][i].second),c--;
  sort(ans.begin(),ans.end());
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++)cout<<ans[i]+1<<endl;
  return 0;
}



Measured memory_bytes: 3168
from collections import deque
H,W=map(int,input().split())
S=[]
for _ in range(H):
    s=input()
    S.append(s)
m=[[0]*W for _ in range(H)]
def DFS(y,x,S):

    d=deque([])
    d.append((y,x,0))
    white=0
    black=0
    while d:
        p,q,n=d.popleft()
        if m[p][q]==1:
            continue
        else:
            if n%2==0 and S[p][q]=='#':
                black+=1
                m[p][q]=1
                if 0<=p+1<=H-1 and S[p+1][q]=='.':
                    d.append((p+1,q,n+1))
                if 0<=p-1<=H-1 and S[p-1][q]=='.':
                    d.append((p-1,q,n+1))
                if 0<=q+1<=W-1 and S[p][q+1]=='.':
                    d.append((p,q+1,n+1))
                if 0<=q-1<=W-1 and S[p][q-1]=='.':
                    d.append((p,q-1,n+1))
            
            elif n%2==1 and S[p][q]=='.':
                white+=1
                
                m[p][q]=1
                if 0<=p+1<=H-1 and S[p+1][q]=='#':
                    d.append((p+1,q,n+1))
                if 0<=p-1<=H-1 and S[p-1][q]=='#':
                    d.append((p-1,q,n+1))
                if 0<=q+1<=W-1 and S[p][q+1]=='#':
                    d.append((p,q+1,n+1))
                if 0<=q-1<=W-1 and S[p][q-1]=='#':
                    d.append((p,q-1,n+1))
    return white,black

total=0
for i in range(H):
    for j in range(W):
        if S[i][j]=='.':
            continue
        elif m[i][j]==1:
            continue
        else:
            w,b=DFS(i,j,S)
            total+=w*b

print(total)
                

Measured memory_bytes: 82708
using System;
     
namespace Sample
{
  class Sample
  {
    static void Main()
    {
      string line = System.Console.ReadLine();
      string []A = line.Split(' ');
      int N = int.Parse(A[0]);
      int K = int.Parse(A[1]);
      line = System.Console.ReadLine();
      string []Hs = line.Split(' ');
      long []H = new long[Hs.Length];
      for(int i = 0; i < H.Length; i++)
      {
        H[i] = int.Parse(Hs[i]);
      }
      Array.Sort(H);

      long C;
      C = 0;
      for(int i = 0; i < N-K; i++)
      {
        C += H[i];
      }
      Console.WriteLine(C);
    }
  }
}

Measured memory_bytes: 33792
using System;
class Program
{
    static void Main(string[] args)
    {
        var bwStr = Console.ReadLine();
        var length = bwStr.Length;
        int a1 = 0;
        int b2 = 0;

        int a = 0;
        for (int i = 0; i < length; i++)
        {
            if(a != int.Parse(bwStr[i].ToString())) a1++;

            if(a == 0){
                a = 1;
            }else{
                a = 0;
            }
        }

        a = 1;
        for (int i = 0; i < length; i++)
        {
            if(a != int.Parse(bwStr[i].ToString())) b2++;

            if(a == 0){
                a = 1;
            }else{
                a = 0;
            }
        }

        if(a1 > b2){
            Console.WriteLine(b2);
        }else{
            Console.WriteLine(a1);
        }
    }
}

Measured memory_bytes: 15328
#include <stdio.h>
#define MAX 100001
int A[MAX],n;
int partition(int p,int r){
  int x,i,j,temp;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  return i+1;
}
int main(){
  int i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 988
#import sys
# import math

def modc(a, b, m):
    c = 1
    for i in range(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1, m) % m
    return c


def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)


def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

N = int(input())
#A, B = list(map(int,input().split()))
S = [''.join(sorted(input())) for _ in range(N)]
D = {}
for s in S :
    if s in D :
        D[s] += 1
    else :
        D[s] = 1
V = list(D.values())

count = 0
for v in V :
    if v == 1 :
        count += 0
    elif v == 2 :
        count += 1
    elif v >= 3 :
        count += modc(v, 2, 2 ** 63 - 1)
print(count)

Measured memory_bytes: 67416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N % 2 == 1){
        cout << "No" << endl;
    }
    else{
        int X = N / 2;
        if (S.substr(0,X) + S.substr(0, X) == S){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	int ans = 0;

	void solve() throws IOException {

		int n = ni();
		int a[] = new int[n + 1];
		int max = 0;
		for (int i = 0; i < n; i++) {
			int k = ni();
			a[k] = a[k - 1] + 1;
			max = Math.max(a[k], max);
		}

		out.println(n - max);
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

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

int main() {
  int n, T;
  string f;
  int ans = 0;
  int temp = 1;
  int flag = 0;

  cin >> n >> T;
  cin >> f;

  for(int i = 0; i < f.size(); i++) {
    if(f[i] >= 48 && f[i] <= 57) {
      flag = 1;
      if(f[i] == 48)
        temp = 1;
      else {
        if(n > 10 && (f[i] - 48) >= 9) {
          cout << "TLE" << endl;
          return 0;
        }
        for(int j = 0; j < (f[i] - 48); j++) {
          temp *= n;
          if(temp > 1000000000) {
            cout << "TLE" << endl;
            return 0;
          }
        }
      }
    }
    if(flag == 1)
      ans += temp;
    if(ans > 1000000000) {
      cout << "TLE" << endl;
      return 0;
    }
    temp = 1;
    flag = 0;
  }
  ans = ans * T;

  if(ans <= 1000000000)
    cout << ans << endl;
  else
    cout << "TLE" << endl;
  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,a[233333];
int l[233333],r[233333];
PII q[233333];
LL ans;
int main(){scanf("%d",&n);rep(i,0,n)scanf("%d",a+i);
    int minum=a[0],m=0;l[0]=0;
    rep(i,1,n)l[i]=r[i]=i;
    memset(q,0,sizeof(q));int head=0,tail=0;
    q[tail]=mp(a[0],0);
    rep(i,1,n){
        while(q[tail].fi>a[i]){
            r[q[tail].se]=i;
            tail--;
            if(tail==-1)break;
        }
        q[++tail]=mp(a[i],i);
    }
    while(head<=tail){
        r[q[head++].se]=n;
    }

    memset(q,0,sizeof(q));head=0;tail=0;
    q[tail]=mp(a[n-1],n-1);
    per(i,0,n-1){
        while(q[tail].fi>a[i]){
            l[q[tail].se]=i;
            tail--;
            if(tail==-1)break;
        }
        q[++tail]=mp(a[i],i);
    }
   // cout<<"!!!"<<head<<"!!!"<<tail<<endl;
    while(head<=tail){
        l[q[head++].se]=-1;
    }

    rep(i,0,n){
      //  cout<<i<<": "<<l[i]<<' '<<r[i]<<endl;
        l[i]=i-l[i];
        r[i]=r[i]-i;

       // cout<<i<<": "<<l[i]<<' '<<r[i]<<endl;
        ans+=(LL)l[i]*(LL)r[i]*(LL)a[i];
    }
    cout<<ans<<endl;
	return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  string z;
  cin >> z;
  cout << z.substr(0,4) << " " << z.substr(4) << "\n";
}


Measured memory_bytes: 384
#include <iostream>

int main() {
    int A, B, C, X;
    std::cin >> A >> B >> C >> X;

    int ret = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if (500*i + 100*j + 50*k == X) {
                    ++ret;
                }
            }
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 384
N = int(input())
T, A = map(int,input().split())
H = input().split()
mindif = min(abs(1000 * T - int(H[i]) * 6 - 1000 * A) for i in range(N))

for i in range(N):
    if abs(1000 * T - int(H[i]) * 6 - 1000 * A) == mindif:
        print(i+1)
    else:
        continue


Measured memory_bytes: 3060
n,m,k = map(int,input().split())
friends = [set() for _ in range(n)]
blocked = [set() for _ in range(n)]

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    friends[a].add(b)
    friends[b].add(a)
    
for _ in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    blocked[c].add(d)
    blocked[d].add(c)

checked = set()
ans = [0]*n
for i in range(n):
    if i in checked:
        continue
        
    fgroup = set()
    
    stack = list(friends[i])
    while stack:
        f = stack.pop()
        if f in checked:
            continue
        checked.add(f)
        fgroup.add(f)
        stack.extend(friends[f])
        
    for f in fgroup:
        ans[f] = len(fgroup) - 1 -len(fgroup&(friends[f]|blocked[f]))
    
print(" ".join(map(str,ans)))

Measured memory_bytes: 87828
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const ll INF = 2e9;
const int MAXN = 1200;

ll go[MAXN];
int n, m;
ll a[MAXN][MAXN];
ll x[MAXN];

ll cnk(ll n, ll k) {
	ll fc = 1;
	for (int j = 1; j <= k; ++j)
		fc *= j;
	ll ans = 1;
	for (ll j = n; j > n - k; --j) {
		ans *= j;
		if (ans >= fc * INF)
			return INF;
	}
	return ans / fc;
}



int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			scanf("%lld", &a[i][j]);
	for (int i = 0; i < n - 1; ++i) {
		if (a[i][0] > a[i + 1][0] || (m == 1 && a[i][0] == a[i + 1][0])) {
			cout << -1 << "\n";
			return 0;
		}
		int fl = 0;
		for (int j = 0; j < m; ++j) {
			if (a[i][j] < a[i + 1][j]) {
				fl = 1;
				break;
			}
			if (a[i][j] > a[i + 1][j]) {
				fl = -1;
				break;
			}
		}
		if (fl == 0) {
			go[i] = 1;
		}
		else if (fl == 1) {
			if (a[i][0] < a[i + 1][0]) {
				continue;
			}
			ll nd = (a[i + 1][1] - a[i][1] + a[i][0] - 1) / a[i][0];
			for (int j = 0; j < m; ++j)
				x[j] = a[i][j];
			if (nd <= 100) {
				for (int it = 0; it < nd; ++it) {
					ll sum = 0;
					for (int j = 0; j < m; ++j) {
						sum = min(INF, sum + x[j]);
						x[j] = sum;
					}
				}
			}
			else {
				for (int j = 10; j < m; ++j)
					x[j] = INF;
				for (int j = min(9, m - 1); j >= 1; --j) {
					for (int k = 0; k < j; ++k)
						x[j] = min(INF, x[j] + cnk(nd - 1 + j - k, j - k) * x[k]);
				}
			}
			int fl2 = 0;
			for (int j = 0; j < m; ++j) {
				if (x[j] < a[i + 1][j]) {
					fl2 = 1;
					break;
				}
				if (x[j] > a[i + 1][j])
					break;
			}
			if (fl2)
				go[i] = -nd;
			else
				go[i] = -(nd - 1);
		}
		else {
			ll nd = (a[i][1] - a[i + 1][1] + a[i + 1][0] - 1) / a[i + 1][0];
			for (int j = 0; j < m; ++j)
				x[j] = a[i + 1][j];
			if (nd <= 100) {
				for (int it = 0; it < nd; ++it) {
					ll sum = 0;
					for (int j = 0; j < m; ++j) {
						sum = min(INF, sum + x[j]);
						x[j] = sum;
					}
				}
			}
			else {
				for (int j = 10; j < m; ++j)
					x[j] = INF;
				for (int j = min(m - 1, 9); j >= 1; --j) {
					for (int k = 0; k < j; ++k)
						x[j] = min(INF, x[j] + cnk(nd - 1 + j - k, j - k) * x[k]);
				}
			}
			int fl2 = 0;
			for (int j = 0; j < m; ++j) {
				if (x[j] < a[i][j])
					break;
				if (x[j] > a[i][j]) {
					fl2 = 1;
					break;
				}
			}
			if (fl2)
				go[i] = nd;
			else
				go[i] = nd + 1;
		}
	}
	ll ans = 0;
	ll now = 0;
	for (int i = 1; i < n; ++i) {
		if (a[i][0] > a[i - 1][0]) {
			now = 0;
			continue;
		}
		ll gg = max(0ll, now + go[i - 1]);
		ans += gg;
		now = gg;
	}
	cout << ans << "\n";
	return 0;
}




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

// <expr> ::= <term1>[op0<term1>]*
// <term1> ::= <term2>[op1<term2>]*
// <term2> ::= <fact>[op2<fact>]*
// <fact> ::= <numb> | (<expr>)
// <numb> ::= [0-9]+

template<typename T>
struct Parser {
	using itr = string::const_iterator;
	itr now;
	T ans;
	map<char, int> op;
	const struct ex {
		vector<char> _012;
		ex() {
			_012.resize(10);
			for(int i = 0; i < 10; ++i) {
				_012[i] = (char)('0' + i);
			}
		}
	} ex;
	Parser(const string &s, const map<char, int> &op) : op(op) {
		now = s.begin();
		ans = expr(now);
	}
	T calc(T lhs, T rhs, char op) {
		if(op == '+') return lhs + rhs;
		if(op == '-') return lhs - rhs;
		if(op == '*') return lhs * rhs;
	}
	T expr(itr &now) {
		T ret = term1(now);
		while(true) {
			char c = *now;
			if(op[c] == 1) {
				next(now, c);
				ret = calc(ret, term1(now), c);
			} else {
				return ret;
			}
		}
	}
	T term1(itr &now) {
		T ret = term2(now);
		while(true) {
			char c = *now;
			if(op[c] == 2) {
				next(now, c);
				ret = calc(ret, term2(now), c);
			} else {
				return ret;
			}
		}
	}
	T term2(itr &now) {
		T ret = fact(now);
		while(true) {
			char c = *now;
			if(op[c] == 3) {
				next(now, c);
				ret = calc(ret, fact(now), c);
			} else {
				return ret;
			}
		}
	}
	T fact(itr &now) {
		if(*now == '(') {
			next(now, '(');
			T ret = expr(now);
			next(now, ')');
			return ret;
		} else {
			return numb(now);
		}
	}
	T numb(itr &now) {
		T ret = 0;
		while('0' <= *now and *now <= '9') {
			ret *= 10;
			ret += (T)(*now - '0');
			next(now, ex._012);
		}
		return ret;
	}
	void next(itr &now, const char expected) {
		vector<char> req = {expected};
		next(now, req);
	}
	void next(itr &now, const vector<char> &expected) {
		for(char c : expected) {
			if(*now == c) {
				now++;
				return;
			}
		}
		cerr << "now " << *now << "\n";
		for(char c : expected) cerr << c << "\n";
	}
};

int main() {
	string s; cin >> s;
	map<char, int> op;
	int64_t ans = INT64_MIN;
	for(int i = 0; i < pow(3, 3); ++i) {
		int tmp = i;
		op['+'] = tmp % 3 + 1;
		tmp /= 3;
		op['-'] = tmp % 3 + 1;
		tmp /= 3;
		op['*'] = tmp % 3 + 1;
		Parser<int64_t> parse(s, op);
		// fprintf(stderr, "%d %d %d\n", op['+'], op['-'], op['*']);
		// cerr << parse.ans << "\n";
		ans = max(ans, parse.ans);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
void fast()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
}

int main(void)
{
	fast();
	int a,b;
	cin>>a>>b;
	int c[b];
	for(int i=0;i<b;i++)
	{
	    cin>>c[i];
	}
	int sum=0;
	for(int i=0;i<b;i++)
	{
	    sum=sum+c[i];
	}
	if(sum==a || sum>a)
	{
	    cout<<"Yes"<<endl;
	}
	else
	{
	    cout<<"No"<<endl;
	}
}

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

print(" ".join(map(str, A)))
for i in range(1, len(A)):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = key
    print(" ".join(map(str, A)))



Measured memory_bytes: 5596
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1000000

int n,M[MAX][MAX];

void dijkstra();

int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
    M[i][j] = INFTY;
      } 
    }

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k; j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  dijkstra();
  return 0;
}
 
void dijkstra(){
  int u,minv,i,j,v,sum=0;
  int d[MAX],p[MAX],color[MAX];
 
 for(i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
 }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0;v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u] + M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==INFTY){ 
      printf("%d -1\n",i);
    }else{
      printf("%d %d\n",i,d[i]);
    }
  }
}

Measured memory_bytes: 636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    vector<vector<ll>> A(10, vector<ll>(10));
    for (int i = 1; i <= N; i++) {
        int p,q;
        q = i%10;
        int n = i;
        while (n != 0) {
            p = n;
            n /= 10;
        }
        A[p][q]++;
    }
    ll ans = 0;
    rep(i,10) {
        rep(j,10) {
            ans += A[i][j]*A[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php

$input = explode(' ', trim(fgets(STDIN)));
$n = (int)$input[0];
$k = (int)$input[1];

$array = explode(' ', trim(fgets(STDIN)));

if($k === $n){
  echo 1;
}else{
  echo 1 + ceil(($n-$k)/($k-1));
}


Measured memory_bytes: 12792
#include <bits/stdc++.h>
//#include "cpp/Solution.h"

using namespace std;

int main() {
    int n;
    cin >> n;
    int prev = 0;
    long long sum = 0;
    for(int i = 0;i < n;i++){
        int cur;
        cin >> cur;
        if(cur < prev){
            sum += prev - cur;
        }
        prev = max(cur,prev);
    }
    cout << sum;
}





Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, K;
  cin >> N >> K;

  int ans = N - K + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m, c = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(0, n)]

ans = 0
for i in range(0, n):
  s = c
  for j in range(0, m):
    s += a[i][j] * b[j]
  if s > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3188
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int W, H;
int x[8] = {1,0,-1,0,1,1,-1,-1};
int y[8] = {0,-1,0,1,1,-1,1,-1};

bool in_map(int h, int w) {
  return (1 <= h && h <= H && 1 <= w && w <= W);
}

int main() {
  while(cin >> W >> H && W > 0) {
    int M[55][55];
    for (int h = 1; h <= H; h++) {
      for (int w = 1; w <= W; w++)
        cin >> M[h][w];
    }
    queue<pair<int,int>> Q;
    int ans = 0;
    for (int sh = 1; sh <= H; sh++) {
      for (int sw = 1; sw <= W; sw++) {
        if (M[sh][sw] == 1) {
          ans++;
          Q.push(make_pair(sh,sw));
          M[sh][sw] = 0;
          while (!Q.empty()) {
            pair<int,int> p = Q.front();
            Q.pop();
            int h = p.first; int w = p.second;
            for (int i = 0; i < 8; i++) {
              int nh = h+y[i]; int nw = w+x[i];
              if (in_map(nh, nw) && M[nh][nw] == 1) {
                Q.push(make_pair(nh, nw));
                M[nh][nw] = 0;
              }
            }
          }
        }
      }
    }

    cout << ans << endl;
  }
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int d,n,ans;
    cin>>d>>n;
    ans=n*pow(100,d);
    long long int tmp=pow(100,d);
    if (n==100) {
        cout<<ans+tmp<<endl;
    } else {
        cout<<ans<<endl;
    }
}


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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	string s = "";
	for (int i = 0; i < n; ++i) {
		s += a[i];
		s += b[i];
	}
	cout << s;
}


















Measured memory_bytes: 256
import sys
from collections import Counter
import copy

n = int(sys.stdin.readline())
ct = Counter()
a_ls = dict()
for i in range(n):
    inp = [int(i) - 1 for i in sys.stdin.readline().split()]
    a_ls[i] = inp
cnt = 0
candidate = list(range(n))
rest = n * (n - 1) / 2
combis = set()
while rest:
    no_ls = []
    next_candidate = []
    flg = False
    for i in candidate:
        if len(a_ls[i]) == 0:
            continue
        target = a_ls[i][0]
        if (i, target) in combis or (target, i) in combis:
            next_candidate.append(i)
            next_candidate.append(target)
            rest -= 1
            if len(a_ls[i]) > 0:
                a_ls[i].pop(0)
            if len(a_ls[target]) > 0:
                a_ls[target].pop(0)
            flg = True
        else:
            combis.add((i, target))
    candidate = next_candidate
    if not flg:
        cnt = -1
        break
    cnt += 1
print(cnt)

Measured memory_bytes: 104284
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

string s[] = {"sat", "sun", "mon", "tue", "wed", "thu", "fri"};

int main() {
  int a;
  cin >> a;
  a += 35;
  cout << s[(a - 9) % 7] << endl;
}



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


//c++ templte for help............................................................................................................................................
typedef long long ll;

//template<typename... T>
//void print1(T... t){
	//((cout<<t<<" "),...);
//}

//template<typename... T>
//void print2(T... t){
		//vector<vector<ll>> ans={t...};
		//for(ll i=0;i<(ll)ans.size();i++){
			//if(i!=0) cout<<"\t\t";
			//else cout<<"\t";
			//for(ll j=0;j<(ll)ans[i].size();j++){
				//cout<<ans[i][j]<<" ";
			//}
			//if(i!=(ll)ans.size()-1)
			//cout<<endl;
		//}
//}	
//#define deb(...) cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; 
//#define vdeb(...) cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;





	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
#define M int(1e9+7)
const int INF=1e9+5;
 
//iterate map
//template<typename T>
//void itR(T map){
	 //for(auto itr=map.begin();itr!=map.end();itr++){
				//deb(itr->first,itr->second);
			//}
	//cout<<endl;
//}
 
 
 
//c++ template for help...........................................................................................................................................


ll solve(){
	ll n;
	cin>>n;
	
	return n+(n*n)+(n*n*n);
}

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	cout<<setprecision(50);
	ios::sync_with_stdio(0);
	cin.tie(0);
	

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		//solve();
		ll ans=solve();
		cout<<ans<<endl;
	//}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[55], b[55];
int main()
{
    ll n, x;
    cin >> n >> x;
    a[0] = 1;
    for ( int i = 1 ; i <= n ; i ++ )
	{
        a[i] = a[i-1] * 2 + 1;
    }
    b[0] = 1;    
    for ( int i = 1 ; i <= n ; i ++ )
	{
        b[i] = b[i-1] * 2 + 3;
    }   
    ll ans = 0;    
    while ( x > 0 )
	{
        if ( x == b[n] )
		{
            ans += a[n];
            x = 0;
        }
		else if ( x >= b[n] / 2 + 1 )
		{
            ans += a[n-1] + 1;
            x -= b[n] / 2 + 1;
        }
		else
           x --;
        n --;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const int N = 1e5 + 5;
int a[N], l[N], r[N];

int gcd(int a, int b) {
	while (b > 0) {
		int t = a % b;
		a = b;
		b = t;
	}
	return a;
}

int my_max(int a, int b) {
	if (a == 0 || b ==0) return 0;
	return max(a, b);
}

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

	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i < n; i++)
		l[i+1] = gcd(l[i], a[i]);
	for (int i = n; i > 0; i--)
		r[i] = gcd(r[i+1], a[i]);
	int answer = r[1];
	for (int i = 1; i <= n; i++)
		answer = max(answer, gcd(l[i], r[i+1]));
	printf("%d\n", answer);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 998244353;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
const int N = 303;
long long f[N][N*N], f1[N][N*N], a[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    long long sum = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    f[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= 300*n; j++) {
            if(j-a[i] >= 0) f[i][j] += f[i-1][j-a[i]];
            f[i][j] += f[i-1][j]*2;
            f[i][j] %= mod;
        }
    }
    f1[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= 300*n; j++) {
            if(j-a[i]>=0) f1[i][j] += f1[i-1][j-a[i]];
            f1[i][j] += f1[i-1][j];
            f1[i][j] %= mod;
        }
    }
    long long ans = power(3, n);
    for(int i = (sum+1)/2; i <= 300*n; i++) {
        ans = (ans - 3*f[n][i]%mod + mod) % mod;
    }
    if(~sum & 1) {
        ans = (ans + f1[n][sum/2]*3%mod) % mod;
    }

    cout << ans << "\n";



    return 0;
    
}

Measured memory_bytes: 431744
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,m,n,k;
    ll t;
    string s;
    cin>>n;
    ll a[n];
    ll sum=0;
    for(i=0;i<n;i++)
    {cin>>a[i];
     sum=sum^a[i];}
    
    for(i=0;i<n;i++)
    {   ll o=sum^a[i];
        cout<<o<<" ";
    }
}


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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int compare_string(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
}
//  qsort(names, 3, sizeof *names, compare_string);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a, b, c, d, e, X, Y ,r;
//  long long a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[10000001][11]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
  int sosuu[46] ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};
  int min =100000001;
  int len=0;
  int l=0;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d%d%d", &a, &b,&c);
  for(i=0;i<c-b+1;i++){
  //  printf("%d %d\n",(b+i)%a, b+i);

    if((b+i)%a==0){
      printf("OK\n");
      return 0;
    }  
  }
  printf("NG\n");
return 0;
}


Measured memory_bytes: 1660
from bisect import bisect

def main():
    a,b,q,*stx = map(int,open(0).read().split())
    s = [-1e10] + stx[:a] + [2*1e10]
    t = [-1e10] + stx[a:a+b] + [2*1e10]
    x = stx[a+b:a+b+q]
    for i in x:
        pos_s = bisect(s,i)
        pos_t = bisect(t,i)
        sl = s[pos_s-1]; sr = s[pos_s]
        tl = t[pos_t-1]; tr = t[pos_t]
        ans = min( i-min(sl,tl), max(sr,tr)-i, (sr-i) + (sr-tl), (tr-i) + (tr-sl), (i-sl) + (tr-sl), (i-tl) + (sr-tl) )
        print(ans)

if __name__ == '__main__':
    main()

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int N;
vector<int> A;

int dfs(int n, bool even, bool zero)
{
    if (n == N) return even;
    int a = A[n];

    int res = 0;
    for (int b=a-1; b<=a+1; b++) {
        res += dfs(n+1, even|(b%2==0), zero|(b==0));
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false);

    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];
    
    cout << dfs(0, false, false) << endl;
}

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

vector<int> a;

int main() {
	int n;
	cin >> n;
	int x;
	for (int i = 0; i < n; i++) {
		cin >> x;
		a.push_back(x);
		a.push_back(x);
	}
	sort(a.rbegin(), a.rend());
	long ans = 0;
	for (int i = 1; i < n; i++)
		ans += a[i];
	cout << ans << endl;
}

Measured memory_bytes: 5308
#include<stdio.h>
int main(void)
{
    int k,n,i,a[200001],max=0,temp;
    scanf("%d %d",&n,&k);
    for(i=0;i<k;i++) {
        scanf("%d", &a[i]);
        if(i>0&&a[i]-a[i-1]>max)
            max=a[i]-a[i-1];
    }
    temp=a[0]+n-a[k-1];
    if(temp>max)
        max=temp;
    printf("%d",n-max);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N; cin >> N;
    vector<pair<ll,ll>> A(N);
    for(int i = 0; i < N; ++i){
        ll X,L; cin >> X >> L;
        A[i] = {X+L,X-L};
    }
    sort(ALL(A));
    ll B = -LOWINF;
    ll cnt = 0;
    for(int i = 0; i < N; ++i){
        ll R = A[i].first,L = A[i].second;
        if(B<=L){
            B = R;
            cnt++;
        }
    }
    cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long int i,o,t,j,l,s,z;
int main(){
//	freopen("a.in","r",stdin);
	scanf("%lld%lld%lld%lld%lld%lld%lld",&i,&o,&t,&j,&l,&s,&z);
	if(i==0||j==0||l==0){
		printf("%lld",(i/2)*2+j/2*2+l/2*2+o);
	}else{
		printf("%lld",max(3+((i-1)/2)*2+(j-1)/2*2+(l-1)/2*2+o,(i/2)*2+j/2*2+l/2*2+o));
	}
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        x: usize,
    }

    let mut hoge = 100;
    let mut ans = 0;
    loop {
        if hoge >= x {
            break;
        }
        hoge += hoge / 100;
        ans += 1;
    }
    println!("{}", ans);
}


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

int main(){
  int n;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++)cin >> a[i];

  sort(a,a+n);
  if(a[0]==0){
    cout << 0 << endl;
    return 0;
  }
    
  long long ans = 1;
  for(int i=0;i<n;i++){
    if(a[i]<=1000000000000000000/ans)ans*=a[i];
    else {
      ans=-1;
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4344
#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() {
    int n;
    cin >> n;
    double x[n], y[n];
    rep(i, n) cin >> x[i] >> y[i];
    double sum = 0;
    
    for(int i = 0; i < n-1; ++i){
        for(int j = i+1; j < n; ++j){
            double x_dif = x[j] - x[i];
            double y_dif = y[j] - y[i];
            sum += pow(x_dif * x_dif + y_dif * y_dif, 0.5);
        }
    }
    
    cout << fixed << setprecision(12) << (sum * 2)/ n  << endl;
    return 0;
}

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

void Main()
{
	int A, B; cin >> A >> B;
	int res = A + B;
	res = max(res, A * B);
	res = max(res, A - B);
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	while(1){
		int i,j,H,W;
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			if(i==0||i==H-1){
				for(j=0;j<W;j++){
					printf("#");
				}
			}else{
				for(j=0;j<W;j++){
					if(j==0||j==W-1){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1800