akhauriyash/Code-Regression huggingface dataset:
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<b || d<b)
    {
        cout<<"No"<<endl;
        return ;
    }
    if(c>=b-1)
    {
        cout<<"Yes"<<endl;return ;
    }
    int g=__gcd(b,d);
    int k=(b-(a%b)+g-1)/g;k--;
    int ses=(a%b)+k*g;
    if(ses>c)
    {
        cout<<"No"<<endl;return ;
    }
    cout<<"Yes"<<endl;
}
 main()

{
    fast
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;

}





































Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
int main(void)
{
  int a,b,i,j,k,x,y,z;
  char s[500],c[500];

  scanf("%d%d",&k,&x);

  for ( i = x-k+1; i < k+x; i++)
  {
    printf("%d ",i);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
const int INF=1000000000;
const int MAX_N=1000;
const int MAX_M=1000;
typedef pair<int,int> P;
char maze[MAX_N][MAX_N+1];
int N,M,a,b,c,e,f;
int sx,sy;
int gx,gy;
int d[MAX_N][MAX_N];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int bfs(){
 queue<P>que;
  que.push(P(sx,sy));
  d[sx][sy]=0;
  while(que.size()){
    P p=que.front();que.pop();
    if(p.first==gx&&p.second==gy)break;
    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx&&nx<N&&0<=ny&&ny<M&&maze[nx][ny]!='X'&&d[nx][ny]==INF){
        que.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
  return d[gx][gy];
}
int main(){
  ll x,k,d,ans;cin>>x>>k>>d;
  ll a=abs(x/d);
  //cout<<a;
  if(a>k){
    cout<<abs(abs(x)-d*k);
  }
  else {
    k-=a;
    x=abs(x)%d;
    if(k%2==0)cout<<abs(x);
    else cout<<abs(abs(d-x));
  }
}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, m; std::cin >> n >> m;
  std::cout << (n * (n-1) / 2) + (m * (m-1) / 2) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvii;
typedef pair<int, int> ii;
typedef vector<ii> vii;

////////////////////////////////

void solve() {
	
}

const int INF = 1e9 + 1;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j : {i+1, i+2}) {
			if (j >= n) continue;
			dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())

ka=[]
cnt=[0]*m
for i in range(n):
    ka.append([int(x) for x in input().split()])
for i in range(n):
    for j in range(1,ka[i][0]+1):
        cnt[ka[i][j]-1]+=1
print(cnt.count(n))



Measured memory_bytes: 3060
#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 REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int x, y;
  cin >> x >> y;

  rep(i, x+1){
    if(i*2 + (x-i)*4 == y){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops") 
#include<bits/stdc++.h>
 
#define ll 			long long int 
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;
 
#define N  105
ll mod=1e9+7;
 ll dp[10005][105][2];
 string s;
 int n;
 int d;
 int rec(int i, int rem, int flag)
 {
 	if(i==n)
 	{
 		if(rem==0)
 			return 1;
 		return 0;

 	}
 	ll &res=dp[i][rem][flag];
 	if(res!=-1)
 		return res;
 	res=0;
 	if(flag)
 	{
 		for(int j=0;j<=s[i]-'0';j++)
 		{
 			if(j==s[i]-'0')
 				res=(res+rec(i+1,(rem+j)%d,true))%mod;
 			else
 				res=(res+rec(i+1,(rem+j)%d,false))%mod;
 		}
 	}
 	else
 	{
 		for(int j=0;j<=9;j++)
 		{
 			
 				res=(res+rec(i+1,(rem+j)%d,false))%mod;
 		}

 	}
 	return res;
 }
void solve()
{

	memset(dp,-1,sizeof(dp));
	
	
	cin>>s;
	n=s.length();
	//int d;
	cin>>d;
	cout<<(rec(0,0,1)%mod-1%mod+mod)%mod;
	

}
	
	
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	#ifndef ONLINE_JUDGE
    	// for getting input from input.txt
    	freopen("input.txt", "r", stdin);
    	// for writing output to output.txt
    	freopen("output.txt", "w", stdout);
	#endif
    	
    
   //cin>>TESTS;
	int p=1;
	while(TESTS--)
	{
		//cout<<"CASE #"<<p<<":"<<" ";
		solve();
		p++;
		
		
	}
	return 0;
}

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

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

int main()
{
	int N;
	cin >> N;
	if ( N % dsum(N) == 0 ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return ( 0 );
}


Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		var b = Console.ReadLine();

		if(b == "A")Console.WriteLine("T");
		if(b == "C")Console.WriteLine("G");
		if(b == "G")Console.WriteLine("C");
		if(b == "T")Console.WriteLine("A");
	}
}

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

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

  int ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    if (a[i] == a[i + 1]) {
      ans++;
      i++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string s;
		cin >> s;
		cout << s;
		if (s.back() == 's') cout << "es";
		else cout << "s";
	}
	return 0;
}

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

int main(){
    int n,b,zero = 0,bounding = 1;
    cin >> n >> b;
    vector<int> bound(n);
    for(int i = 0;i < n;i++){
        cin >> bound.at(i);
    }
    for(int i = 0;i < n;i++){
            zero += bound.at(i);
            if(b < zero){
                break;
            }
            bounding++;
    }
    cout << bounding << endl;
}

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

using namespace std;

bool ok(const vector<pair<int, int>>& v)
{
	int p = 0;
	for (auto& x : v) {
		if (p + x.first < 0) {
			return false;
		}
		p += x.second;
	}
	return true;
}

int main()
{
	int N;
	cin >> N;
	vector<string> S(N);
	for (auto& x : S) {
		cin >> x;
	}

	vector<pair<int, int>> L, R;
	int total = 0;
	for (const auto& x : S) {
		int h = 0;
		int b = 0;
		for (auto c : x) {
			if (c == '(') {
				++h;
			}
			else {
				--h;
			}
			b = min(b, h);
		}

		if (h > 0) {
			L.emplace_back(b, h);
		}
		else {
			R.emplace_back(b - h, -h);
		}

		total += h;
	}

	sort(L.rbegin(), L.rend());
	sort(R.rbegin(), R.rend());
	if (total == 0 && ok(L) && ok(R)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 42504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
const int MAX = 510000;
//const int MOD = 998244353;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    // 前処理
    COMinit();
    int N,P;
    cin >> N >> P;
    vector<int> A(N);
    ll odd=0,even=0;
    rep(i,N){
        cin >> A[i];
        if(A[i]%2==0) even++;
        else odd++;
    }
    ll ans = 0;
    ll tmp = 0;
    ans += (ll)powl(2,even);
    if(P==1){
        for(int i=1;i<=odd;i+=2){
            tmp += COM(odd,i);
        }
    }else{
        for(int i=0;i<=odd;i+=2){
            tmp += COM(odd,i);
        }
    }
    ans *= tmp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15668
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define ForR(i,a,b) for(ll i=a;i>=b;i--)
#define maxn 300002
#define pb push_back
#define X first
#define Y second
#define mod 1000000007
#define base 17
using namespace std;

int N;
string S;
int cntE[maxn], cntW[maxn];  // W W W || E E  => cntW = 3 , cntE = 2
main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    cout.tie(NULL);   
    cin >> N >> S;
    For(i,1,N){
    	cntW[i] = cntW[i-1];
    	if(S[i-1]=='W') cntW[i]++;
//    	cout << cntW[i] << " ";
	}
	ForR(i,N,1){
    	cntE[i] = cntE[i+1];
    	if(S[i-1]=='E') cntE[i]++;
//    	cout << cntE[i] << " ";
	}
	int ans = N+1;
	For(i,1,N){
		ans = min(ans,cntW[i-1] + cntE[i+1]);
	}
	cout << ans;
}

Measured memory_bytes: 2964
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	v := float64(n) / 1.08

	if isInteger(v) {
		fmt.Println(v)
		return
	}

	for i := 0; i < 60000; i++ {
		if i*108/100 == n {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(":(")

}
func isInteger(x float64) bool {
	return math.Floor(x) == x
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
char*C="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?",*strchr();L[]={6,8,4,4,3,5,8,6,4,8,4,5,8,8,5,3,8,4,5,5,8,8,6,8,8,8,3,6,6,8,6,6};B[]={0x25,0x9a,0x05,0x01,0x06,0x09,0x9b,0x10,0x07,0x98,0x06,0x04,0x99,0x9e,0x05,0x07,0x9f,0x08,0x06,0x07,0x9c,0x9d,0x02,0x92,0x93,0x90,0x05,0x11,0x03,0x91,0x00,0x01};b,l;main(c){for(;c=getchar(),c+1;)if(c-10)for(c=strchr(C,c)-C,b=b<<L[c]|B[c],l+=L[c];l>4;putchar(C[b>>l&31]))l-=5;else l&&putchar(C[(b<<=5-l)&31]),l=0,putchar(c);exit(0);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

int main(){
    ll N,M;
    cin>>N>>M;
    vl A(N);
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    sort(all(A));
    vl CA(N+1);
    for(ll i=0;i<N;i++){
        CA[i+1]=CA[i]+A[i];
    }
    ll low=0;
    ll high=2e5+1;
    ll cnt=0;
    ll ret=0;
    while((high-low)>1){
        ll mid=(high+low)/2;
        //  mid is lowest value obtained in handshake
        cnt=0;
        // finding number of handshake
        ret=0;
        for(auto a:A){
            auto it=lower_bound(all(A),mid-a);
            int idx=it-A.begin(); //index of element just above or equal to mid-a
            cnt+=A.end()-it;    //number of element abobe or equal to c-a
            ret+=(CA[N]-CA[idx]+a*(A.end()-it));
        }
        if(cnt>=M){
            low=mid;
        }else{
            high=mid;
        }
    }
    cout<<(ret-(cnt-M)*low)<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int a, b;
	cin >> a >> b;
	int res = 1;
	if (res == a || res == b) res++;
	if (res == a || res == b) res++;
	cout << res << endl;
}


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

int main() {
	// your code goes here
	string a,b;
cin>>a;
cin>>b;
int m=a.length();
int n=b.length();
int c[m][n];
if(a[0]!=b[0])c[0][0]=0;
else c[0][0]=1;
for(int i=1;i<m;i++)
{
    if(a[i]==b[0])c[i][0]=1;
    else c[i][0]=c[i-1][0];
}
for(int i=1;i<n;i++)
{
    if(b[i]==a[0])c[0][i]=1;
    else c[0][i]=c[0][i-1];
}
for(int i=1;i<m;i++)
{
    for(int j=1;j<n;j++)
    {
        if(a[i]==b[j])c[i][j]=c[i-1][j-1]+1;
        else c[i][j]=max(c[i-1][j],c[i][j-1]);
    }
}
int l=c[m-1][n-1];
int i=m-1,j=n-1;
vector<char> p;
while(i>=0 && j>=0)
{
    if(a[i]==b[j])
    {
        p.push_back(a[i]);
        i--;
        j--;
        l--;
    }
     else if(c[i-1][j]>=c[i][j-1] && i>=1 && j>=1)i--;
else if(j==0)i--;
else if(i==0)j--;
else j--;
}
reverse(p.begin(),p.end());
if(p.size()!=0)for(int i=0;i<p.size();i++)cout<<p[i];
else cout<<' ';
	return 0;
}

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

int main() {
int x;
cin >> x;
if (x<1200){
    cout<<"ABC"<<endl;
}
if (1200<=x && x<2800){
    cout<<"ARC"<<endl;
}
if (x>=2800){
    cout<<"AGC"<<endl;
}
    return 0;
}

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

namespace _1_10_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            double x1 = double.Parse(s[0]);
            double y1 = double.Parse(s[1]);
            double x2 = double.Parse(s[2]);
            double y2 = double.Parse(s[3]);
            double answer = 0;

            double a = x2 - x1;
            double b = y2 - y1;

            answer = Math.Sqrt(a * a + b * b);

            Console.WriteLine(answer);
        }
    }
}



Measured memory_bytes: 17968
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100001;

int main(){
  int n;
  int a[maxn];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  int res=0;
  for(int i=0;i<n;i++){
    int tmp=0;
    tmp+=upper_bound(a,a+n,a[i]+2)-lower_bound(a,a+n,a[i]+2);
    tmp+=upper_bound(a,a+n,a[i]+1)-lower_bound(a,a+n,a[i]+1);
    tmp+=upper_bound(a,a+n,a[i])-lower_bound(a,a+n,a[i]);
    res=max(res,tmp);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;

int main() {
	string s;
	int K;
	cin >> s >> K;
	rep(i, s.size()) {
		int cnt = (26 - (s[i] - 'a')) % 26;
		if (cnt <= K) {
			s[i] = 'a';
			K -= cnt;
		}
	}
	s[s.size() - 1] = 'a' + (s[s.size() - 1] - 'a' + K) % 26;
	cout << s << endl;
}

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

// DFS

void dfs(Graph &G, map<pair<int, int>, int> &MAP, vector<int> &color, int x) {
  
  for (int nx : G[x]) {
    
    if (color[nx] != -1) continue;
    
    if (MAP[{x, nx}] % 2 == 0) {
      color[nx] = color[x];
      dfs(G, MAP, color, nx);
    }
    
    else {
      color[nx] = 1 - color[x];
      dfs(G, MAP, color, nx);
    }
    
  }
  
  return;
  
}

int main () {
  
  // 入力
  
  int N;
  cin >> N;
  
  Graph G(N);
  map<pair<int, int>, int> MAP;
  
  for(int i = 0; i < N - 1; i++) {
    
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    
    G[a].push_back(b);
    G[b].push_back(a);
    MAP[{a, b}] = w;
    MAP[{b, a}] = w;
    
  }
  
  // DFS
  
  vector<int> color(N, -1);
  color[0] = 0;
  dfs(G, MAP, color, 0);
  
  // 出力
  
  for (int i = 0; i < N; i++) {
    cout << color[i] << endl;
  }
    
  
}

Measured memory_bytes: 24448
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vec A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i != 0) {
      if (A[i] - A[i - 1] > 1) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      if (A[0] > 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] != A[i - 1] + 1) {
      ans += A[i - 1];
    }
  }
  ans += A[N - 1];

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


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

int main(){
    int N; cin>>N;
    int X[N],Y[N];
    for(int i=0;i<N;i++){
        cin>>X[i];
        Y[i] = X[i];
    }

    sort(Y,Y+N);
    // for(int i=0;i<N;i++) cout<<X[i];
    int I = (N+1)/2 -1;
    int mid = Y[I];
    // cout<<I<<' ' <<Y[I]<<endl<<endl;
    int ans[N];
    // for(int i=0;i<N;i++) cout << Y[i] << endl;
    // int tmp;
    // vector<int>::iterator it;
    // for(it=X.begin();it!=X.end();it++){
    //     tmp=*it;

    // }
    for(int i=0;i<N;i++){
        if(X[i]<=mid) ans[i] = Y[I+1];
        else ans[i] = Y[I];
    }

    for(int i=0;i<N;i++) cout << ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 4480
object Main extends App {
	val Array(a, b, k) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
 	var ans = List[Int]()

 	for(i<-1 to math.min(a,b)){
 		if(a%i == 0 && b%i == 0){
 			ans ::= i
 		}
 	}

 	println(ans(k-1))
}

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

int main() {
	int n, m; cin >> n >> m;
	int a[100], b[100], c[100], d[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < n; i++) {
		int minv = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		int check_point = 1;
		for (int j = 1; j < m; j++) {
			int current = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (minv > current) {
				minv = current;
				check_point = j + 1;
			}
		}
		cout << check_point << endl;
	}

	return 0;
}

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

using namespace std;
struct position {
    int x, y;
    int length;
};

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    const auto N = s1.size(), M = s2.size();
    auto dp = vector<vector<position>>(N + 1, vector<position>(M + 1, {0, 0, 0}));

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (dp[i][j - 1].length > dp[i - 1][j].length) {
                dp[i][j] = dp[i][j - 1];
            } else {
                dp[i][j] = dp[i - 1][j];
            }
            if (s1[i - 1] == s2[j - 1] && dp[i - 1][j - 1].length + 1 >= dp[i][j].length) {
                dp[i][j] = {i - 1, j - 1, dp[i - 1][j - 1].length + 1};
            }
//            printf("dp[%d][%d] = {%d,%d,%d}\n", i, j , dp[i][j].x, dp[i][j].y, dp[i][j].length);
        }
    }

    position cur = dp[N][M];
    string ans = "";
    while (cur.length > 0) {
        int x = cur.x ;
        ans = ans + s1[x];
        cur = dp[cur.x][cur.y];
    }
    reverse(ans.begin(), ans.end());
    cout << ans<<endl;
}

