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

#define s second
#define f first

const long long maxn = 50;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool grd[maxn][maxn];
bool mark[maxn][maxn];
int dis[maxn][maxn];
long long n, m;
long long pen, ac;
long long state[maxn];
int ans;

void in();
void solve();
void out();
void bfs(int, int);

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            char w;
            cin >> w;
            if(w == '.')
                grd[i + 1][j + 1] = 1;
        }
    }
}

void solve(){
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= m; j++)
            if(grd[i][j])
                bfs(i, j);
}

void out(){
    cout << ans;
}

void bfs(int X, int Y){
    queue<pair<int, int>> bs;
    bs.push({X, Y});
    memset(mark, 0, sizeof mark);
    memset(dis, 0, sizeof dis);
    mark[X][Y] = 1;
    while(bs.size()){
        auto x = bs.front();
        bs.pop();
        for(int i = 0; i < 4; i++){
            if(grd[x.f + dx[i]][x.s + dy[i]] && !mark[x.f + dx[i]][x.s + dy[i]]){
                bs.push({x.f + dx[i], x.s + dy[i]});
                mark[x.f + dx[i]][x.s + dy[i]] = 1;
                dis[x.f + dx[i]][x.s + dy[i]] = dis[x.f][x.s] + 1;
                ans = max(ans, dis[x.f + dx[i]][x.s + dy[i]]);
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
#define diff(a,b) ((a)>(b))?(a)-(b):(b)-(a)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll x,n;
	cin >> x >> n;
	if(n==0){
		cout << x << endl;
		return 0;
	}
	ll p[n];
	cinf(p,n);
	sort(p,p+n);
	ll min=diff(x,x-n-1);	
	ll ans=x-n-101;
	ll j=0;
	arep(x-n-100,i,x+n+100){
		if(i==p[j]){
			j++;
			continue;
		}
		if(diff(x,i)<min){
			min=diff(x,i);
			ans=i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sum;
		for(int i = 0;i < 5;++i){
			sum = sc.nextInt();
			if(sum == 0) break;
			for(int j = 0;j < 9;++j){
				sum -= sc.nextInt();
			}
			System.out.println(sum);
		}
	}
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


int N, K;
ll H[200000];

signed main(){
    cin >> N >> K;
    REP(i, N) cin >> H[i];
    sort(H, H + N, greater<int>());
    ll sum = 0;
    FOR(i, K, N) sum += H[i];
    PRINT(sum);
    return 0;
}

Measured memory_bytes: 1792
n = int(input())
ST = []
    
for i in range(n-1):
    c,s,f = map(int,input().split())
    ST.append([c,s,f])


for i in range(n-1):    
    ans = ST[i][0] + ST[i][1]
    for j in range(i+1,n-1):
        if ans < ST[j][1]:
            ans = ST[j][1] +ST[j][0]
        elif (ans-ST[j][1])%ST[j][2] == 0:
                ans = ans + ST[j][0]
        else:
            ans = ans + ST[j][2] -(ans-ST[j][1])%ST[j][2] +ST[j][0]
    print(ans)
            
print('0')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int n;cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  ll ans1 = a[n-1];
  ll ans2 = 0;
  ll maximum = -1;
  rep(i,n-1){
    if(a[i] > ans1/2){
      if(ans1-a[i] > maximum){
        ans2 = a[i];
        maximum = ans1-a[i];
      }
    }else{
      if(a[i] > maximum){
        ans2 = a[i];
        maximum = a[i];
      }
    }
  }
  cout << ans1 SP ans2 << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main {
    
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt(); 
	    int arr[] = new int[n];
	    for(int i = 0; i<n; i++) arr[i] = in.readInt();
	    long ans = Long.MAX_VALUE;  
	    for(int t = -100; t<=100; t++) {
	    	long cost = 0; 
	    	for(int i = 0; i<n; i++) {
	    		cost += (int)Math.pow(arr[i] - t, 2);
	    	}
	    	ans = Math.min(ans, cost); 
	    }
	    System.out.println(ans); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

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

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

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

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
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;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

int main(){
	int n=read();
	vi a;
	REP(i,n)
		a.PB(read());
	ll ans=0;
	vector<pii> g;
	REP(i,n){
		int c=1;
		while(!g.empty()){
			if(g.back().first>=a[i]){
				ans-=ll(g.back().first)*g.back().second*(n-i);
				c+=g.back().second;
				g.pop_back();
			}else
				break;
		}
		g.PB(MP(a[i],c));
		ans+=ll(a[i])*c*(n-i);
	}
	cout<<ans<<endl;
}


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

static const int MAX = 10000;


static const int INFTY = (1 << 30 );

class DisjointSet {
private:
  vector<int> rank, p;
public:
  DisjointSet(){}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i = 0; i < size; ++i ) makeSet(i);
  }
    void makeSet(int x) {
      rank[x] = 0;
      p[x] = x;
    }

    bool same(int x, int y) {
      return findSet(x) == findSet(y);
    }
    int findSet(int x) {
      if( x != p[x]) { 
        p[x] = findSet(p[x]);
        rank[p[x]]--;
      }
      return p[x];
    }
    void unite(int x, int y) {
      int a = findSet(x);
      int b = findSet(y);
      if ( a != b ) {
        if( rank[a] < rank [b] )
          p[a] = b;
        else {
          p[b] = a;
          
        }
        if( rank[a] == rank[b] ) rank[a]++;
      }
    }
};

class Edge {
public: 
  int source, target, cost;

  Edge(int source = 0, int target = 0, int cost = 0):
   source(source), target(target), cost(cost){}
   bool operator < (const Edge e) {
      return cost < e.cost;
   }
};
int kruskal(int n, vector<Edge> edges) {
  int totalCost = 0;
  sort(edges.begin(), edges.end() );

  DisjointSet dset = DisjointSet(n );

  
  for(int i = 0; i < edges.size(); i++) {
    Edge e = edges[i];
    if( !dset.same(e.source, e.target)) {
      totalCost += e.cost;
      dset.unite(e.source, e.target);
    }
  }
  return totalCost;
}
int main() {
  int n, e;
  int u, v, w;
  cin >> n >> e;
  
  vector<Edge> edges;
   for( int i = 0; i < e; i++ ) 
   	 {
        cin >> u >> v >> w;
   		  edges.push_back(Edge(u, v, w));
   	}
  
   cout << kruskal(n, edges) << endl;
  
   return 0;
}


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

int main(){
   int n;
   cin >> n;
   vector<int> a(n),b(n),c(n-1);
   rep(i,n) {cin >> a[i];a[i] --;}
   rep(i,n) cin >> b[i];
   rep(i,n-1)cin >> c[i];
   int ans=0;
   rep(i,n){
     ans += b[a[i]];
     if(i>0 && a[i]-a[i-1] == 1) ans += c[a[i-1]];
   }
   cout << ans;
}
   

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

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

    String s = sc.next();

    int len = s.length();

    int[] nums = new int[len];
    int[][] table = new int[len][len];
    long ans = 0;

    for (int i = 0; i < len; i++) {
      nums[i] = Integer.parseInt(s.substring(i,i+1));
    }

    for (int i = 0; i < len; i++) {
      for (int j = 0; j < len; j++) {
        if (i == j) {
          table[i][j] = (int) Math.pow(2, i);
        }
      }
    }

    for (int i = 0; i < len; i++) {
      for (int j = 0; j < len; j++) {
        for (int k = 0; k< j; k++) {
          table[i][j] += table[i][k];
        }
        ans += nums[i] * ((long) Math.pow(10, len-j-1)) * table[i][j];
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 9684
from collections import deque

S = input()
Q = int(input())
X = [input() for _ in range(Q)]

ans = deque(S)
r = 0  # r=0: order, r=1: reverse
for i in range(Q):
    q, *x = X[i].split()
    if q == "1":
        r = abs(r - 1)
    else:
        f, c = x
        if (r == 0 and f == "1") or (r == 1 and f == "2"):
            ans.appendleft(c)
        else:
            ans.append(c)
            
print("".join(ans) if r == 0 else "".join(ans)[::-1])


Measured memory_bytes: 98776
#include <cstdio>

int main(){
    int a, b, d;
    while(scanf("%d %d %d", &a, &b, &d) && a && b && d){
        int ai = 1000000, bi = 0;
        for(int i=0 ; i<=ai+bi ; i++){
            int j = -1;
            int asum = i*a;
            int bsum = asum + d;
            if(bsum % b == 0){
                j = bsum / b;
                if(i+j < ai+bi){
                    ai = i;
                    bi = j;
                }if(i+j == ai+bi && a*i+b*j<a*ai+b*bi){
                    ai = i;
                    bi = j;
                }
            }
            if(asum >= d) bsum = asum - d;
            else bsum = d - asum;
            if(bsum % b == 0){
                j = bsum / b;
                if(i+j < ai+bi){
                    ai = i;
                    bi = j;
                }if(i+j == ai+bi && a*i+b*j<a*ai+b*bi){
                    ai = i;
                    bi = j;
                }
            }
        }printf("%d %d\n", ai, bi);
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<ctype.h>
  
char s[10000];
  
void min()
{
  int i,len=strlen(s);
  
  for(i=0;i<len;i++)s[i]=tolower(s[i]);
}
  
int main()
{
  char t[10000];
  int cnt=0;
  
  scanf("%s",t);
  for(;;)
  {
    scanf("%s",s);
  
    if(strcmp(s,"END_OF_TEXT")==0)break;
  
    min();
    if(strcmp(s,t)==0)cnt++;
  }
  printf("%d\n",cnt);
  
  return 0;
}

Measured memory_bytes: 556
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
//#define MAXN 1001000
using namespace std;
typedef vector<int> vi;
typedef set<int> se;
typedef pair<int,int> pii;
inline int mod(int n, int m){
int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
	fastio;
 	int a,b,c;
	 cin>>a>>b>>c;
	 cout<<c - min(a-b,c)<<endl; 
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
char s[202020];
int main()
{
    cin >> N>> s;
    int ans = 0;
    int mv = 0;
    for(int i=0; i<N; ++i)
    {
        if(s[i]=='D') --mv;
        else ++mv;
        if(ans<mv) ans = mv;
    }
    cout << ans << endl;
}

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


int main(){
    int n, l;
    cin>>n>>l;
    int sum = 0;
    int minim = INT_MAX;
    int temp;
    int actual= 0;
    for(int i = 1;i<=n;i++){
        temp = l + i - 1;
        if(abs(temp) < minim){
            minim = min(minim, abs(temp));
            actual = temp;
        }
        sum+= temp;
    }
    cout<<sum- actual<<endl;
    return 0;
}

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

/* constant */

const int MAX_N = 1000;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef map<string,int> msi;

struct Tool {
  string name, sup;
  int day1, day2, diff, i, si;

  void print() {
    printf("Tool: %s(%d):%d, %s(%d):%d\n",
	   name.c_str(), i, day1, sup.c_str(), si, day2);
  }
};

/* global variables */

int n;
Tool tools[MAX_N];
msi nhash;

bool used[MAX_N], tmpused[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> n;
    if (n == 0) break;

    nhash.clear();
    for (int i = 0; i < n; i++) {
      Tool& ti = tools[i];
      cin >> ti.name >> ti.day1 >> ti.sup >> ti.day2;
      ti.diff = ti.day1 - ti.day2;
      ti.i = i;
      ti.si = -1;
      nhash[ti.name] = i;
    }
    for (int i = 0; i < n; i++) {
      Tool& ti = tools[i];
      ti.si = nhash[ti.sup];
      //ti.print();
    }

    memset(used, false, sizeof(used));

    int minsum = 0;
    
    // find loops
    for (int i = 0; i < n; i++) {
      Tool& ti = tools[i];
      if (! used[i]) {
	memset(tmpused, false, sizeof(tmpused));
	tmpused[i] = true;
	int j = ti.si;
	for (; ! tmpused[j]; j = tools[j].si) {
	  if (used[j]) break;
	  tmpused[j] = true;
	}
	if (used[j]) continue;

	int sumloop = tools[j].day2;
	int mindiff = tools[j].diff;

	used[j] = true;
	for (int k = tools[j].si; k != j; k = tools[k].si) {
	  used[k] = true;
	  sumloop += tools[k].day2;
	  if (mindiff > tools[k].diff) mindiff = tools[k].diff;
	}

	minsum += sumloop + mindiff;
      }
    }
    //cout << ln << endl;

    // check leafs
    bool changed = true;
    while (changed) {
      changed = false;

      for (int i = 0; i < n; i++) {
	Tool& ti = tools[i];
	if (! used[i] && used[ti.si]) {
	  used[i] = true;
	  minsum += ti.day2;
	  changed = true;
	}
      }
    }
    
    cout << minsum << endl;
  }

  return 0;
}

Measured memory_bytes: 1412
# ABC122D - We Like AGC
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]


def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret


print(dfs(0, 'TTT'))


Measured memory_bytes: 3872
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;


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

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    int i=0;
    while(1)
    {
        if(i==0){
            c-=b;
            if(c<=0){
                cout<<"Yes";
                break;
            }
        }
        else{
            a-=d;
            if(a<=0){
                cout<<"No";
                break;
            }
        }
        i=i^1;
    }

    return (0);
}


Measured memory_bytes: 3592
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
dp = [[0] * N for _ in range(N)]

for l in range(N):
    for i in range(N-l):
        if l == 0:
            dp[i][i] = a[i]
        else:
            j = i + l
            dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1])
print(dp[0][N-1])

Measured memory_bytes: 113244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int a;
 cin >> a;
 int b;
 cin >> b;
 if(a>=13){
  cout << b <<endl;
 }
 else if(a>=6){
  cout<< b/2 <<endl;
 }
 else{
  cout<<"0"<<endl;
 }
 return 0;
}

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

A = []
B = []
C = []

for _ in range(n):
    A.append(list(map(int, input().split())))

for _ in range(m):
    B.append(int(input()))

for i in range(n):
    c = 0

    for j in range(m):
        c += A[i][j] * B[j]

    C.append(c)

for c in C:
    print(c)


Measured memory_bytes: 6016
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    print(ryuka(N))

memo = {}

def ryuka(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    if n in memo:
        return memo[n]
    res = ryuka(n-1) + ryuka(n-2)
    memo[n] = res
    return res

main()


Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
import copy

H, W = map(int, input().split(' '))
S = [list(input().rstrip('\r\n')) for _ in range(H)]
ans = copy.copy(S)

def count_bomb(h, w):
    hd_list = [-1, 0, 1]
    wd_list = [-1, 0, 1]
    count = 0
    for hd in hd_list:
        if h + hd < 0 or h + hd >= H:
            continue
        for wd in wd_list:
            if w + wd < 0 or w + wd >= W:
                continue
            if hd == 0 and wd == 0:
                continue
            if S[h+hd][w+wd] == '#':
                count += 1
    return count

for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            continue
        ans[h][w] = str(count_bomb(h, w))
for h in range(H):
    print(''.join(ans[h]))

Measured memory_bytes: 3684
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    for(;;){
        int n,a,b,c,x;
        cin >> n >> a >> b >> c >> x;
        if(!n) break;
        vector<int> Y(n);
        rep(i,n)cin >> Y[i];
        int ans = 0;
        int p=0;
        while (p<n) {
            if(x == Y[p]){
                p++;
            }
            if(ans>10000){
                ans = -1;
                break;
            }
            if(p==n)break;
            x = (a*x+b)%c;
            ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1<<30)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class T,typename I=typename T::iterator>auto&operator<<(ostream&os,T t){bool b=1;for(auto s:t)os<<(abi::__cxa_demangle(typeid(decltype(*declval<I>())).name(),0,0,0)[2]=='d'||exchange(b,0)?"":" ")<<s;return os<<endl;}

int main(){
	int n;
	cin>>n;
	if (n>999) cout<<"ABD"<<endl;
	else  cout<<"ABC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.00000000001
#define prid(x) printf("%.15lf\n", x)

struct vec{
  double x, y;
  vec operator+(const vec& a) const { return (vec){x + a.x, y + a.y}; }
  vec operator-(const vec& a) const { return (vec){x - a.x, y - a.y}; }
  vec sca(double t){ return (vec){t * x, t * y}; }
  double dot(vec a){ return x * a.x + y * a.y; }
  double cross(vec a){ return x * a.y - y * a.x; }
  double norm(){ return sqrt(x * x + y * y); };
};
struct line{
  vec a, b;
  vec getvec(){ return b - a; }
  vec proj(vec p){
    vec pa = p - a, ba = b - a;
    double t = pa.dot(ba) / ba.dot(ba);
    return a + ba.sca(t);
  }
  vec vref(vec p){ return proj(p).sca(2.0) - p; }
  int ccw(vec p){
    vec q = p - a, ba = b - a;
    if(ba.cross(q) > 0)return 1; //ccw
    if(ba.cross(q) < 0)return -1; //cw
    if(ba.dot(q) < 0)return -2; //back
    if(ba.dot(ba) < q.dot(q))return 2; //front
    return 0; //on
  }
  bool paral(line l){
    double res = abs(l.getvec().cross(getvec()));
    return res < eps;
  }
  bool orth(line l){
    double res = abs(l.getvec().dot(getvec()));
    return res < eps;
  }
};

signed main(void){
  int i, j, k;
  int(q);
  for(;q--;){
    line l, m;
    cin >> l.a.x >> l.a.y >> l.b.x >> l.b.y >> m.a.x >> m.a.y >> m.b.x >> m.b.y;
    if(l.paral(m))puts("2");
    else if(l.orth(m))puts("1");
    else puts("0");
  }

  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

using Graph = vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph &G,int v){
    seen[v] =true;
    for(auto next: G[v]){
        if(!seen[next]){
            dfs(G,next);
        }
    }
}

int main(){
    int N,M; 
    cin >> N >> M;

    Graph G(N+1);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    seen.assign(N,false);
    int cnt = 0;
    for(int i=1;i<=N;i++){
        if(!seen[i]){
            dfs(G,i);
            cnt++;
        }
    }
    
    cout << cnt-1 << endl;
}


Measured memory_bytes: 9592
#include<iostream>
using namespace std;
int main(){
        int n,k,sum=0,max=0;
        cin>>n>>k;
        int *w = (int *)malloc(sizeof(int)*n);
        for(int i=0;i<n;i++) {
                cin>>w[i];
                sum += w[i];
                max = max>w[i]? max:w[i];
        }
        int low=max, hi=sum, p, ntruck;
        while(low<hi){
                p=(low+hi)/2;
                int i=0,load;
                ntruck=0;
                while(i<n){
                        load = 0;
                        while(i<n && load+w[i]<=p){
                                load += w[i];
                                i++;
                        }
                        ntruck++;
                }
                if(ntruck<=k) hi = p;
                else low = p+1;
        }
        cout<<low<<endl;

        free(w);
        return 0;
}


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

int main(){
  int n,m;cin >> n >> m;
  int a[n],b[n];rep(i,n)cin >> a[i] >> b[i];
  int c[m],d[m];rep(i,m)cin >> c[i] >> d[i];
  for(int i=0;i<n;++i){
    long long an = 100000000000;
    int ans = 0;
    for(int j=0;j<m;++j){
      int m = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(m < an){ans = j+1;an = m;}
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,m:usize,s:Usize1,t:Usize1,
        uvab:[(Usize1,Usize1,i64,i64);m],
    }
    let INF = 10i64.pow(15);
    let mut g = vec![vec![]; n];
    for &(u, v, a, b) in uvab.iter() {
        g[u].push((v, a));
        g[v].push((u, a));
    }
    let mut dp = vec![INF; n];
    dp[s] = 0;
    let mut q = MinQueue::new();
    q.push((0, s));
    while let Some((d, v)) = q.pop() {
        if d > dp[v] {
            continue;
        }
        for &(u, c) in g[v].iter() {
            let d = d + c;
            if dp[u] > d {
                dp[u] = d;
                q.push((d, u));
            }
        }
    }
    let mut dp1 = dp.clone();

    let mut g = vec![vec![]; n];
    for &(u, v, a, b) in uvab.iter() {
        g[u].push((v, b));
        g[v].push((u, b));
    }
    let mut dp = vec![INF; n];
    dp[t] = 0;
    let mut q = MinQueue::new();
    q.push((0, t));
    while let Some((d, v)) = q.pop() {
        if d > dp[v] {
            continue;
        }
        for &(u, c) in g[v].iter() {
            let d = d + c;
            if dp[u] > d {
                dp[u] = d;
                q.push((d, u));
            }
        }
    }
    let mut dp2 = dp.clone();
    let mut val = INF;
    let mut anss = vec![];
    for (&s, &t) in dp1.iter().zip(dp2.iter()).rev() {
        val = min(s + t, val);
        anss.push(INF - val);
    }
    for &ans in anss.iter().rev() {
        println!("{}", ans);
    }
}
use std::{cmp::*, collections::*};
struct MinQueue<T> {
    que: BinaryHeap<Reverse<T>>,
}
impl<T: Ord + Copy> MinQueue<T> {
    fn new() -> MinQueue<T> {
        MinQueue {
            que: BinaryHeap::<Reverse<T>>::new(),
        }
    }
    fn is_empty(&mut self) -> bool {
        self.que.is_empty()
    }
    fn push(&mut self, x: T) {
        self.que.push(Reverse(x));
    }
    fn len(&mut self) -> usize {
        self.que.len()
    }
    fn pop(&mut self) -> Option<T> {
        if let Some(x) = self.que.pop() {
            let Reverse(y) = x;
            Some(y)
        } else {
            None
        }
    }
    fn peek(&mut self) -> Option<&T> {
        if let Some(x) = self.que.peek() {
            let Reverse(y) = x;
            Some(y)
        } else {
            None
        }
    }
}


Measured memory_bytes: 27920
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 3030, mod = 1e9 + 7;
int n, m, dp[maxn][2*maxn][2];
inline void add(int &a, int b) {
	a = a+b >= mod ? a+b-mod : a+b;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 0; i <= n; i++) dp[0][i][i==0] = 1;
	for(int i = 0; i < m; i++) {
		for(int j = 0; j <= n; j++) {
			int k = n-j;
			for(int f = 0; f < 2; f++) {
				if(j) {
					add(dp[i+1][j-1][f|(j==1)], dp[i][j][f]);
					add(dp[i+1][j][f|(j==1)], dp[i][j][f]);
				}
				if(k) {
					add(dp[i+1][j][f], dp[i][j][f]);
					add(dp[i+1][j+1][f], dp[i][j][f]);
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; i++) add(ans, dp[m][i][1]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 85760
s = list(input())

s.pop(-1)

if len(s)%2==1:
	s.pop(-1)
q = len(s)
for i in range(q//2):
	a =s[:len(s)//2]
	b =s[len(s)//2:]

	if a==b:
		print(len(a)*2)
		break
	else:
		s.pop(-1)
		s.pop(-1)
else:
	print(-1)

Measured memory_bytes: 3064
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int p[]=new int[n];
		
		int max=0;
		long total=0;
		for(int i=0;i<n;++i) {
			p[i]=sc.nextInt();
			max=Math.max(p[i], max);
			total=total+p[i];
		}
		total=total-max/2;
		System.out.println(total);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int N;
long long K;
vector<long long> A, F;

bool C(long long S) {
    long long cnt = 0;
    for(int i=0; i<N; ++i) {
        if(A[i] * F[i] > S) {
            cnt += A[i] - S / F[i];
        }
    }
    return cnt <= K;
}

int main() {
    cin >> N >> K;
    A.resize(N); F.resize(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    for(int i=0; i<N; ++i) cin >> F[i];
    sort(begin(A), end(A));
    sort(begin(F), end(F), greater<long long>());

    long long ng = -1, ok = 1001001001001001001;
    while(ok - ng > 1) {
        long long m = (ng + ok) / 2;
        if(C(m)) ok = m;
        else ng = m;
    }
    cout << ok << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	ll n,d;
	cin>>n>>d;
	ll ans=0;

	ans=n/(2*d+1);

	if(n%(2*d+1)!=0){
		ans++;
	}

	cout<<ans<<endl;

	
	
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, n;
	cin >> h >> w >> n;
	cout << min((n + h - 1) / h, (n + w - 1) / w) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, a[1 << 18], b[1 << 18], c[1 << 18], d[1 << 18], e[1 << 18], dist[1 << 18]; vector<pair<int, int>>x[1 << 18], y[1 << 18];
int main() {
	scanf("%d%d%d", &n, &m, &q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) scanf("%d%d", &a[i], &b[i]);
	for (int i = 1; i <= q; i++) scanf("%d", &c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].push_back(make_pair(b[i], d[i]));
		x[b[i]].push_back(make_pair(a[i], d[i]));
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.push(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (pair<int, int> i : x[a1]) {
			if (dist[i.first] == -1) {
				dist[i.first] = dist[a1] + 1;
				Q1.push(i.first);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		for (pair<int, int> j : x[i]) {
			if (dist[i] < dist[j.first]) y[i].push_back(j);
		}
	}
	priority_queue<pair<int, int> >Q; Q.push(make_pair(1 << 30, 1)); e[1] = (1 << 30);
	while (!Q.empty()) {
		int a1 = Q.top().first, a2 = Q.top().second; Q.pop();
		for (int i = 0; i < y[a2].size(); i++) {
			if (e[y[a2][i].first] < min(y[a2][i].second, a1)) {
				e[y[a2][i].first] = min(y[a2][i].second, a1);
				Q.push(make_pair(e[y[a2][i].first], y[a2][i].first));
			}
		}
	}
	sort(e + 1, e + n + 1);
	int T = 1;
	for (int i = 1; i <= q; i++) {
		while (e[T] <= i) T++;
		printf("%d\n", T - 1);
	}
	return 0;
}

Measured memory_bytes: 28144
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static void exec(MyScanner in, PrintWriter out) {
		in.nextInt();
		String S = in.next();
		int red = 0;
		int blue = 0;
		for (int i = 0; i < S.length(); i += 1) {
			int c = S.charAt(i);
			if (c == 'R') {
				red += 1;
			} else if (c == 'B') {
				blue += 1;
			}
		}
		out.println(red > blue ? "Yes" : "No");
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int readByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


Measured memory_bytes: 22356
n, k = map(int, input().split())
MOD = 1000000007


def combinations(n, r, MOD):
    if (r < 0) or (n < r):
        return 0

    r = min(r, n - r)
    return fact[n] * fact_inv[r] * fact_inv[n - r] % MOD


fact = [1, 1]
fact_inv = [1, 1]
inv = [0, 1]

for i in range(2, n + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    fact_inv.append((fact_inv[-1] * inv[-1]) % MOD)


s = 0
for num_zero in range(min(k + 1, n)):
    # nCz
    x = combinations(n, num_zero, MOD)

    # n-zCx
    y = combinations(n - 1, n - num_zero - 1, MOD)

    s += (x * y) % MOD


print(s % MOD)


Measured memory_bytes: 27000
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int h,w,m;
    cin>>h>>w>>m;
    map<int,int> cx,cy;
    vector<pair<int,int>> p;
    int mx=-1,my=-1;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        --x,--y;
        ++cx[x];
        ++cy[y];
        mx=max(mx,cx[x]);
        my=max(my,cy[y]);
        p.push_back({x,y});
    }
    int ans=mx+my-1;
    ll cnt=0;
    ll x=0,y=0;
    for(auto t:cx){
        if(t.second==mx)++x;
    }
    for(auto t:cy){
        if(t.second==my)++y;
    }
    for(auto t:p){
        if(cx[t.first]==mx&&cy[t.second]==my){
            ++cnt;
        }
    }
    if(cnt<x*y)++ans;
    cout<<ans<<endl;
}


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

int main() {
	long long N,K;
	cin>>N>>K;
	vector<int> H(N,0);
	for(int i=0; i<N; i++){
		long long h; cin>>h;
		H[i]=h;
	}
	sort(H.begin(),H.end(),greater<int>());
	long long count=0;
	for(int i=0; i<N; i++){
		if(i+1<=K) continue;
		count+=H[i];
	}
	cout<<count<<endl;
}
	
	

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

int main() {
    int N;
    int Y;
	int x = -1, y = -1, z = -1;

	cin >> N >> Y;

	for (int i = 0; i <= N; ++i){
		for (int j = 0; j <= N - i; ++j){
			int k = N - i - j;
			if (10000*i + 5000*j + 1000*k == Y){
				x = i;
				y = j;
				z = k;
			}
		}
	}

	cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

int main() {

    IO; 

    ll n;
    cin>>n;
    ll k;
    cin>>k;
    string s;
    cin>>s;
    if(k>n){
        cout<<s<<endl;
    }
    else{
        ll cnt=0;
        for(ll i=0;s[i];i++){
            cnt++;
            if(cnt==k){
                if(s[i]>=65 && s[i]<=90){
                    s[i]=s[i]-65+97;
                }
                break;
            }
        }
        cout<<s<<endl;
    }
    

}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll N, K, Q, j;
	cin >> N >> K >> Q;
	ll b[N];
	REP(i, 0, N)b[i] = K-Q;
	REP(i, 0, Q){
		cin >> j;
		++b[j-1];
	}
	REP(i, 0, N){
		if(b[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	

}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>

using namespace std;

vector<vector<char>> rec(301,vector<char>(301,'#'));

int main(){
  int h[300],w[300],cnt = 0;
  while(1){
    cin >> h[cnt] >> w[cnt];
    if(h[cnt] == 0 && w[cnt] == 0) break;
    cnt++;
  }

  for(int k=0;k < cnt;k++){
    for(int i=0;i < h[k];i++){
      for(int j=0;j < w[k];j++){
        if(i % 2 == 0){
          if(j % 2 != 0){
            rec.at(i).at(j) = '.';
          }
        }else{
          if(j % 2 == 0){
            rec.at(i).at(j) = '.';
          }
        }
        cout << rec.at(i).at(j);
        if(j == w[k]-1) cout << "\n";
      }
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 3184
unittest
{
	assert( [ "2", "1 2", "2 3" ].solve == 3 );
	assert( [ "3", "100 100", "10 10000", "1 1000000000" ].solve == 9991 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	auto as = new long[ n ];
	auto bs = new long[ n ];
	foreach( ref a, ref b; lockstep( as, bs ) )
	{
		input.popFront;
		auto ab = input.front.split.to!( long[] );
		a = ab[ 0 ];
		b = ab[ 1 ];
	}
	
	// 中央値の最小を計算
	as.sort;
	auto mi = ( as.length % 2 == 0 ) ? ( as[ $ / 2 - 1 ] + as[ $ / 2 ] ) : as[ $ / 2 ];
	
	// 中央値の最大を計算
	bs.sort;
	auto ma = ( bs.length % 2 == 0 ) ? ( bs[ $ / 2 - 1 ] + bs[ $ / 2 ] ) : bs[ $ / 2 ];
	
	// 中央値の個数を計算（最小～最大の間は、nが偶数のときは0.5刻み、nが奇数のときは1刻みで作れる）
	return ma - mi + 1;
}


Measured memory_bytes: 7068
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int a, b;
	cin >> a >> b;
	cout << a*b << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000 + 10;

int n, m, a[maxn], b[maxn], h[maxn], ecnt, pos[maxn], sfa[maxn], vis[maxn], w[maxn];
ll f[maxn], dp[maxn];
struct enode{
	int v, n;
	enode() {}
	enode(int _v, int _n):v(_v), n(_n) {}
}e[maxn << 1];

inline void addedge(int u, int v) { ecnt ++; e[ecnt] = enode(v,h[u]); h[u] = ecnt; }

inline bool cmp(int x, int y) { return w[x] < w[y]; }

int findfa(int u) { return (sfa[u] == u) ? (u) : (sfa[u] = findfa(sfa[u])); }

int lis[maxn];

inline void upmin(ll &x, ll y) { x = min(x,y); }

int main() {
	scanf("%d%d", &n, &m); ecnt = 0;
	memset(h,-1,sizeof(h));
	for(int i = 1;i <= n;i ++) scanf("%d%d", &a[i], &b[i]), w[i] = max(0,a[i] - b[i]);
	for(int i = 1;i <= m;i ++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addedge(u,v);
		addedge(v,u);
	}
	for(int i = 1;i <= n;i ++) pos[i] = i, sfa[i] = i;
	sort(pos + 1,pos + n + 1,cmp);
	for(int i = 1;i <= n;i ++) {
		int u = pos[i]; vis[u] = 1;
		f[u] = b[u]; int tot = 0;
		for(int j = h[u];~ j;j = e[j].n) {
			int v = e[j].v, r;
			if(!vis[v] || findfa(v) == findfa(u)) continue;
			r = findfa(v);
			f[u] += f[r];
			sfa[r] = u;
			lis[++ tot] = r;
		}
		dp[u] = f[u] + w[u];
		for(int j = 1;j <= tot;j ++) {
			int v = lis[j];
			ll now = f[u] - f[v] + max((ll)w[u],dp[v]);
			upmin(dp[u],now);
		}
	}
	ll Ans = dp[pos[n]];
	printf("%lld\n", Ans);
	return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    ll n, a, b, ans = 0;
    cin >> n >> a >> b;
    ll x = n / (a + b);
    ans += x * a;
    ans += min(n - x * (a + b), a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    cin>>n;
    for(int i=26,cnt=1;;i*=26,cnt++){
        if(n*25<i*26-1){
            n-=(i-1)/25;
            string s;
            for(int i=0;i<cnt;i++){
                s.push_back('a'+n%26);
                n/=26;
            }
            reverse(s.begin(),s.end());
            cout<<s<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628