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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL n;
    cin>>n;
    LL a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    LL mx=a[0];
    LL ans=0;
    for(int i=0;i<n;i++)
    {
        mx=max(mx,a[i]);
        ans+=mx-a[i];
    }
    cout<<ans;

}


Measured memory_bytes: 5188
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;




int main()
{
    int a,b,ans=0,cnt=0,sum=0;
    cin>>a>>b;
    ans=a+b;
    cnt=a-b;
    ans=max(ans,cnt);
    sum=a*b;
    sum=max(sum,ans);
    cout<<sum;
    //system("pause");
    return 0;
} 

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int r, D, x;
	
	cin >> r >> D >> x;

	rep(i, 10)
	{
		x = r * x - D;
		cout << x  << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){

	int n;
	cin >> n;
	long long int p = 1;
	for(int i=1; i<=n; i++){
		p *= i;
		p %= 1000000000+7;
	}
	cout << p << endl;

	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

def E(i, x):
    if i == 1:
        return 5*x
    return (2*i+1)*x

N, X = map( int, input().split())
G = list( map( int, input().split()))
G.sort(key=None, reverse = True)
accG = list(accumulate(G))
accG.insert(0,0)
ans = X*2*N + G[0]*N*5
for k in range(1,N+1):
    now = 0
    for i in range(1,N+1):
        if i*k <= N:
            now += E(i, accG[i*k] - accG[(i-1)*k])
        else:
            now += E(i, accG[-1] - accG[(i-1)*k])
            break
    ans = min( ans, now+(N+k)*X)
print(ans)

Measured memory_bytes: 25252
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin>>n;

	string s1="AC";
	string s2="WA";
	string s3="TLE";
	string s4="RE";
	string str;
	int count[5]={0};
	for(int i=0;i<n;i++)
	{
		cin>>str;
		if(str==s1)
		{
			count[0]++;
		}
		if(str==s2)
		{
			count[1]++;
		}
		if(str==s3)
		{
			count[2]++;
		}
		if(str==s4)
		{
			count[3]++;
		}
		
	}
	cout<<s1<<" x "<<count[0]<<endl;
		cout<<s2<<" x "<<count[1]<<endl;
			cout<<s3<<" x "<<count[2]<<endl;
				cout<<s4<<" x "<<count[3]<<endl;
 } 

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>b(N);
  for(int i=0;i<N;i++)cin>>b[i];
  vector<int>ans;
  for(int i=0;i<N;i++){
    for(int j=b.size()-1;j>=0;j--){
      if(b[j]==j+1){
        b.erase(b.begin()+j,b.begin()+j+1);
        ans.push_back(j+1);
        break;
      }
    }
  }
  reverse(rng(ans));
  if(b.size())cout<<-1<<endl;
  else for(auto it:ans)cout<<it<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n, k;
  scanf("%d %d\n", &n, &k);
  vector<int> dices = vector<int>(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &dices[i]);
    dices[i] += 1;
  }
  
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += dices[i];
  }
  int maxSum = sum;
  for (int i = k; i < n; i++) {
    sum += dices[i] - dices[i-k];
    maxSum = max(maxSum, sum);
  }
  printf("%lf\n", maxSum / 2.0);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int res=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]!=i+1)
            {
                res++;
            }
    }
    if(res>2)
        cout<<"NO";
    else cout<<"YES";

        return 0;
}


Measured memory_bytes: 256
N = int(input())
days = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*3 for i in range(N + 1)]
for i in range(N):
    for k in range(3):
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][(k + 1) % 3] + days[i][k], dp[i][(k - 1) % 3] + days[i][k])

print(max(dp[-1]))


