akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 44
int fibonach(int );

int main()
{
  int fn,n;

  scanf("%d",&n);

  fn = fibonach(n);

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


int fibonach(int n)
{
  
  int i,a[N];

  for(i=0;i<=n;i++)
    {
      if(i == 0) a[i] = 1;
      else if(i == 1) a[i] = 1;
      else a[i] = a[i-2] + a[i-1];
    }

    return a[i-1];

  //再帰版
  /*
    if(n == 0 || n == 1) return 1;
    return fibonach(n - 1) + fibonach(n - 2);
  */
}



Measured memory_bytes: 2104
N,x=map(int,input().split())
a=list(map(int,input().split()))
eat=0
for i in range(N-1):
    num1=a[i]
    num2=a[i+1]
    if num1+num2>x:
        buf=min(num1+num2-x,num2)
        eat=eat+buf
        num2=num2-buf
        if num1>x:
            buf=num1-x
            eat=eat+buf
            num1=num1-buf
    a[i]=num1
    a[i+1]=num2
    #print(a)
print(eat)

Measured memory_bytes: 85456
h,w=map(int,input().split())
s=[list("."+input()+".") for _ in range(h)]
s= [["."]*(w+2)] + s + [["."]*(w+2)] 
for i in range(1,h+1):
    l=[]
    for k in range(1,w+1):
        if s[i][k]=="#":
            p="#"
        else:
            p=0
            p+=s[i-1][k-1:k+2].count("#")
            p+=s[i][k-1:k+2].count("#")
            p+=s[i+1][k-1:k+2].count("#")
        l.append(str(p))
    print("".join(l))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	string s;
	int w;
	cin >> s >> w;
	string ans;

	int i = 0;
	while (i < (int)s.size()){
		if (i % w == 0){
			ans += s[i];
		}
		i++;
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
t = a+b

s=input()
n=len(s)

for i in range(n):
	if s[i]=="a" and t > 0:
		print("Yes")
		t = t - 1
	elif s[i]=="b" and t > 0 and b > 0:
		print("Yes")
		t = t - 1
		b = b - 1
	else:
		print("No")

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

int main() {
	long long N;
	cin >> N;
	long long ANS = 0;
	for (long long i = 1; i <= N; i++) {
		long long X = N / i;
		ANS += X * (X + 1) / 2 * i;
	}
	cout << ANS << endl;
}

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

int main() {
	std::vector<std::vector<int>> vv{ {1,3,5,7,8,10,12},{4,6,9,11},{2} };
	int x, y,count=0;
	bool flag=false;

	std::cin >> x >> y;
	
	for (int i = 0; i < 2; i++) {
		auto itr_x = std::find(vv[i].begin(), vv[i].end(), x); 
		auto itr_y = std::find(vv[i].begin(), vv[i].end(), y);

		if (itr_x != vv[i].end() && itr_y != vv[i].end()) {
			flag = true;
			break;
		}
	}

	std::cout << (flag ? "Yes" : "No") << std::endl;

	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 1e9  //
#define INFLL 4e18  //
#define MOD (1e9)+7
#define MP make_pair

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

// a 0x61  z 0x7a  0 0x30

//------------------------------------------------------

vector<pii> edge[50][50]; //行き先を格納
int cost[50][50] = {}; //(0,0)からの最短距離
bool used[50][50] = {};
int h, w;

void bfs() {

    queue<pii> que;

    cost[h - 1][w - 1] = INF;

    cost[0][0] = 0;
    que.push(MP(0, 0));
    used[0][0] = true;

    while (!que.empty()) {
        pii q = que.front();

        for (auto ep : edge[q.first][q.second]) {
            if (!used[ep.first][ep.second]) {
                que.push(MP(ep.first, ep.second));
                used[ep.first][ep.second] = true;
                cost[ep.first][ep.second] = cost[q.first][q.second] + 1;
            }
        }

        que.pop();
    }

}

int main() {
    int white = 0;

    cin >> h >> w;

    char s[h][w];

    rep(i, h) {

        rep(j, w) {
            cin >> s[i][j];
            if (s[i][j] == '.') white++;
        }
    }

    //横の辺

    rep(i, h) {

        rep(j, w - 1) {
            if (s[i][j] == '.' && s[i][j + 1] == '.') {
                edge[i][j].push_back(MP(i, j + 1));
                edge[i][j + 1].push_back(MP(i, j));
            }
        }
    }

    //縦の辺

    rep(i, h - 1) {

        rep(j, w) {
            if (s[i][j] == '.' && s[i + 1][j] == '.') {
                edge[i][j].push_back(make_pair(i + 1, j));
                edge[i + 1][j].push_back(make_pair(i, j));
            }
        }
    }

    bfs();

    if (cost[h - 1][w - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << white - cost[h - 1][w - 1] - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main (){
	int N, a, b;
	scanf ("%d %d %d", &N, &a, &b);
	int sum = 0;
	
	for (int i = 0; i <= N; i++){
		int digitSum = 0;
		int temp = i;
		while ( temp != 0){
			digitSum = digitSum + temp % 10;
			temp /= 10;
		}
		
	if (digitSum >= a && digitSum <= b){
		sum += i;
	}
	}
	printf ("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1728
N = int(input())

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

def norm(n, prev_list):
	out_list = []
	for line in prev_list:
		for i in range(len(set(line))+1):
			new_line = line + alphabet[i]
			out_list.append(new_line)
	return out_list

init_line = ['a']

for _ in range(N-1):
	init_line = norm(1, init_line)
for line in init_line:
	print(line)

Measured memory_bytes: 12980
n = int(raw_input())
a = map(int, raw_input().split())
ans = []
for k in range(2):
    s, cur = 0, 0
    for j in range(n):
        s += a[j]
        if (k+j) % 2 == 0:
            if s <= 0:
                cur += abs(1 - s)
                s = 1
        else:
            if s >= 0:
                cur += abs(-1 - s)
                s = -1
    ans.append(cur)
print min(ans)

Measured memory_bytes: 11272
#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;
#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 200005
#define mod 100000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}

int main()
{
  boost
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    
    freopen("output.txt", "w", stdout);
#endif 
ll n;
cin>>n;
ll r=0;
ll i;
ll p=1e7;
ll ans=-1;
REP(i,p)
{
  r=(r*10+7)%n;
  if(r==0)
  {
 ans=i+1;
 break;
  }
}
cout<<ans<<"\n";
}


Measured memory_bytes: 3628
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    long long x, k, d;
    cin >> x >> k >> d;
    if (x < 0)
        x *= -1;
    long long t = x % d;
    long long moves = x / d;
    cerr << t << " " << moves << "\n";
    if (k <= moves) {
        cout << x - d * k;
    } else {
        long long rest = k - moves;
        if (rest % 2 == 0)
            cout << t;
        else
            cout << -(t - d);
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n, m;
vector<int> g[200010];
bool v[200010];
int main(){
	cin>>n>>m;
	int a, b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for(auto t: g[1])
		for(auto r: g[t])
			v[r]=1;
	if(v[n]) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

string s;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> s;
    int m=753, x=0;
    for (int i = 0; i < s.sz-2; ++i)
        x=100*(s[i]-'0')+10*(s[i+1]-'0')+s[i+2]-'0', m=min(m,abs(x-753));
    cout << m;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int count = 0;
    while(N >= K){
      N = N / K;
      count += 1;
    }
    System.out.println(count + 1);
  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <cstdio>
#include <numeric>

using namespace std;


int main()
{
	int n;
	int m;

	cin >> n >> m;

	for (int i = 0; i < m && n >= 0; ++i)
	{
		int t;
		cin >> t;
		n -= t;
	}

	if (n < 0)
	{
		cout << -1;
	}
	else
	{
		cout << n;
	}


	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////




int main(){fastio
    ll a,b,t;cin>>a>>b>>t;
    cout<<t/a*b<<endl;
    
    return 0;
}

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

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

   bool frag = true;
   if (A != 5 && A != 7) frag = false;
   if (B != 5 && B != 7) frag = false;
   if (C != 5 && C != 7) frag = false;
   if (A + B + C != 17) frag = false;

   if (frag)
      cout << "YES" << endl;
   else
      cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define dwn(i,x,y) for(int i=(x);i>=(y);--i)
#define view(u,k) for(int k=fir[u];~k;k=nxt[k])
#define maxn 1000007
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();while(!isdigit(ch)&&ch!='-')ch=getchar();if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();return x*f;
}
void write(int x)
{
	if(x==0){putchar('0'),putchar(' ');return;}int f=0;char ch[20];if(x<0)putchar('-'),x=-x;
	while(x)ch[++f]=x%10+'0',x/=10;while(f)putchar(ch[f--]);putchar(' ');return;
}
int n,q[maxn],hd=1,tl=0,up,dn,ans;
char s[maxn],t[maxn];
int main()
{
	n=read();scanf("%s%s",s,t);up=n-1,dn=n-1;
	rep(i,0,n-1)if(s[i]!=t[i])
	{
		while(dn>=0)
		{
			while(dn&&t[dn-1]==t[dn])--dn;
			while(up>=0&&(up>dn||s[up]!=t[dn]))--up;
			//cout<<dn<<" "<<up<<endl;
			if(up<0){puts("-1");return 0;}
			while(hd<=tl&&q[hd]-(tl-hd+1)>=dn)hd++;
			if(up!=dn)q[++tl]=up;
			ans=max(ans,tl-hd+2);
			dn--;
		}
		write(ans);
		return 0;
	}
	puts("0");
	return 0;
}
/*
5
abcde
aaacc
*/

Measured memory_bytes: 6144
abc = "abcdefghij"

N = int(input())

def dfs(S, i):
    if len(S) == N:
        return S + "\n"

    res = ""
    for c in abc[:i]:
        res += dfs(S + c, i)
    res += dfs(S + abc[i], i + 1)

    return res

print(dfs("", 0))

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int a[5][5];
int n ,x[135];
bool aa[5][5];
int main() 
{
	
	for(int i=1;i<=3;i++)
	{	
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
		}
	}
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int z=1;z<=3;z++)
			{
				if(a[j][z]==x[i])
				{
					aa[j][z]=1;
				}
			}
		}
	}
	if((aa[1][1]==1 && aa[2][1]==1 && aa[3][1]==1) || (aa[1][1]==1 && aa[2][2]==1 && aa[3][3]==1) || (aa[1][1]==1 && aa[1][2]==1 && aa[1][3]==1) || (aa[2][1]==1 && aa[2][2]==1 && aa[2][3]==1) || (aa[1][2]==1 && aa[2][2]==1 && aa[3][2]==1) || (aa[3][1]==1 && aa[3][2]==1 && aa[3][3]==1) || (aa[1][3]==1 && aa[2][3]==1 && aa[3][3]==1) || (aa[1][3]==1 && aa[2][2]==1 && aa[3][1]==1))
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	ll A, B, K;
	cin >> A >> B >> K;

	vector<ll> v;

	for ( int i = A; i < A + K; i++ )
	{
		if ( i > B ) break;
		v.eb( i );
	}
	for ( int i = B; i > B - K; i-- )
	{
		if ( i < A ) break;
		v.eb( i );
	}
	sort( ALL( v ) );
	UNIQUE( v );

	arep( it, v ) cout << it << endl;

	return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+7
/*
────────▄──────────────▄
────────▌▒█───────────▄▀▒▌
────────▌▒▒▀▄───────▄▀▒▒▒▐
───────▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
─────▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
───▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀██▀▒▌
──▐▒▒▒▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▒▌
──▌▒▒▐▄█▀▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
─▐▒▒▒▒▒▒▒▒▒▒▒▌██▀▒▒▒▒▒▒▒▒▀▄▌
─▌▒▀▄██▄▒▒▒▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌
_▌▀▐▄█▄█▌▄▒▀▒▒▒▒▒▒░░░░░░▒▒▒▐
▐▒▀▐▀▐▀▒▒▄▄▒▄▒▒▒▒▒░░░░░░▒▒▒▒▌
▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒░░░░░░▒▒▒▐
─▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌
─▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐
──▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▒▒▒▒▌
────▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀
───▐▀▒▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
──▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▀
*/
int main() {
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    k--;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            if (k == i) {
                cout << '1';
                return 0;
            }
        } else {
            cout << s[i];
            return 0;
        }
    }
}


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

int main() {
	int a, b;
	char op;

	while (1) {
		cin >> a >> op >> b;
		if (op == '?')break;

		if (op == '+')cout << a + b << endl;
		else if (op == '-')cout << a - b << endl;
		else if (op == '*')cout << a*b << endl;
		else if (op == '/')cout << a / b << endl;

	}
	return 0;
}

Measured memory_bytes: 3096
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int a=in();int b=in();
	if(abs(a-b)<=1)puts("Brown");
	else puts("Alice");
	
}

Measured memory_bytes: 3704
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool cmp(pair <lli, lli>& a, pair <lli, lli>& b) {
	return a.ff > b.ff;
}
void out(vector < pair <lli, lli> >& v) {
	for (auto& x : v) {
		cout << x.first << " " << x.second << endl;
	}
}
lli n;
lli help(lli low, lli high, vector < pair <lli, lli> >& v, vector < vector <lli> >& dp) {
	if (low > high) return 0;
	if (dp[low][high] != -1) return dp[low][high];
	lli ret = 0;
	lli i = n - (high - low + 1) + 1;
	lli left = v[i].ff * abs(low - v[i].ss) + help(low + 1, high, v, dp);
	lli right = v[i].ff * abs(high - v[i].ss) + help(low, high - 1, v, dp);
	ret = max(left, right);
	return dp[low][high] = ret;
}
void solve() {
	cin >> n;
	vector < pair <lli, lli> > v(n + 1);
	for (lli i = 1; i <= n; i++) {
		cin >> v[i].ff;
		v[i].ss = i;
	}
	sort(v.begin() + 1, v.end(), cmp);
	vector < vector <lli> >dp (n + 1, vector <lli>(n + 1, -1));
	cout << help(1, n, v, dp) << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}


Measured memory_bytes: 34868
import numpy as np
n,m = map(int,input().split())
ans = np.ones(m+1)
ans[0] = 0
for i in range(n):
    a = list(map(int,input().split()))
    a.pop(0)
    for i in range(1,m+1):
        if i in a:
            continue
        else:
            ans[i] = 0
print(int(np.sum(ans)))

Measured memory_bytes: 12396
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;

const int N = 1e5 + 20;
const int inf = 1e9;



int main()
{


    int x;
    SC(x);
    int sum = 0, cnt = 0;
    while(sum < x)
    {
        ++cnt;
        sum += cnt;
    }
    PR(cnt);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	vector<ll> a(n); for(auto &b : a) cin >> b;
	vector<vector<ll> > dp(n, vector<ll>(n));
	for(ll i = 0; i < n; i++) dp[i][i] = a[i];
	for(ll len = 2; len <= n; len++) for(ll lb = 0; lb < n; lb++){
		ll rb = lb + len - 1;
		if(rb >= n) continue;
		dp[lb][rb] = max(a[lb] - dp[lb+1][rb], a[rb] - dp[lb][rb-1]);
	}
	cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    int n,k;
    cin>>n>>k;
    ll res = k;
    for(int i=1;i<n;++i) {
        res *= k-1;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int n,x;

while(scanf("%d %d",&n,&x) != EOF){
if(n==0&&x==0){
break;
}

int count = 0;

for(int i = 1; i <= n-2; i++){
   for(int j = i+1; j <= n-1; j++){
      for(int k = j+1; k <= n; k++){
         if(i!=j&&i!=k&&k!=j){
         if(i+j+k==x){
           count++;
          }
          }
}
}
}
printf("%d\n",count);
}
return 0;
}




Measured memory_bytes: 2036
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

map<int, int> nums;

int main() {
    int N;
    cin >> N;
    
    int x;
    rep(i, N) {
        cin >> x;
        nums[x]++;
    }
    
    int cnt = 0;
    for (const auto& imap : nums){
        //cout2( imap.first, imap.second);
        if ( imap.first == imap.second ) continue;
        else if ( imap.first > imap.second ) {
            cnt += imap.second;
        }else {
            cnt += imap.second - imap.first;
        }
    }
    
    cout1(cnt);
}


Measured memory_bytes: 4736
from sys import exit

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

# for i in range(A, B + 1):
#     if i % K == 0:
#         print("OK")
#         exit()

# print("NG")

if A % K == 0:
    print("OK")
    exit()

if B // K > A // K:
    print("OK")
else:
    print("NG")


Measured memory_bytes: 61880
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans=-10*18
for i in range(1<<n):
    mask=[(i>>j)&1 for j in range(n)]
    X=0
    Y=0
    for k, m in enumerate(mask):
        if m==1:
            X+=v[k]
            Y+=c[k]
    ans=max(ans, X-Y)
    
print(ans)

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

int main(){
    int N,C;
    scanf("%d %d",&N,&C);
    int D[C][C];
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            scanf("%d",&D[i][j]);
        }
    }
    int b;
    int c[3][30]={0};
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            scanf("%d",&b);
            c[(i+j)%3][b-1]++;
        }
    }
    int su=1e9;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            if(i==j){continue;}
            for(int k=0;k<C;k++){
                if(i==k || j==k){continue;}
                int t=0;
                for(int l=0;l<C;l++){
                    t+=D[l][i]*c[0][l];
                }
                for(int l=0;l<C;l++){
                    t+=D[l][j]*c[1][l];
                }
                for(int l=0;l<C;l++){
                    t+=D[l][k]*c[2][l];
                }
                su=min(su,t);
            }
        }
    }
    printf("%d\n",su);
    return 0;
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int n,m;