Measured memory_bytes: 105984
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,i,j,sum=0;
cin >> N ;
int d[N];
for(i=0;i<N;i++){
    cin >> d[i];
}
for(i=0;i<N;i++){
    for(j=(i+1);j<N;j++){
        sum += d[i]*d[j];
    }
}
cout << sum << endl;
return 0;
}


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

int main() {
	int N, M; cin >> N >> M;
	vector<int> X(100001, 0), sum(M, 0), cand(M, 0);
	for(int i=0; i<N; ++i){
	    int a; cin >> a;
	    ++X[a];
	    ++sum[a%M];
	}
	for(int i=0; i<100001; ++i) cand[i%M] += X[i]/2;
	int ans=sum[0]/2;
	for(int i=1; i*2<=M; ++i){
	    if(i*2==M){
	        ans += sum[i]/2;
	        break;
	    }
	    int mn=(sum[i]<sum[M-i] ? i : M-i);
	    ans += sum[mn];
	    ans += min((sum[M-mn]-sum[mn])/2, cand[M-mn]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
n=read()
ls=factorization(n)
res=0
#print(ls)
for num in ls:
    k=num[1]
    if num[0]==1:
      break
    i=1
    while True:
        k-=i
        if k>=0:
            res+=1
        else:break
        i+=1
print(res)

Measured memory_bytes: 9880
n = int(input())

name = ['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']
ans = ''

stop = False

while not stop: 
  if (n-1) // 26 >= 1:
    ans += name[(n-1) % 26]
    n = (n-1) // 26
  else:
    ans += name[n-1]
    stop = True

r_ans = ans[::-1]

print(r_ans)

Measured memory_bytes: 9212
/** 
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  if (n == 1 || m == 1) {
    cout << 1 << '\n';
    return 0;
  }
  if (n % 2 == 0 || m % 2 == 0) {
    cout << n * m / 2 << '\n';
    return 0;
  } 
  cout << (n * m + 1) / 2 << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder output = new StringBuilder();
		while(true) {
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			
			if (m == -1 && f == -1 && r == -1) break;
			if (m == -1 || f == -1) {
				output.append("F").append('\n');
			} else {
				if (m + f >= 80)
					output.append("A").append('\n');
				if (m + f >= 65 && m + f < 80)
					output.append("B").append('\n');
				if (m + f >= 50 && m + f < 65)
					output.append("C").append('\n');
				if (m + f >= 30 && m + f < 50) {
					if (r >= 50) {
						output.append("C").append('\n');
					} else {
						output.append("D").append('\n');
					}
				}
				if (m + f < 30)
					output.append("F").append('\n');
			}
			
		}
		System.out.print(output);
		scan.close();
	}

}

Measured memory_bytes: 18816
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
int n,m,q;
int x[2005][2005],y[2005][2005],z[2005][2005],w[2005][2005];
int main(void){
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char c;
            scanf(" %c",&c);
            if(c=='1')x[i][j]=1;
            y[i][j]=x[i][j]+y[i-1][j]+y[i][j-1]-y[i-1][j-1];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(x[i][j]){
                z[i][j]=x[i][j+1];
                w[i][j]=x[i+1][j];
            }
            z[i][j]+=z[i-1][j]+z[i][j-1]-z[i-1][j-1];
            w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
        }
    }
    for(int i=0;i<q;i++){
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        a--;b--;
        printf("%d\n",y[c][d]-y[a][d]-y[c][b]+y[a][b]-z[c][d-1]+z[a][d-1]+z[c][b]-z[a][b]-w[c-1][d]+w[a][d]+w[c-1][b]-w[a][b]);
    }
}

Measured memory_bytes: 64640
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
template<class T> bool umin(T &x,T y) { if (x<y) return 0; x=y; return 1; }
template<class T> bool umax(T &x,T y) { if (x>y) return 0; x=y; return 1; }
using ll = long long;
using ld = long double;

int const INF=1e9;

struct dist_func {
	ll l1,r1,l2,r2,m1,m2;
	vector<ll> ts;
	
	dist_func(ll a,ll b,ll c,ll d,ll e,ll f): l1(a),r1(b),l2(c),r2(d),m1(e),m2(f) {
		ts.push_back(0);
		while (true) {
			ll nt=find_next(ts.back());
			if (nt==int(2e8)) break;
			ts.push_back(nt);
		}
	}
	
	ll eval(ll t) const {
		return max({r1+t,r2-t,m2})-min({l1+t,l2-t,m1});
	}
	
	ll operator()(ll t) const {
		return eval(t);
	}
	
	ll find_next(ll t) {
		ll s=eval(t+1)-eval(t);
		ll l=t,r=2e8;
		while (l<r) {
			ll m=l+(r-l)/2;
			if (eval(m+1)-eval(m)==s) l=m+1; else r=m;
		}
		return l;
	}
};

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	ll r1,r2,l1,l2,x1,x2,d1,d2,u1,u2,y1,y2;
	r1=l1=x1=d1=u1=y1=INF;
	r2=l2=x2=d2=u2=y2=-INF;
	
	int N;
	cin>>N;
	rep(i,0,N) {
		ll x,y;
		string s;
		cin>>x>>y>>s;
		x*=2;
		y*=2;
		switch (s[0]) {
			case 'R':
				umin(r1,x),umax(r2,x),umin(y1,y),umax(y2,y);
				break;
			case 'L':
				umin(l1,x),umax(l2,x),umin(y1,y),umax(y2,y);
				break;
			case 'U':
				umin(u1,y),umax(u2,y),umin(x1,x),umax(x2,x);
				break;
			case 'D':
				umin(d1,y),umax(d2,y),umin(x1,x),umax(x2,x);
				break;
			default:
				throw;
		}
	}
	
	dist_func dx(r1,r2,l1,l2,x1,x2);
	dist_func dy(u1,u2,d1,d2,y1,y2);

	ll res=dx(0)*dy(0);
	for (ll t:dx.ts) umin(res,dx(t)*dy(t));
	for (ll t:dy.ts) umin(res,dx(t)*dy(t));
	cout<<ld(res)/4<<"\n";	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
vector<int> vec(3);
  rep(i,3) {
    cin >>vec.at(i);
  }
int count=1;
  if((vec.at(0)==vec.at(1)) && (vec.at(1)==vec.at(2))) {
cout << 1 << endl;
  }
else if( (vec.at(0)==vec.at(1)) || (vec.at(0)==vec.at(2)) || (vec.at(2)==vec.at(1)))  {
  cout << 2<< endl;
}
else {
cout << 3 << endl;
}
}

 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k;cin>>n>>k;
    vector<int> h(2*n,INF);
    rep(i,n) cin >> h[i];
    vector<int> dp(n+10,INF);
    dp[0] = 0;
    rep(i,n){
        for(int j=1;j<=k;j++){
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1536
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<cstdio>
#include<algorithm>
using namespace std;
int main() 
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    printf("%s\n", c % __gcd(a, b) == 0 ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <iomanip>

using namespace std;

int main(void)
{
    long double sum = 0;
    long double ave = 0;
    int N;
    long double C=1;
    int tmp1, tmp2;
    int X[10],Y[10];

    scanf("%d",&N);
    
    for(int i=0; i<N; i++){
        scanf("%d %d",&X[i],&Y[i]);
    }
    
    for(int i=1; i<=N; i++){
        C*=i;
    }
    //cout << "C=" << C << endl;

    

    int array[] = {0,1,2,3,4,5,6,7};

    do{
        sum = 0;
        for(int i=0; i<N-1; i++){
            tmp1 = array[i];
            tmp2 = array[i+1];
            //cout << array[i];
            //if(i != N-1) cout << " ";
            //sum += (long double)sqrt(pow((long double)(X[tmp1]-X[tmp2]),2)+pow((long double)(Y[tmp1]-Y[tmp2]),2))/(long double)C;
            sum += hypot(X[tmp1]-X[tmp2],Y[tmp1]-Y[tmp2])/C;
            
            //cout << "sum =" <<sum << endl;
        }
        //cout << sum << endl;
        ave += (long double)sum;

    }while(next_permutation(array,array+N));

    cout << fixed << setprecision(12) << ave << endl;
    

    return 0;
}

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

#define MAX 1000

int main(void)
{
	int n,i;
	double a[MAX];
	double ave,sum;
	while (1) {
		scanf("%d",&n);
		if (n == 0) {
			break;
		}
		else {
			sum = 0;
			for (i=0; i<n; i++) {
				scanf("%lf",&a[i]);
				sum += a[i];
			}
			ave = sum/n;
			sum = 0;
			for (i=0; i<n; i++) {
				sum += (a[i] - ave)*(a[i]-ave);
			}
			printf("%lf\n", sqrt(sum/n));
		}
	}
	return 0;
}



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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i < n; ++i){
		if (s[i] == s[i - 1] && s[i] == 'L'){
			ans++;
		}
	}
	for (int i = n - 2; i >= 0; --i){
		if (s[i] == s[i + 1] && s[i] == 'R'){
			ans++;
		}
	}
	cout << min(n - 1, ans + 2 * k);
	return 0;
}



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

int H, W[100];
int M[100][100];
int dp[100][100];

void input() {
  string str;
  
  while( getline( cin, str ) ) {
    replace( str.begin(), str.end(), ',', ' ' );
    stringstream ss(str);
    while( ss >> M[H][W[H]] ) W[H] ++;
    H ++;
    /*
    cout << H-1 << " " << W[H-1] << endl;
    for( int i=0; i<W[H-1]; i++ ) cout << M[H-1][i] << " ";
    cout << endl;
    */
  }
  
}

int solve() {

  for( int i=0; i<H; i++ ) {
    for( int j=0; j<W[i]; j++ ) {
      if( i-1 < 0 ) {
	dp[i][j] = M[i][j];
	continue;
      }
      if( i <= H/2 && j-1 < 0 ) {
	dp[i][j] = dp[i-1][j] + M[i][j];
	continue;
      }
      if( i <= H/2 && j+1 == W[i] ) {
	dp[i][j] = dp[i-1][j-1] + M[i][j];
	continue;
      }
      if( i<=H/2 ) {
	dp[i][j] = max( dp[i-1][j-1], dp[i-1][j] ) + M[i][j];
      } else {
	dp[i][j] = max( dp[i-1][j], dp[i-1][j+1] ) + M[i][j];
      }
    }
  }
  
  /*
  for( int i=0; i<H; i++ ) {
    for( int j=0; j<W[i]; j++ ) {
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
  */

  return dp[H-1][0];
}

int main() {
  input();
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

vi C, X;
vvi A;
int n,m,x;

int findMinCost(int index)
{
	//cout<<index<<"\n";
	bool flag = true;
	rep(i, 0, m - 1)
	{
		if(X[i] > 0){
			flag = false;
			break;
		}
	}
	if(flag){
			return 0;
		}

	if(index > n - 1)
		return INT_MAX;

	
	rep(i, 0, m - 1)
	{
		X[i] -= A[index][i];
	}
	int min_cost =  findMinCost(index+1);
	if(min_cost != INT_MAX)
		min_cost += C[index];
	rep(i, 0, m - 1)
	{
		X[i] += A[index][i];
	}

	return min(min_cost, findMinCost(index + 1));
}


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	
	cin>>n>>m>>x;
	C = vi(n);
	A = vvi(n,vi(m));

	rep(i ,0, n - 1)
	{
		cin>>C[i];
		rep(j, 0, m - 1)
			cin>>A[i][j];
	}

	X = vi(m , x);
	int min = findMinCost(0);
	if(min == INT_MAX)
		cout<< -1;
	else
		cout<<min;


}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
typedef long long ll;
const int mx=10000;
int a[mx];
int tree[mx*4];
//void init(int node, int b, int e)
//{
//    if (b == e) {
//        tree[node] = a[b];
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    init(Left, b, mid);
//    init(Right, mid + 1, e);
//    tree[node] = __gcd(tree[Left],tree[Right]);
//}
//int query(int node, int b, int e, int i, int j)
//{
//    if (i > e || j < b)
//        return 0;
//    if (b >= i && e <= j)
//        return tree[node];
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    int p1 = query(Left, b, mid, i, j);
//    int p2 = query(Right, mid + 1, e, i, j);
//    return __gcd(p1,p2);
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    update(Left, b, mid, i, newvalue);
//    update(Right, mid + 1, e, i, newvalue);
//    tree[node] = __gcd(tree[Left] , tree[Right]);
//}
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if((4*a*b)<((c-a-b)*(c-a-b)) && c-a-b>=0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

int main()
{
  int N;
  cin >> N;
  // printf("%d\n",N);

  float ans;
  if(N % 2 == 1){
    ans = ((N/2)+1);
  }else{
    ans = (N/2);
  }
  // printf("%d\n",N%2);
  // printf("%d\n",N/2);
  printf("%f\n",ans/N);
}

Measured memory_bytes: 256
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/

#include <bits/stdc++.h>
using namespace std;
 
// #define    int                      long long int
 
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1110111110111
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <long long int , pll>              //pair of ll and pair ll 
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    char c;
    cin>>c;
    cout<<char(c+1);
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, K = map(int, input().split())

ansA = A
ansB = B
ansA -= min(A, K)
K -= A - ansA
ansB -= min(B, K)
print(ansA, ansB)

Measured memory_bytes: 9412
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  int num = 1;
  rep(i,N) {
    if(A[i]==num) {
      num++;
    }
  }
  if(num-1==0) {
    cout << -1 << endl;
  } else {
    cout << N-(num-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
import java.util.*
 
fun main(args: Array<String>) {
    val cin = Scanner(System.`in`)
    val N : Int = cin.nextInt()
    var Ws = ArrayList<String>()
    for (i in 1..N) {
        Ws.add(cin.next())
    }
    var prev = Ws[0][Ws[0].lastIndex]
    var used = mutableMapOf<String, Boolean>()
    used[Ws[0]] = true
    var ans : Boolean = true
    for (i in 1..N-1) {
        if (Ws[i][0] != prev || used[Ws[i]] != null) {
            ans = false
        }
        used[Ws[i]] = true
        prev = Ws[i][Ws[i].lastIndex]
    }
    if (ans) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 31524
def main():
    N,M=map(int,input().split())
    like=[0]*M
    for _ in range(N):
        K,*A=map(int,input().split())
        for num in A:
            like[num-1]+=1
    print(like.count(N))

if __name__=='__main__':
    main()




     


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n - 1];
		
		for (int i = 0; i < n - 1; i++) {
			b[i] = sc.nextInt();
		}
		a[0] = b[0];
		a[1] = b[0];
		
		long res = 0;
		
		for (int i = 2; i < n; i++) {
			int bN = b[i-1];
			if (bN > a[i-1]) {
				a[i] = bN;
			} else {
				a[i] = bN;
				a[i-1] = bN;
			}
		}
		// System.out.println(Arrays.toString(a));
		for (int i = 0; i < a.length; i++) {
			res += a[i];
		}
		// System.out.println(Arrays.toString(b));
		System.out.println(res);
		
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    
    int tHp = scan.nextInt();
    int tAt = scan.nextInt();
    int aHp = scan.nextInt();
    int aAt = scan.nextInt();
    
    for(int i = 0; i <200; i++){
      if(i%2 == 0)
        aHp = aHp - tAt;
      else
        tHp = tHp - aAt;
      
      if(aHp <=0 ){
        System.out.println("Yes");
        break;
      }
      else if(tHp <= 0){
        System.out.println("No");
        break;
      }
    }
  }
}
      


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef pair<long,long> PL;
typedef map<long,long> ML;
typedef vector<long> VL;
#define INF (int)(1e9)
#define MAXX 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    V h(n);rep(i,n)cin>>h[i];
    int cnt=0;
    //int now=0;
    rep(i,n-1){
        int tmp=h[i];
        int next=h[i+1];
        if(tmp<next){
            cnt+=next-tmp;
        }
    }
    cout<<cnt+h[0]<<endl;
}




Measured memory_bytes: 256
n = int(input())
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
dic = {}
for i in range(n):
    if i < n / 2:
        dic[sorted_x_list[i]] = sorted_x_list[n // 2]
    else:
        dic[sorted_x_list[i]] = sorted_x_list[n // 2 - 1]
for x in x_list:
    print(dic[x])

Measured memory_bytes: 34824
n,l = map(int, input().split())



sum = 0
tmp_list = []
tmp_abs  = []
for i in range(1,n+1):
  tmp = l + i -1
  sum += tmp
  
  tmp_list.append(tmp)
  tmp_abs.append(abs(tmp))

index = tmp_abs.index(min(tmp_abs))
print(sum-tmp_list[index])


Measured memory_bytes: 3060