Measured memory_bytes: 74148
fun main() {
    val s = readLine()!!
    val t = readLine()!!
    var min = t.length

    for (i in 0..(s.length - t.length)) {
        val ss = s.substring(i, i + t.length)
        val count = ss.chunked(1).mapIndexed{j, str ->
            if(str != t.substring(j, j+1)){
                1
            }else{
                0
            }
        }.sum()
        min = if(count < min) count else min
    }
    println(min)
}

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

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var inputNumber = IO.ReadInt();
			if(inputNumber < 13)
			{
				IO.Write(inputNumber);
				return;
			}
			
			var list = new List<long>(Enumerable.Range(1 , 9).Select(iNumber => (long)iNumber));
			var index = 0;
			while(list.Count < inputNumber)
			{
				var top = list[index];
				var checkNumber = top % 10;
				var baseNumber = top * 10;
				if(checkNumber > 0) { list.Add(baseNumber + (checkNumber - 1)); }
				list.Add(baseNumber + checkNumber);
				if(checkNumber < 9) { list.Add(baseNumber + (checkNumber + 1)); }

				++ index;
			}

			IO.Write(list[inputNumber - 1]);
		}
	}

	public static class IO
	{
		public static string   Read()							   { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	   { return Read().Split(iSplitter); }
		public static int	   ReadInt()						   { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')  { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()						   { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ') { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					   { return Read().ToCharArray(); }

		public static void Write(string iValue)			  { Console.WriteLine(iValue); }
		public static void Write(int iValue)			  { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue) { Console.WriteLine(string.Join(" " , iValue)); }
		public static void Write(long iValue)			  { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)		  { Console.WriteLine(iValue); }
		public static void Write(bool iValue)			  { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1)	{ return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}
ll nof(ll n){
    if(n==2)
    {
        return 2;
    }
    ll c=1;
if(n%2==0)
{
    while(n%2==0)
    {
             c++;
        n/=2;
      //  cout<<c<<"--->"<<n<<" ";
    }
    //cout<<endl;
}
for(int i=3;i<=sqrt(n);i++)
{
    if(n%i==0)
    {
        c+=2;
    }
}
if(n>1)
{
    c++;
}
return c;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,k;
  cin>>n>>k;
 ll a[n];
 for(int i=0;i<n;i++)
 {
     cin>>a[i];
 }
 ll m=1e18;
 vector<ll>ans(n,m);
ans[0]=0;
for(int i=0;i<n;i++)
{
    for(int j=i+1;j<=i+k;j++)
    {
      if(j<n)
        ans[j]= min(ans[j], ans[i] + abs(a[i]-a[j]));
    }
}
          cout<<ans[n-1];
  }


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

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

    for(int i = 0; i <= n / 7; ++i){
        if((n - i * 7) % 4 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nx = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var sum = new long[nx[0]];
        sum[0] = ar[0];
        for(var i = 1; i < nx[0]; i++)
        {
            sum[i] = ar[i] + sum[i - 1];
        }
        var result = 0L;
        var dif = new long[nx[0]];
        dif[0] = 0;
        for(var i = 1; i < nx[0]; i++)
        {
            var s = i == 1 ? sum[1] : sum[i] - sum[i - 2]-(dif[i-1]-dif[i-2]);
            result += Max(0, s - nx[1]);
            dif[i] = dif[i-1]+Min(ar[i],Max(0, s - nx[1]));
        }
        WriteLine(result);
    }

    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 30684
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, a[100010], x, y;
vector<int> vec[100010], memo;
bool used[100010];
void func(int node) {
	used[node] = true;
	memo.push_back(a[node]);
	for (int i : vec[node]) {
		if (!used[i])func(i);
	}
}
signed main() {
	cin >> n >> m;
	rep(i, n)cin >> a[i];
	rep(i, m) {
		cin >> x >> y;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	int ans = 0, num = 0;
	vector<int> free;
	rep(i, n) {
		if (!used[i]) {
			num++;
			memo.clear();
			func(i);
			int cnt = INF, now;
			rep(j, memo.size()) {
				if (cnt > memo[j]) {
					cnt = memo[j];
					now = j;
				}
			}
			ans += cnt;
			memo.erase(memo.begin() + now);
			free.insert(free.end(), memo.begin(), memo.end());
		}
	}
	sort(free.begin(), free.end());
	if (num == 1) {
		cout << 0 << endl;
		return 0;
	}
	num = 2 * (num - 1) - num;
	if (free.size() < num) {
		puts("Impossible");
		return 0;
	}
	rep(i, num)ans += free[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
int main()
{
    int n, t, x, i, j ;
    cin >> n >> x >> t;
    i=(n/x)*t;
    if(n%x!=0)
        i+=t;
    cout << i ;
    return 0;
}


Measured memory_bytes: 3620
first_input = input().split(' ')

s_length = int(first_input[0])
num_of_Q = int(first_input[1])

input_string = input()

seq = [0]*s_length
count = 0

for s in range(s_length):
    if s > 0 and input_string[s-1:s+1] == 'AC':
        count += 1
    seq[s] = count

for q in range(num_of_Q):
    l_r = input().split(' ')
    l = int(l_r[0])
    r = int(l_r[1])

    print(seq[r-1] - seq[l-1])

Measured memory_bytes: 6164
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int a, b;
    public static void main(String[] args) {
        while(read()){
            slove();
        }
    }

    static boolean read(){
        if(!sc.hasNext())return false;
        a = sc.nextInt(); 
        b = sc.nextInt();
        return true;
    }

    static void slove(){
        int ans = Integer.toString(a+b).length();
        System.out.println(ans);
    }

}

Measured memory_bytes: 20428
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()


if __name__ == '__main__':
    n = iread()
    a = aread_int()
    s = sum(a)
    m = max(a)
    if m < s - m :
        print("Yes")
    else :
        print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int digit(int x) {
    int ans = 0;
    while (x > 0) {
        ++ans;
        x /= 10;
    }
    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> SHI(N);
    vector<int> P(M);
    rep(i, M) {
        int p, Y;
        cin >> p >> Y;
        P[i] = p;
        SHI[p - 1].push_back(make_pair(Y, i));
    }
    rep(i, N) sort(SHI[i].begin(), SHI[i].end());
    vector<int> last(M);
    rep(i, N) rep(j, SHI[i].size()) {
        last[SHI[i][j].second] = j + 1;
    }
    
    rep(i, M) {
        rep(j, 6 - digit(P[i])) cout << 0;
        cout << P[i];
        rep(j, 6 - digit(last[i])) cout << 0;
        cout << last[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
using namespace std;

void Onigiri()
{
  string s;
  cin>>s;

  vector<int> v;
  for(auto x:s)
    v.push_back(x-'0');

  reverse(v.begin(), v.end());
  int n=v.size();
  int num=v[0];
  int mul=1;
  int modvals[n]={0};
  modvals[0]=num;

  for(int i=1;i<n;i++)
  {
    mul=(mul*10)%2019;
    modvals[i]=(modvals[i-1]+v[i]*mul)%2019;
    num=modvals[i];
  }
  
  reverse(modvals,modvals+n);
  map<int,int>mpp;
  rep(i,0,n)
  mpp[modvals[i]]++;

  int ans=0;
  int z=mpp[0];
  
  vector<pair<int,int>> v2;
  for(auto x:mpp)
    v2.push_back({x.first,x.second});

  for(int i=0;i<v2.size();i++)
  {
    ans+=v2[i].second*(v2[i].second-1)/2;
  }
  
  cout<<ans+z;
  
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
   //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 6832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long int

ll xor(ll n){
	if(n==-1)return 0;
	ll x;
	if(((n+1)/2)%2==0) x = 0;
	else x = 1;
	if(n%2==0) x ^= n;
	return x;
}

int main(void){
	ll a,b,ans;
	scanf("%lld %lld",&a,&b);
	ll A = xor(a-1);
	ll B = xor(b);
	ans = A^B;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N, D = map(int, input().split())

X = [[int(i) for i in input().split()] for i in range(N)]

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        tmp = 0
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        if np.sqrt(tmp) % 1 == 0:
            ans += 1
            
print(ans)

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

using namespace std;

#define int long long

signed main(){
	int n,k;
	cin>>n>>k;
	int v[k+1];
	for(int i=1;i<=k;i++)v[i]=-1;
	v[0]=0;
	for(int i=0;i<n;i++){
		int peso, valor;
		cin>>peso>>valor;
		for(int j=k-peso;j>=0;j--){
			if(v[j]!=-1){
				v[j+peso]=max(v[j+peso],v[j]+valor);
			}
		}
	}
	int maior=-1;
	for(int i=0;i<=k;i++){
		if(v[i]>maior)maior=v[i];
	}
	cout<<maior<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

string temp;
int n,v[100010];
void read(int x){
    cout<<x<<endl;
    cin>>temp;
    if(temp=="Vacant")exit(0);
    if(temp=="Male")v[x]=1;
    else v[x]=2;
}

void solve(){
    cin>>n;read(0);read(n-1);
    int l=0,r=n-1;
    REP(i,20){
        int m=(l+r)/2;
        read(m);
        if((m+l)%2==(v[m]+v[l])%2)l=m;
        else r=m;
    }
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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


#define fi first
#define se second
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define pb push_back
#define len(x) (int)(x).size()

typedef long long ll;
typedef long double ld;

using namespace std;
const int N = 1e5 + 10 , LG = 18;
int x[N] , f[N], bin[N][LG];
signed main(){
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;cin >> n;
    for(int i =  0 ;  i < n; ++i)cin >> x[i];
    int L;cin >> L;
    /// not more that L per a day
    /// he must to stay al hotel for night
    /// okay we have Q queries v
    /// okay let's f[i] - will be next hotel after ower
    /// let's do binary lifiting for it and understand when f[f[f[f[fi]]]] >= b
    for(int i =  0 ;   i < n; ++i){
        int nxt = upper_bound(x , x + n , x[i] + L) - x - 1;
        f[i] = nxt;
    }
//    for(int i = 0 ; i < n; ++i)
//        cout << f[i] << ' ';
//    cout << " MEM \n";
    for(int i =  0 ; i  < n; ++i)
        bin[i][0] = f[i];
    for(int st = 1; st < LG; ++st)
        for(int i = 0  ; i < n; ++i)
            bin[i][st] = bin[bin[i][st-1]][st-1];
    int q;cin >> q;
    while(q--){
        int a , b;cin >> a >> b;
        --a , --b;
        if(a > b)swap(a , b);
        int ans = 0;
        for(int i = LG - 1; i >= 0 ; --i){
            if(bin[a][i] < b)
                a = bin[a][i] , ans += (1 << i);
        }
        ans += 1;
        cout << ans << '\n';
    }
    return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N1 100001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountll(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

main()
{
  ios

//si(test);
int test=1,i,j,k,l;
int n,m;
//si(test);
//sieve();
while(test--)
{
  // sii(n,k);
 si(n);
 n=1-n;
 cout<<n;
}
}

Measured memory_bytes: 3648
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,m;
int d[105][105][2];
char s[105][105];

int main(){
	n=readint(); m=readint();
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	memset(d,0x3f,sizeof(d));
	if(s[1][1]=='#') d[1][1][1]=1;
	else d[1][1][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i==n&&j==m) continue;
			if(i<n){
				if(s[i+1][j]=='#') chkmin(d[i+1][j][1],min(d[i][j][1],d[i][j][0]+1));
				else chkmin(d[i+1][j][0],min(d[i][j][0],d[i][j][1]));
			}
			if(j<m){
				if(s[i][j+1]=='#') chkmin(d[i][j+1][1],min(d[i][j][1],d[i][j][0]+1));
				else chkmin(d[i][j+1][0],min(d[i][j][0],d[i][j][1]));
			}
		}
	}
	printf("%d\n",min(d[n][m][0],d[n][m][1]));
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    ll n,m;
    cin>>n>>m;
    //bitDP
    vector<ll> dp((1<<n),0);
    rep(i,m){
        ll a,b;cin>>a>>b;
        ll bit=0;
        while(b--){
            ll t;cin>>t;t--;
            bit+=(1<<t);
        }
        if(dp[bit]>0) dp[bit]=min(dp[bit],a);
        else dp[bit]=a;
    }

    for(int i=0;i<(1<<n);i++){
        if(dp[i]>0){
            for(int j=0;j<i;j++)if(dp[j]>0){
                if(dp[i|j]>0) dp[i|j]=min(dp[i|j],dp[i]+dp[j]);
                else dp[i|j]=dp[i]+dp[j];
            }
        }
    }
    if(dp[(1<<n)-1]==0) cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N, K;
  cin >> N >> K;
  vi num(N);
  rep(i, N) {
    int a;
    cin >> a;
    num[a - 1]++;
  }

  sort(all(num));
  int sum = 0;
  rep(i, N) {
    if (num[i]) sum++;
  }
  int cnt = 0, kinds = 0;
  rep(i, N) {
    if (sum - kinds <= K) break;
    if (!num[i]) continue;
    cnt += num[i];
    kinds++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long   ll;
string arr[200005];
string ans[200005];
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    sort(arr,arr+n);
    int c=1,maxi=0,b=0;
    for(int i=1;i<n;i++){
        if(arr[i]==arr[i-1]&& i!=n-1){
            c++;
        }
        else{
            if(i==n-1&&arr[i]==arr[i-1]){
                c++;
            }
            if(c>maxi){
                b=0;
                maxi =c;
                c=1;
                for(int i=0;i<n;i++){
                    ans[i] = "";
                }
                ans[b] = arr[i-1];
            }
            else if(c==maxi){
                c=1;
                b++;
                ans[b] = arr[i-1];
            }
            else{
                c=1;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(ans[i] == ""){
            break;
        }
        else{
            cout << ans[i] << endl;
        }
    }
    if(maxi==1){
        cout << arr[n-1];
    }


}

Measured memory_bytes: 15872
#include <cstdio>
#include <queue>

using namespace std;

int n;
deque<int> b;

int main(){
    scanf("%d", &n);
    for(int i=0;i<n;++i){
        int tmp;
        scanf("%d", &tmp);
        if(i%2){
            b.push_front(tmp);
        }else{
            b.push_back(tmp);
        }
    }
    if(n%2){
        while(!b.empty()){
            printf("%d ", b.back());
            b.pop_back();
        }
    }else{
        while(!b.empty()){
            printf("%d ", b.front());
            b.pop_front();
        }
    }
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=353;
int N, M, k;
ll arr[MX];
int row[222], col[222];
char g[MX][MX];
int main()
{
    cin>>N>>M;
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<M;j++)
        {
            char c;
            cin>>c;
            g[i][j]=c;
            if(c == '#') row[i]++, col[j]++;
        }
    }
    vector<vector<char > > an(222);
    for(int i=0;i<N;i++)
    {
        bool p=0;
        for(int j=0;j<M;j++)
        {
           if(col[j] && row[i])cout<<g[i][j], p=1;

        }
        if(!p) continue;
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int sumDig(int x){
    int sum = 0;
    while (x > 0){
        sum += x % 10;
        x = x / 10;
    }
    return sum;
}

int main(){
    int n;
    cin >> n;
    int s = sumDig(n);
    if(n % s == 0) cout << "Yes\n";
    else cout << "No\n";
}


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

typedef long long int lli;

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

	lli n;
	cin>>n;
	lli arr[n+1];
	for(lli i=1;i<=n;i++){
	    arr[i]=1;
	}

	for(lli i=2;i<=n;i++){
	    for(lli j=1;i*j<=n;j++){
	        arr[i*j]++;
	    }
	}
	lli ans=0;
	for(lli i=1;i<=n;i++){
	    ans=ans+(i*arr[i]);
	}
    cout<<ans;

	return 0;
}


Measured memory_bytes: 81756
#include <stdio.h>
int main()
{

  int S,h,m,s; 
  scanf("%d",&S);
 
  h = S/3600;
  m = (S%3600)/60;
  s = (S%3600)%60;

 
  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;


// 145_a
public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();
        String n = a < b ? "0" : "10";
        System.out.println(n);

    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
	int w;
	string ss;
	cin>>ss>>w;
	int n=ss.length();
	for(int i=0;i<n;i+=w){
		cout<<ss[i];
	}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  string S;
  string T;
  cin >> S >> T;
  string X;
  for (int i=0; i<n; i++) {
    X +=S.at(i);
    X +=T.at(i);
  }
  cout << X << endl;
  
      
  

  
  
}

Measured memory_bytes: 256
D, G = gets.split(' ').map(&:to_i)

ps = []
1.upto(D) do |i|
	ps[i] = gets.split(' ').map(&:to_i)
end
ans = []
[0, 1].repeated_permutation(D) do |solve|
	solve = [0] + solve
	score = 0
	problems = 0
	1.upto(D) do |i|
		if solve[i] == 1
			score += 100 * i * ps[i][0] + ps[i][1]
			problems += ps[i][0]
		end
	end
	m = solve.rindex(0)
	if score < G
		if score + 100 * m * (ps[m][0] - 1) >= G
			n = (G - score + 100 * m - 1) / (100 * m)
			score += 100 * m * n
			problems += n
		end
	end 
	ans.push(problems) if score >= G
end

puts ans.min

Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

template<typename T>
class Node {
public:
  T label;
  Node *right;
  Node *left;
  
  Node(T s) :label{s}, right{nullptr}, left{nullptr} {}
};

template<typename T>
class Dictionary {
  bool lookup(T);
  void insert(T);
};

template<typename T>
class TreeDict : public Dictionary<T> {
private:
  Node<T>* root;
public:
  TreeDict() :root{nullptr} {}
  void insert(T s) {
    if (!root) root = new Node<T>(s);
    auto curr = root;
    while(curr) {
      if(s==curr->label) return;
      if(s < curr->label) {
        if(curr->left) curr = curr->left;
        else curr->left = new Node<T>(s);
      } else if(s > curr->label) {
        if(curr->right) curr = curr->right;
        else curr->right = new Node<T>(s);
      }
    }
  }
  bool lookup(T s) {
    if (!root) return false;
    auto curr = root;
    while(curr) {
      if(s == curr->label) return true;
      if(s < curr->label) {
        curr = curr->left;
      } else {
        curr = curr->right;
      }
    }
    return false;
  }
};

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

  int n; cin >> n;

  TreeDict<string> d;

  string cmd, arg;
  while(cin >> cmd >> arg) {
    if(cmd[0]=='i') {  // insert
      d.insert(arg);    
    } else {  // find
      cout << (d.lookup(arg) ? "yes" : "no") << endl;
    }
  }
}


Measured memory_bytes: 25476
import math
N,A,B = map(int,input().split())
H = []
for i in range(N):
  H.append(int(input()))
ok = -1
ng = int(sum(H)/B)
while ng-ok > 1:
  mid = (ok+ng)//2
  cnt = 0
  for i in range(N):
    if H[i] < B*mid:
      None
    else:
      cnt += math.ceil((H[i]-B*mid)/(A-B))
  if cnt > mid:
    ok = mid
  else:
    ng = mid
print(ng)

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

using namespace std;

int main(){
    int w,h;
    while(true){
        cin >> w >> h;
        if(w==0&&h==0){
            break;
        }
        for(int i=0;i<w;i++){
            for(int y=0;y<h;y++){
                if(i%2==0){
                    if(y%2==0){
                        cout << "#";
                    }
                    else{
                        cout << ".";
                    }
                }
                else{
                    if(y%2!=0){
                        cout << "#";
                    }
                    else{
                        cout << ".";
                    }
                }
                
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
// Just GRL_3_A with added search for bridges
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i = a; i < b; i++)

int V, E;
vvi conn(100002);
vi vis(100002);
vb trail(100002);
vpii bridges(0);

int dfs_min(int v, int depth, int parent) {
  if(vis[v] > 0) return vis[v];
  vis[v] = depth;
  trail[v] = true;

  int minHit = depth;
  rep(i,0,(int)conn[v].size()) {
    if(conn[v][i] != parent && (vis[conn[v][i]] == 0 || trail[conn[v][i]])) {
      int hit = dfs_min(conn[v][i], depth+1, v);
      minHit = min(minHit, hit);
      if(hit > depth)
	bridges.push_back(make_pair(min(v,conn[v][i]), max(v,conn[v][i])));
    }
  }

  trail[v] = false;
  return minHit;
}

int main() {
  cin >> V;
  cin >> E;
  rep(e,0,E) {
    int s, t;
    cin >> s;
    cin >> t;
    conn[s].push_back(t);
    conn[t].push_back(s);
  }

  dfs_min(0, 1, -1);
  /*if(V > 1) {
    cut[0] = false;
    bool remember = cut[1];
    fill(all(vis), 0);
    dfs_min(1, 1, -1);
    cut[1] = remember;
    }*/


  /*rep(v,0,V) {
    if(!(cut[v] || conn[v].size() == 1)) continue;
    rep(i,0,(int)conn[v].size())
      if(v < conn[v][i] && (cut[conn[v][i]] || conn[conn[v][i]].size() == 1))
	bridges.push_back(to_string(v)+" "+to_string(conn[v][i]));
	}*/
  sort(all(bridges));
  rep(b,0,(int)bridges.size())
    cout << bridges[b].first << ' ' << bridges[b].second << '\n';
}



Measured memory_bytes: 7000
N, M = map(int, input().split())
A = [[0] * M for _ in range(N)]
for i in range(N):
    A[i] = [int(x) for x in input().split()[1:]]
food = [0] * M
for x in A:
    for f in x:
        food[f-1] += 1
ans = 0
for f in food:
    if f == N:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt(); 

    if (A >= 10 || B >= 10)
      System.out.println("-1");
    else
      System.out.println(A*B);
  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <cmath>

using namespace std;

typedef long double ld;
const ld eps = 1.0e-10;

ld mysqrtl(ld x)
{
	ld a = sqrt((double)x);
	do {
		a = (a + x / a) / 2.0L;
	} while (fabsl(x - a * a) > eps);
	return a;
}

int main()
{
	long long a, b, c;
	cin >> a >> b >> c;
	if ((long long)(mysqrtl((ld)a + eps) * mysqrtl((ld)b + eps) * 2.0l + eps) >= c - a - b) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std; 
int main(){
	string s ; 
	cin>> s ; 
	deque<char> de ; 
	for(int i = 0 ; i <(int)s.length() ; ++i) de.pb(s[i]) ; 
	int ans =  0  ;
	int q ; 
	cin>> q ; 
	while(q--){
	  int t ; 
	  cin>> t ; 
	  int x  ; 
		  char c ;
	  if(t == 2){
		   
		  cin>> x >> c ; 
	  }
	  if(t == 1) ans++ ; 
	  else {
		  if((ans%2 != 0 && x == 1 )|| (ans%2 == 0 && x == 2))
		  de.pb(c) ; 
		  else 
		  de.pf(c) ; 
	  }
		  
}
if(ans % 2 == 0){
	while(!de.empty()){
		cout<<de.front() ; 
		de.pop_front() ; 
	}
}
else {
	
	while(!de.empty()){
		cout<<de.back() ; 
		de.pop_back() ; 
	}
	
	
	
}

}



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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW
#define INF 1e9

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
}

bool compare(pii &a, pii &b) {
	return a.F > b.F;
}

ll numOfDigits(ll n) {
	if (!n) return 1;
	return (ll) (log10(n)) + 1;
}

ll POW(ll a, ll b);

/*

*/

ll BN();

int main()
{
    THINK_TWICE_CODE_ONCE;
    //freopen("test cases\\.txt", "r", stdin) ;
    int even, odd; cin>>even>>odd;
    int cnt = even*(even-1)/2 + odd * (odd-1)/2;
    cout<<cnt;
    return 0;
}

ll BN() {
	int low = 1, up = 0;
	int ans = -1;
	while (low <= up) {
		ll mid = (((ll)low + up) / 2);
		if (mid){
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  int a;
  vector<int> va;
  for (long long i=0;i<N;i++){
    cin>>a;
    va.push_back(a);
  }
  long long tmpsum;
  long long M=0;
  vector<long long > vans;
  for (long long i=N-1;i>-1;i--){
    tmpsum=0;
    for (long long j=2*i+1;j<N;j+=i+1){
      tmpsum+=va[j];
    }
    //va[i]=(va[i]-tmpsum)%2;
    va[i]=(va[i]+tmpsum)%2;
    if (va[i]==1){
      M++;
      vans.push_back(i+1);
    }
  }
  cout<<M<<endl;
  for (long long i=0;i<M;i++){
    cout<<vans[i]<<" ";
  }
  if (M)cout<<endl;
}


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

using namespace std;

int main()

{

    int k,a,b,flag=0;

    cin>>k>>a>>b;

    for(int i=a;i<=b;i++)

    {

        if(i%k==0)

        {

            flag=1;

            break;

        }



    }

    if(flag)

        cout<<"OK";

    else

        cout<<"NG";

    return 0;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 15

int n,m,x;
int a[N][N];
int c[N];
int w;

int dp(int idx  , vector<int>b ){
    if(idx>n){
      //  trace3(n,m,x);
        // for(int i=1; i<=m; i++){
        //     cout << b[i] << ' ';
        // }
        // cout << '\n';
        for(int i=1; i<=m; i++){
            if(b[i]<x){
                return inf;
            }
        }
        
        w=0;
        return 0;
    }

    int ans=0;
    ans=dp(idx+1,b);
    for(int i=1; i<=m; i++){
        b[i]+=a[idx][i];
    }
    ans=min(ans,c[idx]+dp(idx+1,b));
    return ans;
}



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

    //    int n,m,x;
        cin >> n >> m >> x;
      //  int a[n+1][m+1];
       // int c[n+1];
        int i,j;
        for(i=1; i<=n; i++){
            for(j=0; j<=m; j++){
                cin >> a[i][j];
            }
            
        }

        for(i=1; i<=n; i++){
            c[i]=a[i][0];
         //   v.pb({c[i],i});
        }
        //sort(v.begin(),v.end());

        
        vector<int>b(m+1,0);
        //mem(b,0);
        w=1;
        int r=dp(1,b);
        if(w){
            cout << -1;
        }
        else{
            cout << r;
        }
        //cout << dp(1,b);



        

}

Measured memory_bytes: 3656
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define MOD 1000000007
using namespace std;


int main() {
	FASTIO
	ll n, k;
	cin >> n >> k;
	ll ans = 0;
	rep(i, k, n+2){
		ans += (((i * n) % MOD - (i * (i - 1)) % MOD) + MOD + 1) % MOD;
		ans %= MOD;
	}
	cout << ans;
	return 0;
}




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

using namespace std;

int main()
{
    long long int i;

    int a,b;
    int ans = 0;
    cin >> a;
    cin >> b;
    int count1  = 0;
    if(b == 1)
    {
        ans = 0;
        cout << ans;
        return 0;

    }
    else if(a > b)
    {

        ans = 1;
        cout << ans;
        return 0;
    }
    else
    {
    int sum = 0,count1 = 0;
    while(sum < b-a)
   {

       sum = sum + (a-1);
       count1++;
   }
   cout << count1+1;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const ll N   = 500500;

int main()
{
	fio
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif
	string s;
	cin>>s;
	if(s[s.length()-1] == 's')
		cout<<s + "es";
	else
		cout<<s + "s";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string S; cin >> S;

    string ans = "";
    rep (i, 0, S.size()) {
        ans += 'x';
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int[] a = cin.ArrayInt(n);
			int ans = 1;
			int min = a[0];
			for (int i = 1; i < n; i++) {
				if (a[i] < min) {
					++ans;
					min = a[i];
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 29404
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'

using namespace std;

int main() {
    fast;
    ll n,d;
    cin>>n>>d;
    ll a[n]={0},b[n]={0};
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
     ll ctr=0;
    for(int i=0;i<n;i++)
    {
        double res=sqrt(pow(a[i],2)+pow(b[i],2));
        if(res<=d)
        ctr++;
    }
    cout<<ctr<<endl;
}

Measured memory_bytes: 6816
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 102
#define MAX 100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"

const int inf = (int)1e18 + 10;

int a[N] , pre[N] ;
int dp[MAX][N] , predp[MAX][N];
signed main(){
  fast;
  
 int n , t;
 cin >> n >> t;
 for(int i = 1 ; i <= n ; i++)
 	cin >> a[i] , pre[i] = pre[i-1]+ a[i];

dp[0][0] = 1;
predp[0][0] = 1;
for(int i = 1 ; i<= t ; i++)
	predp[i][0] += predp[i-1][0];
for(int i = 1 ; i<=n ; i++){
	for(int j = 0 ; j<= min(pre[i] , t) ; j++){
		int k= min(j , a[i]);
		if(j  - k - 1 >= 0)
		dp[j][i] += predp[j][i-1] - predp[j - k - 1][i-1] + mod;
	    else
	    dp[j][i] += predp[j][i-1];


	    dp[j][i] %= mod; 
	}
		
	    for(int j = 0 ; j <= t ; j++){
	    	if(j == 0)
	    		predp[j][i] = dp[j][i];
	    	else
	    	predp[j][i] += predp[j-1][i] + dp[j][i];

            predp[j][i] %= mod;
	    // cout << "predp " << j << " " << i << " "<< predp[j][i] << endl;
	    }
	

	
}

cout << dp[t][n] << endl; 

}	

Measured memory_bytes: 159616
#include<iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include "math.h"
using namespace std;

int main() {
  std::vector<long long> a;
  a.resize(3);
  cin >> a[0] >> a[1] >> a[2];
  long long k;
  cin >> k;

  std::vector<long long>::iterator max_it = std::max_element(a.begin(), a.end());
  size_t max_index = std::distance(a.begin(), max_it);

  long long sum = 0;
  for (size_t i=0; i<3; i++) {
    if (i == max_index) {
      sum += a[i] * (1 << k);
    } else {
      sum += a[i];
    }
  }
  std::cout << sum;

  return 0;
}

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

typedef long long ll;
const int mod = 1e9 + 7;

int a, b;
vector<string> v;

int main() {
    cin >> a >> b;

    string s1 = "";
    rep(i, b) {
        s1 += to_string(a); 
    }
    string s2 = "";
    rep(i, a) {
        s2 += to_string(b);
    }
    v.push_back(s1);
    v.push_back(s2);

    sort(v.begin(), v.end());

    cout << v[0] << endl;
}

Measured memory_bytes: 256