bool compare_by_b(pair<int, string> a, pair<int, string> b) {
    if(a.second != b.second){
        return a.second.compare( b.second )<0;
    }else{
        return a.first > b.first;
    }
}



int main(){
  int ans=0;
  cin>>n;
  string s;
  vector<pair<int, string> > pairs(n);

/*
  sort(pairs.begin(),pairs.end(), compare_by_b);

*/
  REP(i,n){
    cin>>s>>m;
    pairs[i].first=m*200+i;
    pairs[i].second=s;
  }
  
  sort(pairs.begin(),pairs.end(), compare_by_b);

  REP(i,n){
    cout<<(pairs[i].first%200+1)<<endl;

  }
  return 0;
}

Measured memory_bytes: 256
while True:
    list = input().split()
    a = int(list[0])
    b = list[1]
    c = int(list[2])
    if b == '?':
        break
    if b == '+':
        print(a + c)
    if b == '-':
        print(a - c)
    if b == '*':
        print(a * c)
    if b == '/':
        print(a // c)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  string s;
  cin >> n >> s;
  int ans=0;
  rep(i,n-2) {
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using namespace std;

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

	long double r;
	cin >> r;
	cout << fixed << setprecision(10) << 4*r*asin(1) << '\n'; 

	return 0;
} 

Measured memory_bytes: 3784
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CWalkOnMultiplicationTable {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();

            long answer = Long.MAX_VALUE;
            for (long i = 1; i * i <= n; i++) {
                if (n % i == 0) {
                    long j = n / i;
                    answer = Math.min(answer, i + j - 2);
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui, ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; };
int lcm(int a, int b) { return a * b / gcd(a, b); };
int floor(int a, int b) { return (a + b - 1) / b; };
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
};
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
};

int main()
{
  int n;
  cin >> n;
  cout << (10000 - n) % 1000 << endl;
}

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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while(n) {
      if(n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

struct Combination {
  vector<ModInt<>> _fact, _rfact, _inv;
  Combination(long long nsize = 5000000)
      : _fact(nsize + 1), _rfact(nsize + 1),
        _inv(nsize + 1) {
    _fact[0] = _rfact[nsize] = _inv[0] = 1;
    for(int i = 1; i <= nsize; i++)
      _fact[i] = _fact[i - 1] * i;
    _rfact[nsize] /= _fact[nsize];
    for(int i = nsize - 1; i >= 0; i--)
      _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= nsize; i++)
      _inv[i] = _rfact[i] * _fact[i - 1];
  }
  inline ModInt<> fact(int k) const { return _fact[k]; }

  inline ModInt<> rfact(int k) const { return _rfact[k]; }

  inline ModInt<> inv(int k) const { return _inv[k]; }

  ModInt<> P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  ModInt<> C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
  ModInt<> H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 0 : C(n + r - 1, r - 1);
  }
};

long long n, k;
Combination com;

ModInt<> solve();

int main() {
  cin >> n >> k;
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res;
  for(int i = 0; i <= min(k, n); ++i) {
    res += com.C(n, i) * com.H(i, n - i);
  }
  return res;
}


Measured memory_bytes: 58880
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int r,g;
  cin>>r>>g;
  cout<<2*g-r<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
import itertools

n = int(input())
def f(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
lim = 0
while lim**2+lim+4 <= n:
    lim += 1
tmp = list(range(1,lim+1))
# print(lim)
combList = list(itertools.combinations_with_replacement(tmp,3))
ansLis = [0] * (n+1)
for item in combList:
    tmp = f(item[0],item[1],item[2])
    if tmp > n:
        pass
    else:
        if item[0] == item[1] and item[1] == item[2]:
            ansLis[tmp] += 1
        elif item[0] == item[1] or item[1] == item[2] or item[2] == item[0]:
            ansLis[tmp] += 3
        else:
            ansLis[tmp] += 6
# print(ansLis)
for i in range(1,n+1):
    print(ansLis[i])

Measured memory_bytes: 21380
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int maxn=307;

char S[maxn];
int L,K;

int dp[maxn][maxn][maxn],V[maxn][maxn];

int main(){
        scanf("%s%d",S+1,&K);
        L=strlen(S+1);
        for(int i=1;i<=L;++i) for(int j=L;j;--j) for(int k=0;k<=K;++k){
                if(S[i]==S[j]){
                        dp[i][j][k]=dp[i-1][j+1][k]+1;
                }else{
                        dp[i][j][k]=max(dp[i-1][j][k],dp[i][j+1][k]);
                        if(k) dp[i][j][k]=max(dp[i][j][k],dp[i-1][j+1][k-1]+1);
                }   
        }   
        for(int i=1;i<=L;++i) for(int j=L;j;--j){
                V[i][j]=max(max(V[i-1][j],V[i][j+1]),dp[i][j][K]);
        }   

        int ans=1;
        for(int i=2;i<L;++i) ans=max(ans,V[i-1][i+1]*2+1);
        for(int i=1;i<L;++i) ans=max(ans,V[i][i+1]*2);
        printf("%d\n",ans);
}


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

int main(){
	long long N,K,loop;
	cin >> N >> K;
	long long mini=0,maxi=N;
	long long dist=1;
	for(loop=1;loop<K;loop++){
		mini += loop;
		maxi += N-loop;
	}
	long long ans=0;
	for(;loop<N+2;loop++){
		ans += maxi-mini+1;
		mini+=loop;
		maxi+=N-loop;
		ans=ans%1000000007;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;

struct BIT
{
	ll M;
	std::vector<ll>bit;
	BIT(ll n)
	{
		init(n);
	}
	void init(ll n)
	{
		M=n;
		bit.resize(M+1);
		fill(bit.begin(),bit.end(),0);
	}
	ll sum(ll i)
	{
		ll s=0;
		while(i>0)
        {
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(ll i,ll x)
	{
		while(i<=M)
        {
			bit[i]+=x;
			i+=i&-i;
		}
	}
};


main()
{
	int N;
	cin>>N;
	vector<int>A(N);
	vector<int>A_Sort(N);
	for(int i=0;i<N;i++)
    {
		cin>>A[i];
		A_Sort[i]=A[i];
	}
	sort(A_Sort.begin(),A_Sort.end());
	int l=0;
	int r=N;
	while(l+1<r)
	{
		int c=(l+r)/2;
		vector<int>B(N);
		for(int i=0;i<N;i++) B[i]=(A[i]<A_Sort[c])?-1:1;
		vector<int>S(N);
		for(int i=0;i<N;i++) S[i]=(i==0)?S[i]:S[i-1]+B[i];
		long long cnt=0;
		BIT bit(2*N+1);
		bit.add(N,1);
		for(int i=0;i<N;i++)
		{
			cnt+=bit.sum(S[i]+N);
			bit.add(S[i]+N,1);
		}
		if(cnt>=1ll*N*(N+1)/4) l=c;
		else r=c;
	}
	cout<<A_Sort[l];
}


Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		int n, m;
		cin>>n>>m;
		string str;
		int prob;
		map<int, pair<int, int>> mp;
		REP(i, m)
		{
			cin>>prob;
			cin>>str;
			if(mp.find(prob)!=mp.end())
			{
				if(str=="WA")
				{
					if(mp[prob].first==0)
					{
						mp[prob].second++;
					}
				}
				else
				{
					mp[prob].first = 1;
				}
			}
			else
			{
				if(str=="WA")
				{
					mp[prob].first = 0;
					mp[prob].second = 1;
				}
				else
				{
					mp[prob].first = 1;
					mp[prob].second = 0;
				}
			}
		}
		int solved = 0, penalty = 0;
		for(auto m:mp)
		{
			if(m.second.first==1)
			{
				solved++;
				penalty = penalty + m.second.second;
			}
		}
		cout<<solved<<" "<<penalty<<"\n";
	}
}

Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        int answer = solve(N, a);
        System.out.println(answer);
    }
    private static int solve(int N, int[] a) {
        int answer = 0;
        for (int i = 0; i < N; i++) {
            answer += (a[i] - 1);
        }
        return answer;
    }
}


Measured memory_bytes: 25936
N,M=map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

flag=0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      if A[i+k][j:j+M]!=B[k]:
        break
      #print(i,j,k,' ',A[i+k][j:j+M],' ',B[k])
    else:
      flag=1
print('Yes' if flag==1 else 'No')

Measured memory_bytes: 3188
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

int32_t main(){
	int n, d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (sqrt(ld(x) * ld(x) + ld(y) * ld(y)) <= ld(d))
			ans ++;
	}
	cout << ans;
}


Measured memory_bytes: 3676
bin = {
    0 => 0b0111111,
    1 => 0b0000110,
    2 => 0b1011011,
    3 => 0b1001111,
    4 => 0b1100110,
    5 => 0b1101101,
    6 => 0b1111101,
    7 => 0b0100111,
    8 => 0b1111111,
    9 => 0b1101111,
}

loop do
    n = gets.to_i
    break if n == -1
    x = 0 
    n.times do
        n = gets.to_i
        printf("%07b\n", x ^ bin[n])
        x = bin[n]
    end
end 

Measured memory_bytes: 8672
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file


ll x,k,d;

int main(){
	cin >> x >> k >> d;
    ll ans = abs(x);
	if(ans / d >= k){
		ans -= k*d;
		cout << ans << endl;
	}
	else {
		k -= ans/d;
		ans = ans % d;
		
		k%=2;
		if(k == 0)cout << ans << endl;
		else cout << abs(ans - d) << endl;
		
	}
	
	
	return 0;
} 







Measured memory_bytes: 3604
X,Y,Z, K  = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)


count = 0
queued = set()
from heapq import heappush, heappop
hpq = []

i = j = k = 0
heappush(hpq, ( -(A[i]+B[j]+C[k]), i,j,k) )
queued.add( (i,j,k) )

ans = []
for k in range(K):
    p = heappop( hpq)
    ans.append( - p[0]  )
    if k == K-1: break
    i,j,k = p[1:]

    if (not (i+1,j,k) in queued) and i+1 < X and j < Y and k < Z:
        queued.add((i+1,j,k))
        heappush(hpq, (-(A[i+1]+B[j]+C[k]),i+1,j,k) )
        # i+=1
    if (not (i,j+1,k) in queued) and i < X and j+1 < Y and  k < Z:
        queued.add((i,j+1,k))
        heappush(hpq, (-(A[i]+B[j+1]+C[k]), i,j+1,k))
        # j+=1
    if (not (i,j,k+1) in queued) and i < X and j < Y and k+1 <Z:
        queued.add((i,j,k+1))
        heappush(hpq, (-(A[i]+B[j]+C[k+1]), i,j,k+1))
        # k+=1

for k in range(K):
    print(ans[k])
            




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

int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};  
int H,W,countB =0,d[55][55];
char G[55][55];
vector<vector<bool>> seen(55,vector<bool>(55,false));

void bfs(int a,int b) {
  seen[a][b] = true;
  queue<pair<int,int>> Q;
  Q.push({a,b});
  while (!Q.empty()) {
    int x,y; tie(x,y) = Q.front(); Q.pop();
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx >= H || nx < 0 || ny >= W || ny < 0) continue;
      if(seen[nx][ny]) continue;
      if(G[nx][ny] == '#') continue;
      d[nx][ny] = d[x][y] + 1;
      seen[nx][ny] = true;
      Q.push({nx,ny});
    }
  }
}   

int main() {
  cin >> H >> W;
  for (int i =0; i<H; i++) {
    string tmp; cin >> tmp;
    for (int j =0; j<W; j++) {
      G[i][j] = tmp[j];
      if (tmp[j] =='#') countB++;
    }
  }
  
  d[0][0] =1;
  bfs(0,0);
  int ans;
  if (d[H-1][W-1] ==0) ans = -1;
  else ans = H * W - d[H-1][W-1] - countB; 
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
 
int main(void){
    int i, j, flag, flag2,offset;
    int lenstr;
 
    char str[100];
 
    for(i = 0 ; i < 100; i++){
            str[i] = 0;
        }
 
    while(fgets(str, 100, stdin) != NULL){
        lenstr = strlen(str);
        flag = 0;
		flag2 = 0;
        for(i = 0; i < lenstr; i++){
            if(str[i]>str[i+1]){
                if((str[i]-str[i+1])=='t'-'h'){
                    flag = 1;
                }
            }else if(str[i]<str[i+1]){
                if(((str[i]+26)-str[i+1])=='t'-'h'){
                    flag = 1;
                }
            }

            if(flag){
                if((str[i] - 't')>=0){
                    offset = str[i] - 't';
					flag2 = 1;
                } else if((str[i] - 't')<0){
                    offset = str[i] - 't' + 26;
					flag2 = 2;
                }

                for(j = 0; j < lenstr; j++){
                    if(str[j] == ' ' || str[j] == ',' || str[j] == '.' || str[j] == '\n') continue;
						if((flag2 == 1)){
							str[j] = str[j] - offset;
						}else if(flag2 == 2){
							if((str[j]-'a')<offset){
								str[j] = str[j]+26 - offset;
							}else{
								str[j] = str[j] - offset;
							}
						}
                }
                break;
			}else{
				continue;
			}
        }
		if(strstr(str,"the") != NULL || strstr(str,"this") != NULL || strstr(str,"that") != NULL)
			printf("%s", str);

		for(i = 0 ; i < 100; i++){
            str[i] = 0;
        }
    }

    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

signed main(){
    int N,K,S;
    cin >> N >> K >> S;
    
    int ans[N+1];
    for(int i=1;i<=K;i++){
        ans[i] = S;
    }
    
    int a = 0;
    if(S==10001){
        a = 20001;
    }else{
        a = 10001;
    }
    for(int i=K+1;i<=N;i++){
        ans[i] = a;
    }
    
    for(int i=1;i<=N;i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2048